package com.bytedance.sdk.component.adexpress.dynamic.dynamicview;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import androidx.media3.exoplayer.ExoPlayer;

/* JADX INFO: loaded from: classes.dex */
public class yz extends ajl {
    ObjectAnimator fm;
    ObjectAnimator ro;
    private Runnable sds;
    private int wey;

    public yz(Context context, DynamicRootView dynamicRootView, com.bytedance.sdk.component.adexpress.dynamic.yz.wu wuVar) {
        super(context, dynamicRootView, wuVar);
        this.wey = 0;
        this.sds = new Runnable() { // from class: com.bytedance.sdk.component.adexpress.dynamic.dynamicview.yz.1
            @Override // java.lang.Runnable
            public void run() {
                yz.this.fm();
            }
        };
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.dynamicview.ajl, com.bytedance.sdk.component.adexpress.dynamic.dynamicview.jnr, android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        for (int i10 = 0; i10 < getChildCount(); i10++) {
            View childAt = getChildAt(i10);
            FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) childAt.getLayoutParams();
            layoutParams.topMargin = (this.wu - layoutParams.height) / 2;
            childAt.setLayoutParams(layoutParams);
            if (i10 != 0) {
                childAt.setVisibility(8);
            }
        }
        postDelayed(this.sds, 2500L);
    }

    @Override // com.bytedance.sdk.component.adexpress.dynamic.dynamicview.jnr, com.bytedance.sdk.component.adexpress.dynamic.dynamicview.hxv
    public void ro() {
        removeCallbacks(this.sds);
        ObjectAnimator objectAnimator = this.fm;
        if (objectAnimator != null) {
            objectAnimator.removeAllUpdateListeners();
            this.fm.cancel();
        }
        ObjectAnimator objectAnimator2 = this.ro;
        if (objectAnimator2 != null) {
            objectAnimator2.removeAllUpdateListeners();
            this.ro.cancel();
        }
        super.ro();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void fm() {
        final View childAt = getChildAt(this.wey);
        final View childAt2 = getChildAt((this.wey + 1) % getChildCount());
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(childAt, "translationY", 0.0f, (-(getChildAt(this.wey).getHeight() + this.wu)) / 2);
        this.fm = objectAnimatorOfFloat;
        objectAnimatorOfFloat.setInterpolator(new LinearInterpolator());
        this.fm.addListener(new Animator.AnimatorListener() { // from class: com.bytedance.sdk.component.adexpress.dynamic.dynamicview.yz.2
            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationCancel(Animator animator) {
            }

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

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

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationStart(Animator animator) {
            }
        });
        ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(childAt2, "translationY", (childAt2.getHeight() + this.wu) / 2, 0.0f);
        this.ro = objectAnimatorOfFloat2;
        objectAnimatorOfFloat2.setInterpolator(new LinearInterpolator());
        this.ro.addListener(new Animator.AnimatorListener() { // from class: com.bytedance.sdk.component.adexpress.dynamic.dynamicview.yz.3
            @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) {
            }

            @Override // android.animation.Animator.AnimatorListener
            public void onAnimationStart(Animator animator) {
                childAt2.setVisibility(0);
            }
        });
        this.fm.setDuration(500L);
        this.ro.setDuration(500L);
        this.fm.start();
        this.ro.start();
        int i10 = this.wey + 1;
        this.wey = i10;
        this.wey = i10 % getChildCount();
        postDelayed(this.sds, ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS);
    }
}
