package xyz.stream.view;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;

/* JADX INFO: loaded from: classes3.dex */
public class ThreeDotIndicatorView extends LinearLayout {

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public static final /* synthetic */ int f36373j = 0;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public View f36374a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public View f36375b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public View f36376c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public View f36377d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f36378e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final int f36379f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final int f36380g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final int f36381h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public AnimatorSet f36382i;

    public ThreeDotIndicatorView(Context context) {
        this(context, null);
    }

    public static void a(ThreeDotIndicatorView threeDotIndicatorView) {
        threeDotIndicatorView.getClass();
        threeDotIndicatorView.post(new i(threeDotIndicatorView, 3));
    }

    public void animateNext() {
        b();
        f();
        int i10 = this.f36381h * 2;
        int i11 = this.f36378e;
        float f10 = i10 + i11;
        View view = this.f36374a;
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f);
        View view2 = this.f36375b;
        Property property = View.TRANSLATION_X;
        ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(view2, (Property<View, Float>) property, view2.getTranslationX(), this.f36375b.getTranslationX() - f10);
        int i12 = this.f36379f;
        ValueAnimator valueAnimatorOfInt = ValueAnimator.ofInt(i12, i11);
        valueAnimatorOfInt.addUpdateListener(new h(this, 4));
        View view3 = this.f36376c;
        ObjectAnimator objectAnimatorOfFloat3 = ObjectAnimator.ofFloat(view3, (Property<View, Float>) property, view3.getTranslationX(), this.f36376c.getTranslationX() - f10);
        ValueAnimator valueAnimatorOfInt2 = ValueAnimator.ofInt(i11, i12);
        valueAnimatorOfInt2.addUpdateListener(new h(this, 5));
        View view4 = this.f36377d;
        ObjectAnimator objectAnimatorOfFloat4 = ObjectAnimator.ofFloat(view4, (Property<View, Float>) property, view4.getTranslationX(), this.f36376c.getTranslationX() - f10);
        ValueAnimator valueAnimatorOfArgb = ValueAnimator.ofArgb(-1, -10066330);
        valueAnimatorOfArgb.addUpdateListener(new h(this, 6));
        ValueAnimator valueAnimatorOfArgb2 = ValueAnimator.ofArgb(-10066330, -1);
        valueAnimatorOfArgb2.addUpdateListener(new h(this, 7));
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(objectAnimatorOfFloat, objectAnimatorOfFloat2, valueAnimatorOfInt, objectAnimatorOfFloat3, valueAnimatorOfInt2, objectAnimatorOfFloat4, valueAnimatorOfArgb, valueAnimatorOfArgb2);
        animatorSet.setDuration(300L);
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() { // from class: xyz.stream.view.ThreeDotIndicatorView.2
            @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
            public void onAnimationCancel(Animator animator) {
                ThreeDotIndicatorView threeDotIndicatorView = ThreeDotIndicatorView.this;
                threeDotIndicatorView.f36382i = null;
                ThreeDotIndicatorView.a(threeDotIndicatorView);
            }

            @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
            public void onAnimationEnd(Animator animator) {
                ThreeDotIndicatorView threeDotIndicatorView = ThreeDotIndicatorView.this;
                threeDotIndicatorView.f36382i = null;
                ThreeDotIndicatorView.a(threeDotIndicatorView);
            }
        });
        this.f36382i = animatorSet;
        animatorSet.start();
    }

    public void animatePrevious() {
        b();
        f();
        int i10 = this.f36381h * 2;
        int i11 = this.f36378e;
        float f10 = i10 + i11;
        View view = this.f36376c;
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(view, "alpha", view.getAlpha(), 0.0f);
        View view2 = this.f36375b;
        Property property = View.TRANSLATION_X;
        ObjectAnimator objectAnimatorOfFloat2 = ObjectAnimator.ofFloat(view2, (Property<View, Float>) property, view2.getTranslationX(), this.f36375b.getTranslationX() + f10);
        int i12 = this.f36379f;
        ValueAnimator valueAnimatorOfInt = ValueAnimator.ofInt(i12, i11);
        valueAnimatorOfInt.addUpdateListener(new h(this, 0));
        View view3 = this.f36374a;
        ObjectAnimator objectAnimatorOfFloat3 = ObjectAnimator.ofFloat(view3, (Property<View, Float>) property, view3.getTranslationX(), this.f36374a.getTranslationX() + f10);
        ValueAnimator valueAnimatorOfInt2 = ValueAnimator.ofInt(i11, i12);
        valueAnimatorOfInt2.addUpdateListener(new h(this, 1));
        View view4 = this.f36377d;
        ObjectAnimator objectAnimatorOfFloat4 = ObjectAnimator.ofFloat(view4, (Property<View, Float>) property, view4.getTranslationX(), this.f36374a.getTranslationX() + f10);
        ValueAnimator valueAnimatorOfArgb = ValueAnimator.ofArgb(-1, -10066330);
        valueAnimatorOfArgb.addUpdateListener(new h(this, 2));
        ValueAnimator valueAnimatorOfArgb2 = ValueAnimator.ofArgb(-10066330, -1);
        valueAnimatorOfArgb2.addUpdateListener(new h(this, 3));
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(objectAnimatorOfFloat, objectAnimatorOfFloat2, valueAnimatorOfInt, objectAnimatorOfFloat3, valueAnimatorOfInt2, objectAnimatorOfFloat4, valueAnimatorOfArgb, valueAnimatorOfArgb2);
        animatorSet.setDuration(300L);
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() { // from class: xyz.stream.view.ThreeDotIndicatorView.1
            @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
            public void onAnimationCancel(Animator animator) {
                ThreeDotIndicatorView threeDotIndicatorView = ThreeDotIndicatorView.this;
                threeDotIndicatorView.f36382i = null;
                ThreeDotIndicatorView.a(threeDotIndicatorView);
            }

            @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
            public void onAnimationEnd(Animator animator) {
                ThreeDotIndicatorView threeDotIndicatorView = ThreeDotIndicatorView.this;
                threeDotIndicatorView.f36382i = null;
                ThreeDotIndicatorView.a(threeDotIndicatorView);
            }
        });
        this.f36382i = animatorSet;
        animatorSet.start();
    }

    public final void b() {
        AnimatorSet animatorSet = this.f36382i;
        if (animatorSet != null) {
            animatorSet.cancel();
            this.f36382i = null;
        }
        View view = this.f36374a;
        if (view != null) {
            view.animate().cancel();
        }
        View view2 = this.f36375b;
        if (view2 != null) {
            view2.animate().cancel();
        }
        View view3 = this.f36376c;
        if (view3 != null) {
            view3.animate().cancel();
        }
        View view4 = this.f36377d;
        if (view4 != null) {
            view4.animate().cancel();
        }
    }

    public final View c(boolean z10) {
        View view = new View(getContext());
        view.setBackground(d(z10));
        view.setAlpha(1.0f);
        view.setScaleX(1.0f);
        view.setScaleY(1.0f);
        view.setTranslationX(0.0f);
        return view;
    }

    public final GradientDrawable d(boolean z10) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setColor(z10 ? -1 : -10066330);
        gradientDrawable.setCornerRadius(this.f36380g / 2.0f);
        gradientDrawable.mutate();
        return gradientDrawable;
    }

    public final int e(int i10) {
        return (int) ((i10 * getResources().getDisplayMetrics().density) + 0.5f);
    }

    public final void f() {
        View view = this.f36374a;
        if (view != null) {
            view.setAlpha(1.0f);
            this.f36374a.setScaleX(1.0f);
            this.f36374a.setScaleY(1.0f);
            this.f36374a.setTranslationX(0.0f);
        }
        View view2 = this.f36375b;
        if (view2 != null) {
            view2.setAlpha(1.0f);
            this.f36375b.setScaleX(1.0f);
            this.f36375b.setScaleY(1.0f);
            this.f36375b.setTranslationX(0.0f);
        }
        View view3 = this.f36376c;
        if (view3 != null) {
            view3.setAlpha(1.0f);
            this.f36376c.setScaleX(1.0f);
            this.f36376c.setScaleY(1.0f);
            this.f36376c.setTranslationX(0.0f);
        }
    }

    @Override // android.widget.LinearLayout, android.view.View
    public void onMeasure(int i10, int i11) {
        int paddingRight = (this.f36381h * 6) + (this.f36378e * 2) + getPaddingRight() + getPaddingLeft() + this.f36379f;
        int i12 = this.f36380g;
        setMeasuredDimension(paddingRight, i12);
        super.onMeasure(View.MeasureSpec.makeMeasureSpec(paddingRight, 1073741824), View.MeasureSpec.makeMeasureSpec(i12, 1073741824));
    }

    public ThreeDotIndicatorView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        int iE = e(15);
        this.f36378e = iE;
        int iE2 = e(60);
        this.f36379f = iE2;
        int iE3 = e(15);
        this.f36380g = iE3;
        int iE4 = e(10);
        this.f36381h = iE4;
        setOrientation(0);
        this.f36374a = c(false);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(iE, iE3);
        layoutParams.setMargins(iE4, 0, iE4, 0);
        this.f36374a.setLayoutParams(layoutParams);
        addView(this.f36374a);
        this.f36375b = c(true);
        LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(iE2, iE3);
        layoutParams2.setMargins(iE4, 0, iE4, 0);
        this.f36375b.setLayoutParams(layoutParams2);
        addView(this.f36375b);
        this.f36376c = c(false);
        LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(iE, iE3);
        layoutParams3.setMargins(iE4, 0, iE4, 0);
        this.f36376c.setLayoutParams(layoutParams3);
        addView(this.f36376c);
        this.f36377d = c(false);
        LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(iE, iE3);
        layoutParams4.setMargins(iE4, 0, iE4, 0);
        this.f36377d.setLayoutParams(layoutParams4);
        addView(this.f36377d);
        this.f36375b.post(new i(this, 0));
        this.f36376c.post(new i(this, 1));
        this.f36377d.post(new i(this, 2));
    }
}
