package androidx.leanback.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.content.Context;
import android.content.res.TypedArray;
import android.transition.TransitionValues;
import android.transition.Visibility;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import com.strmr.ps.R;
import defpackage.bo7;

/* JADX INFO: loaded from: classes.dex */
class SlideKitkat extends Visibility {
    public static final DecelerateInterpolator b = new DecelerateInterpolator();
    public static final AccelerateInterpolator c = new AccelerateInterpolator();
    public static final a d = new a();
    public static final b e = new b();
    public static final c f = new c();
    public static final d i = new d();
    public static final e j = new e();
    public static final f k = new f();
    public final g a;

    public class a extends h {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getTranslationX() - view.getWidth();
        }
    }

    public class b extends i {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getTranslationY() - view.getHeight();
        }
    }

    public class c extends h {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getTranslationX() + view.getWidth();
        }
    }

    public class d extends i {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getTranslationY() + view.getHeight();
        }
    }

    public class e extends h {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getLayoutDirection() == 1 ? view.getTranslationX() + view.getWidth() : view.getTranslationX() - view.getWidth();
        }
    }

    public class f extends h {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float a(View view) {
            return view.getLayoutDirection() == 1 ? view.getTranslationX() - view.getWidth() : view.getTranslationX() + view.getWidth();
        }
    }

    public interface g {
        float a(View view);

        float b(View view);

        Property getProperty();
    }

    public static abstract class h implements g {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float b(View view) {
            return view.getTranslationX();
        }

        @Override // androidx.leanback.transition.SlideKitkat.g
        public final Property getProperty() {
            return View.TRANSLATION_X;
        }
    }

    public static abstract class i implements g {
        @Override // androidx.leanback.transition.SlideKitkat.g
        public final float b(View view) {
            return view.getTranslationY();
        }

        @Override // androidx.leanback.transition.SlideKitkat.g
        public final Property getProperty() {
            return View.TRANSLATION_Y;
        }
    }

    public static class j extends AnimatorListenerAdapter {
        public boolean a = false;
        public float b;
        public final View c;
        public final float d;
        public final float e;
        public final int f;
        public final Property g;

        public j(View view, Property property, float f, float f2, int i) {
            this.g = property;
            this.c = view;
            this.e = f;
            this.d = f2;
            this.f = i;
            view.setVisibility(0);
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public final void onAnimationCancel(Animator animator) {
            View view = this.c;
            view.setTag(R.id.lb_slide_transition_value, new float[]{view.getTranslationX(), view.getTranslationY()});
            this.g.set(view, Float.valueOf(this.e));
            this.a = true;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public final void onAnimationEnd(Animator animator) {
            boolean z = this.a;
            View view = this.c;
            if (!z) {
                this.g.set(view, Float.valueOf(this.e));
            }
            view.setVisibility(this.f);
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener
        public final void onAnimationPause(Animator animator) {
            Property property = this.g;
            View view = this.c;
            this.b = ((Float) property.get(view)).floatValue();
            property.set(view, Float.valueOf(this.d));
            view.setVisibility(this.f);
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener
        public final void onAnimationResume(Animator animator) {
            Float fValueOf = Float.valueOf(this.b);
            Property property = this.g;
            View view = this.c;
            property.set(view, fValueOf);
            view.setVisibility(0);
        }
    }

    public SlideKitkat(Context context, AttributeSet attributeSet) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, bo7.n.l);
        int i2 = typedArrayObtainStyledAttributes.getInt(3, 80);
        if (i2 == 3) {
            this.a = d;
        } else if (i2 == 5) {
            this.a = f;
        } else if (i2 == 48) {
            this.a = e;
        } else if (i2 == 80) {
            this.a = i;
        } else if (i2 == 8388611) {
            this.a = j;
        } else {
            if (i2 != 8388613) {
                throw new IllegalArgumentException("Invalid slide direction");
            }
            this.a = k;
        }
        long j2 = typedArrayObtainStyledAttributes.getInt(1, -1);
        if (j2 >= 0) {
            setDuration(j2);
        }
        long j3 = typedArrayObtainStyledAttributes.getInt(2, -1);
        if (j3 > 0) {
            setStartDelay(j3);
        }
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(0, 0);
        if (resourceId > 0) {
            setInterpolator(AnimationUtils.loadInterpolator(context, resourceId));
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public static ObjectAnimator a(View view, Property property, float f2, float f3, float f4, TimeInterpolator timeInterpolator, int i2) {
        float[] fArr = (float[]) view.getTag(R.id.lb_slide_transition_value);
        if (fArr != null) {
            f2 = View.TRANSLATION_Y == property ? fArr[1] : fArr[0];
            view.setTag(R.id.lb_slide_transition_value, null);
        }
        ObjectAnimator objectAnimatorOfFloat = ObjectAnimator.ofFloat(view, (Property<View, Float>) property, f2, f3);
        j jVar = new j(view, property, f4, f3, i2);
        objectAnimatorOfFloat.addListener(jVar);
        objectAnimatorOfFloat.addPauseListener(jVar);
        objectAnimatorOfFloat.setInterpolator(timeInterpolator);
        return objectAnimatorOfFloat;
    }

    @Override // android.transition.Visibility
    public final Animator onAppear(ViewGroup viewGroup, TransitionValues transitionValues, int i2, TransitionValues transitionValues2, int i3) {
        View view = transitionValues2 != null ? transitionValues2.view : null;
        if (view == null) {
            return null;
        }
        float fB = this.a.b(view);
        return a(view, this.a.getProperty(), this.a.a(view), fB, fB, b, 0);
    }

    @Override // android.transition.Visibility
    public final Animator onDisappear(ViewGroup viewGroup, TransitionValues transitionValues, int i2, TransitionValues transitionValues2, int i3) {
        View view = transitionValues != null ? transitionValues.view : null;
        if (view == null) {
            return null;
        }
        float fB = this.a.b(view);
        return a(view, this.a.getProperty(), fB, this.a.a(view), fB, c, 4);
    }
}
