package androidx.leanback.widget;

import android.animation.TimeAnimator;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.AccelerateDecelerateInterpolator;
import androidx.leanback.widget.bi;
import androidx.leanback.widget.co;
import androidx.recyclerview.widget.RecyclerView;
import com.strmr.ps.R;
import defpackage.b61;
import defpackage.zo8;

/* JADX INFO: loaded from: classes.dex */
public class af {

    public static class a implements ae {
        public int a;

        @Override // androidx.leanback.widget.ae
        public final void a(View view, boolean z) {
            view.setSelected(z);
            c(view).a(z, false);
        }

        @Override // androidx.leanback.widget.ae
        public final void b(View view) {
            c(view).a(false, true);
        }

        public final b c(View view) {
            float fraction;
            b bVar = (b) view.getTag(R.id.lb_focus_animator);
            if (bVar == null) {
                Resources resources = view.getResources();
                int i = this.a;
                if (i == 0) {
                    fraction = 1.0f;
                } else {
                    fraction = resources.getFraction(i != 1 ? i != 2 ? i != 3 ? i != 4 ? 0 : R.fraction.lb_focus_zoom_factor_xsmall : R.fraction.lb_focus_zoom_factor_large : R.fraction.lb_focus_zoom_factor_medium : R.fraction.lb_focus_zoom_factor_small, 1, 1);
                }
                bVar = new b(150, fraction, view);
                view.setTag(R.id.lb_focus_animator, bVar);
            }
            return bVar;
        }
    }

    public static class b implements TimeAnimator.TimeListener {
        public final View a;
        public final int b;
        public final zo8 c;
        public final float d;
        public float e = 0.0f;
        public float f;
        public float g;
        public final TimeAnimator h;
        public final AccelerateDecelerateInterpolator i;
        public final b61 j;

        public b(int i, float f, View view) {
            TimeAnimator timeAnimator = new TimeAnimator();
            this.h = timeAnimator;
            this.i = new AccelerateDecelerateInterpolator();
            this.a = view;
            this.b = i;
            this.d = f - 1.0f;
            if (view instanceof zo8) {
                this.c = (zo8) view;
            } else {
                this.c = null;
            }
            timeAnimator.setTimeListener(this);
            this.j = null;
        }

        public final void a(boolean z, boolean z2) {
            TimeAnimator timeAnimator = this.h;
            timeAnimator.end();
            float f = z ? 1.0f : 0.0f;
            if (z2) {
                b(f);
                return;
            }
            float f2 = this.e;
            if (f2 != f) {
                this.f = f2;
                this.g = f - f2;
                timeAnimator.start();
            }
        }

        public void b(float f) {
            this.e = f;
            float f2 = (this.d * f) + 1.0f;
            View view = this.a;
            view.setScaleX(f2);
            view.setScaleY(f2);
            zo8 zo8Var = this.c;
            if (zo8Var != null) {
                zo8Var.setShadowFocusLevel(f);
            } else {
                g0.a(f, 3, view.getTag(R.id.lb_shadow_impl));
            }
            b61 b61Var = this.j;
            if (b61Var != null) {
                b61Var.a(f);
                int color = b61Var.c.getColor();
                if (zo8Var != null) {
                    zo8Var.setOverlayColor(color);
                    return;
                }
                Drawable foreground = view.getForeground();
                if (foreground instanceof ColorDrawable) {
                    ((ColorDrawable) foreground).setColor(color);
                } else {
                    view.setForeground(new ColorDrawable(color));
                }
            }
        }

        @Override // android.animation.TimeAnimator.TimeListener
        public final void onTimeUpdate(TimeAnimator timeAnimator, long j, long j2) {
            float interpolation;
            int i = this.b;
            if (j >= i) {
                this.h.end();
                interpolation = 1.0f;
            } else {
                interpolation = (float) (j / ((double) i));
            }
            AccelerateDecelerateInterpolator accelerateDecelerateInterpolator = this.i;
            if (accelerateDecelerateInterpolator != null) {
                interpolation = accelerateDecelerateInterpolator.getInterpolation(interpolation);
            }
            b((interpolation * this.g) + this.f);
        }
    }

    public static class c implements ae {
        public boolean a;
        public float b;
        public int c;

        public static class a extends b {
            public bi.d k;

            @Override // androidx.leanback.widget.af.b
            public final void b(float f) {
                bi.d dVar = this.k;
                ci ciVar = dVar.a;
                if (ciVar instanceof co) {
                    ((co) ciVar).j((co.a) dVar.b, f);
                }
                super.b(f);
            }
        }

        @Override // androidx.leanback.widget.ae
        public final void a(View view, boolean z) {
            if (!this.a) {
                Resources resources = view.getResources();
                TypedValue typedValue = new TypedValue();
                resources.getValue(R.dimen.lb_browse_header_select_scale, typedValue, true);
                this.b = typedValue.getFloat();
                resources.getValue(R.dimen.lb_browse_header_select_duration, typedValue, true);
                this.c = typedValue.data;
                this.a = true;
            }
            view.setSelected(z);
            b bVar = (b) view.getTag(R.id.lb_focus_animator);
            b bVar2 = bVar;
            if (bVar == null) {
                a aVar = new a(this.c, this.b, view);
                ViewParent parent = view.getParent();
                while (parent != null && !(parent instanceof RecyclerView)) {
                    parent = parent.getParent();
                }
                if (parent != null) {
                    aVar.k = (bi.d) ((RecyclerView) parent).getChildViewHolder(view);
                }
                view.setTag(R.id.lb_focus_animator, aVar);
                bVar2 = aVar;
            }
            bVar2.a(z, false);
        }

        @Override // androidx.leanback.widget.ae
        public final void b(View view) {
        }
    }

    public static void a(bi biVar) {
        biVar.d = new c();
    }
}
