package com.bytedance.sdk.component.adexpress.dynamic.animation.fm;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import com.bytedance.sdk.component.adexpress.dynamic.dynamicview.hxv;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

/* JADX INFO: loaded from: classes.dex */
public abstract class yz implements hxv {

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    public View f6463lb;
    com.bytedance.sdk.component.adexpress.dynamic.yz.fm ro;
    private Set<ScheduledFuture<?>> yz = new HashSet();
    public List<ObjectAnimator> fm = fm();

    public class fm implements Runnable {
        ObjectAnimator fm;
        ScheduledFuture<?> ro;

        public fm(ObjectAnimator objectAnimator) {
            this.fm = objectAnimator;
        }

        public void fm(ScheduledFuture<?> scheduledFuture) {
            this.ro = scheduledFuture;
        }

        @Override // java.lang.Runnable
        public void run() {
            if (com.bytedance.sdk.component.adexpress.fm.fm.fm.fm().lb() != null) {
                com.bytedance.sdk.component.adexpress.fm.fm.fm.fm().lb().lb().post(new Runnable() { // from class: com.bytedance.sdk.component.adexpress.dynamic.animation.fm.yz.fm.1
                    @Override // java.lang.Runnable
                    public void run() {
                        fm.this.fm.resume();
                    }
                });
                if (this.ro != null) {
                    yz.this.yz.remove(this.ro);
                }
            }
        }
    }

    public yz(View view, com.bytedance.sdk.component.adexpress.dynamic.yz.fm fmVar) {
        this.f6463lb = view;
        this.ro = fmVar;
    }

    public abstract List<ObjectAnimator> fm();

    public void lb() {
        List<ObjectAnimator> list = this.fm;
        if (list == null) {
            return;
        }
        for (final ObjectAnimator objectAnimator : list) {
            objectAnimator.start();
            if (this.ro.qhl() > 0.0d) {
                objectAnimator.addListener(new Animator.AnimatorListener() { // from class: com.bytedance.sdk.component.adexpress.dynamic.animation.fm.yz.1
                    @Override // android.animation.Animator.AnimatorListener
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override // android.animation.Animator.AnimatorListener
                    public void onAnimationEnd(Animator animator) {
                    }

                    @Override // android.animation.Animator.AnimatorListener
                    public void onAnimationRepeat(Animator animator) {
                        objectAnimator.pause();
                        fm fmVar = yz.this.new fm(objectAnimator);
                        ScheduledFuture<?> scheduledFutureFm = com.bytedance.sdk.component.adexpress.yz.yz.fm(fmVar, (long) (yz.this.ro.qhl() * 1000.0d), TimeUnit.MILLISECONDS);
                        fmVar.fm(scheduledFutureFm);
                        yz.this.yz.add(scheduledFutureFm);
                    }

                    @Override // android.animation.Animator.AnimatorListener
                    public void onAnimationStart(Animator animator) {
                    }
                });
            }
        }
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.dynamicview.hxv
    public void ro() {
        List<ObjectAnimator> list = this.fm;
        if (list == null) {
            return;
        }
        for (ObjectAnimator objectAnimator : list) {
            objectAnimator.cancel();
            objectAnimator.removeAllUpdateListeners();
        }
        Iterator<ScheduledFuture<?>> it = this.yz.iterator();
        while (it.hasNext()) {
            it.next().cancel(true);
        }
    }

    public ObjectAnimator fm(final ObjectAnimator objectAnimator) {
        objectAnimator.setStartDelay((long) (this.ro.onz() * 1000.0d));
        if (this.ro.fhx() > 0) {
            objectAnimator.setRepeatCount(this.ro.fhx() - 1);
        } else {
            objectAnimator.setRepeatCount(-1);
        }
        if (!"normal".equals(this.ro.irt())) {
            if ("alternate".equals(this.ro.irt()) || "alternate-reverse".equals(this.ro.irt())) {
                objectAnimator.setRepeatMode(2);
            } else {
                objectAnimator.setRepeatMode(1);
            }
        }
        if ("ease-in-out".equals(this.ro.dsz())) {
            objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        } else if ("ease-in".equals(this.ro.irt())) {
            objectAnimator.setInterpolator(new AccelerateInterpolator());
        } else if ("ease-out".equals(this.ro.irt())) {
            objectAnimator.setInterpolator(new DecelerateInterpolator());
        } else {
            objectAnimator.setInterpolator(new LinearInterpolator());
        }
        objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.bytedance.sdk.component.adexpress.dynamic.animation.fm.yz.2
            @Override // android.animation.ValueAnimator.AnimatorUpdateListener
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                if (valueAnimator.getCurrentPlayTime() > 0) {
                    yz.this.f6463lb.setVisibility(0);
                    if (yz.this.f6463lb.getParent() instanceof com.bytedance.sdk.component.adexpress.dynamic.dynamicview.ajl) {
                        ((View) yz.this.f6463lb.getParent()).setVisibility(0);
                    }
                    objectAnimator.removeAllUpdateListeners();
                }
            }
        });
        return objectAnimator;
    }
}
