package androidx.core.view;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.os.Build;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.animation.Interpolator;
import java.lang.ref.WeakReference;

/* JADX INFO: compiled from: ViewPropertyAnimatorCompat.java */
/* JADX INFO: loaded from: classes.dex */
public final class e0 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final WeakReference<View> f1885a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    Runnable f1886b = null;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    Runnable f1887c = null;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    int f1888d = -1;

    /* JADX INFO: compiled from: ViewPropertyAnimatorCompat.java */
    class a extends AnimatorListenerAdapter {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ f0 f1889a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f1890b;

        a(e0 e0Var, f0 f0Var, View view) {
            this.f1889a = f0Var;
            this.f1890b = view;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationCancel(Animator animator) {
            this.f1889a.c(this.f1890b);
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            this.f1889a.a(this.f1890b);
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationStart(Animator animator) {
            this.f1889a.b(this.f1890b);
        }
    }

    /* JADX INFO: compiled from: ViewPropertyAnimatorCompat.java */
    static class b {
        static ViewPropertyAnimator a(ViewPropertyAnimator viewPropertyAnimator, ValueAnimator.AnimatorUpdateListener animatorUpdateListener) {
            return viewPropertyAnimator.setUpdateListener(animatorUpdateListener);
        }
    }

    /* JADX INFO: compiled from: ViewPropertyAnimatorCompat.java */
    static class c implements f0 {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        e0 f1891a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        boolean f1892b;

        c(e0 e0Var) {
            this.f1891a = e0Var;
        }

        @Override // androidx.core.view.f0
        @SuppressLint({"WrongConstant"})
        public void a(View view) {
            int i3 = this.f1891a.f1888d;
            if (i3 > -1) {
                view.setLayerType(i3, null);
                this.f1891a.f1888d = -1;
            }
            if (Build.VERSION.SDK_INT >= 16 || !this.f1892b) {
                e0 e0Var = this.f1891a;
                Runnable runnable = e0Var.f1887c;
                if (runnable != null) {
                    e0Var.f1887c = null;
                    runnable.run();
                }
                Object tag = view.getTag(2113929216);
                f0 f0Var = tag instanceof f0 ? (f0) tag : null;
                if (f0Var != null) {
                    f0Var.a(view);
                }
                this.f1892b = true;
            }
        }

        @Override // androidx.core.view.f0
        public void b(View view) {
            this.f1892b = false;
            if (this.f1891a.f1888d > -1) {
                view.setLayerType(2, null);
            }
            e0 e0Var = this.f1891a;
            Runnable runnable = e0Var.f1886b;
            if (runnable != null) {
                e0Var.f1886b = null;
                runnable.run();
            }
            Object tag = view.getTag(2113929216);
            f0 f0Var = tag instanceof f0 ? (f0) tag : null;
            if (f0Var != null) {
                f0Var.b(view);
            }
        }

        @Override // androidx.core.view.f0
        public void c(View view) {
            Object tag = view.getTag(2113929216);
            f0 f0Var = tag instanceof f0 ? (f0) tag : null;
            if (f0Var != null) {
                f0Var.c(view);
            }
        }
    }

    e0(View view) {
        this.f1885a = new WeakReference<>(view);
    }

    private void i(View view, f0 f0Var) {
        if (f0Var != null) {
            view.animate().setListener(new a(this, f0Var, view));
        } else {
            view.animate().setListener(null);
        }
    }

    public e0 b(float f3) {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().alpha(f3);
        }
        return this;
    }

    public void c() {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().cancel();
        }
    }

    public long d() {
        View view = this.f1885a.get();
        if (view != null) {
            return view.animate().getDuration();
        }
        return 0L;
    }

    public e0 f(long j3) {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().setDuration(j3);
        }
        return this;
    }

    public e0 g(Interpolator interpolator) {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().setInterpolator(interpolator);
        }
        return this;
    }

    public e0 h(f0 f0Var) {
        View view = this.f1885a.get();
        if (view != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                i(view, f0Var);
            } else {
                view.setTag(2113929216, f0Var);
                i(view, new c(this));
            }
        }
        return this;
    }

    public e0 j(long j3) {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().setStartDelay(j3);
        }
        return this;
    }

    public e0 k(final h0 h0Var) {
        final View view = this.f1885a.get();
        if (view != null && Build.VERSION.SDK_INT >= 19) {
            b.a(view.animate(), h0Var != null ? new ValueAnimator.AnimatorUpdateListener() { // from class: androidx.core.view.d0
                @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                    h0Var.a(view);
                }
            } : null);
        }
        return this;
    }

    public void l() {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().start();
        }
    }

    public e0 m(float f3) {
        View view = this.f1885a.get();
        if (view != null) {
            view.animate().translationY(f3);
        }
        return this;
    }
}
