package N1;

import android.content.Context;
import android.graphics.PointF;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
import androidx.recyclerview.widget.RecyclerView;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f4460a = -1;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public androidx.recyclerview.widget.a f4462c;

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

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f4464e;

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

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

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f4467h;
    public final LinearInterpolator i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final DecelerateInterpolator f4468j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public PointF f4469k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public final DisplayMetrics f4470l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public boolean f4471m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public float f4472n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public int f4473o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f4474p;

    public H(Context context) {
        n0 n0Var = new n0();
        n0Var.f4597d = -1;
        n0Var.f4599f = false;
        n0Var.f4600g = 0;
        n0Var.f4594a = 0;
        n0Var.f4595b = 0;
        n0Var.f4596c = Integer.MIN_VALUE;
        n0Var.f4598e = null;
        this.f4466g = n0Var;
        this.i = new LinearInterpolator();
        this.f4468j = new DecelerateInterpolator();
        this.f4471m = false;
        this.f4473o = 0;
        this.f4474p = 0;
        this.f4470l = context.getResources().getDisplayMetrics();
    }

    public static int a(int i, int i5, int i8, int i9, int i10) {
        if (i10 == -1) {
            return i8 - i;
        }
        if (i10 != 0) {
            if (i10 == 1) {
                return i9 - i5;
            }
            throw new IllegalArgumentException("snap preference should be one of the constants defined in SmoothScroller, starting with SNAP_");
        }
        int i11 = i8 - i;
        if (i11 > 0) {
            return i11;
        }
        int i12 = i9 - i5;
        if (i12 < 0) {
            return i12;
        }
        return 0;
    }

    public float b(DisplayMetrics displayMetrics) {
        return 25.0f / displayMetrics.densityDpi;
    }

    public final int c(int i) {
        return (int) Math.ceil(((double) d(i)) / 0.3356d);
    }

    public int d(int i) {
        float fAbs = Math.abs(i);
        if (!this.f4471m) {
            this.f4472n = b(this.f4470l);
            this.f4471m = true;
        }
        return (int) Math.ceil(fAbs * this.f4472n);
    }

    public PointF e(int i) {
        Object obj = this.f4462c;
        if (obj instanceof o0) {
            return ((o0) obj).f(i);
        }
        Log.w("RecyclerView", "You should override computeScrollVectorForPosition when the LayoutManager does not implement " + o0.class.getCanonicalName());
        return null;
    }

    public final View f(int i) {
        return this.f4461b.D.D(i);
    }

    /* JADX WARN: Removed duplicated region for block: B:50:0x00f0  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void g(int i, int i5) {
        PointF pointFE;
        RecyclerView recyclerView = this.f4461b;
        if (this.f4460a == -1 || recyclerView == null) {
            j();
        }
        if (this.f4463d && this.f4465f == null && this.f4462c != null && (pointFE = e(this.f4460a)) != null) {
            float f3 = pointFE.x;
            if (f3 != 0.0f || pointFE.y != 0.0f) {
                recyclerView.j0((int) Math.signum(f3), (int) Math.signum(pointFE.y), null);
            }
        }
        this.f4463d = false;
        View view = this.f4465f;
        n0 n0Var = this.f4466g;
        if (view != null) {
            this.f4461b.getClass();
            t0 t0VarN = RecyclerView.N(view);
            if ((t0VarN != null ? t0VarN.d() : -1) == this.f4460a) {
                i(this.f4465f, recyclerView.f9087y0, n0Var);
                n0Var.a(recyclerView);
                j();
            } else {
                Log.e("RecyclerView", "Passed over target position while smooth scrolling.");
                this.f4465f = null;
            }
        }
        if (this.f4464e) {
            p0 p0Var = recyclerView.f9087y0;
            if (this.f4461b.D.I() == 0) {
                j();
            } else {
                int i8 = this.f4473o;
                int i9 = i8 - i;
                if (i8 * i9 <= 0) {
                    i9 = 0;
                }
                this.f4473o = i9;
                int i10 = this.f4474p;
                int i11 = i10 - i5;
                if (i10 * i11 <= 0) {
                    i11 = 0;
                }
                this.f4474p = i11;
                if (i9 == 0 && i11 == 0) {
                    PointF pointFE2 = e(this.f4460a);
                    if (pointFE2 != null) {
                        if (pointFE2.x == 0.0f && pointFE2.y == 0.0f) {
                            n0Var.f4597d = this.f4460a;
                            j();
                        } else {
                            float f7 = pointFE2.y;
                            float fSqrt = (float) Math.sqrt((f7 * f7) + (r10 * r10));
                            float f8 = pointFE2.x / fSqrt;
                            pointFE2.x = f8;
                            float f9 = pointFE2.y / fSqrt;
                            pointFE2.y = f9;
                            this.f4469k = pointFE2;
                            this.f4473o = (int) (f8 * 10000.0f);
                            this.f4474p = (int) (f9 * 10000.0f);
                            n0Var.b((int) (this.f4473o * 1.2f), (int) (this.f4474p * 1.2f), (int) (d(10000) * 1.2f), this.i);
                        }
                    }
                }
            }
            boolean z8 = n0Var.f4597d >= 0;
            n0Var.a(recyclerView);
            if (z8 && this.f4464e) {
                this.f4463d = true;
                recyclerView.f9081v0.b();
            }
        }
    }

    public void h() {
        this.f4474p = 0;
        this.f4473o = 0;
        this.f4469k = null;
    }

    /* JADX WARN: Removed duplicated region for block: B:10:0x0015  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0055  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void i(View view, p0 p0Var, n0 n0Var) {
        int i;
        int iA;
        PointF pointF = this.f4469k;
        int i5 = -1;
        int iA2 = 0;
        if (pointF != null) {
            float f3 = pointF.x;
            i = f3 == 0.0f ? 0 : f3 > 0.0f ? 1 : -1;
        }
        androidx.recyclerview.widget.a aVar = this.f4462c;
        if (aVar == null || !aVar.p()) {
            iA = 0;
        } else {
            C0203d0 c0203d0 = (C0203d0) view.getLayoutParams();
            iA = a(aVar.N(view) - ((ViewGroup.MarginLayoutParams) c0203d0).leftMargin, aVar.Q(view) + ((ViewGroup.MarginLayoutParams) c0203d0).rightMargin, aVar.getPaddingLeft(), aVar.D - aVar.getPaddingRight(), i);
        }
        PointF pointF2 = this.f4469k;
        if (pointF2 != null) {
            float f7 = pointF2.y;
            if (f7 == 0.0f) {
                i5 = 0;
            } else if (f7 > 0.0f) {
                i5 = 1;
            }
        }
        androidx.recyclerview.widget.a aVar2 = this.f4462c;
        if (aVar2 != null && aVar2.q()) {
            C0203d0 c0203d02 = (C0203d0) view.getLayoutParams();
            iA2 = a(aVar2.R(view) - ((ViewGroup.MarginLayoutParams) c0203d02).topMargin, aVar2.L(view) + ((ViewGroup.MarginLayoutParams) c0203d02).bottomMargin, aVar2.getPaddingTop(), aVar2.f9113E - aVar2.getPaddingBottom(), i5);
        }
        int iC = c((int) Math.sqrt((iA2 * iA2) + (iA * iA)));
        if (iC > 0) {
            n0Var.b(-iA, -iA2, iC, this.f4468j);
        }
    }

    public final void j() {
        if (this.f4464e) {
            this.f4464e = false;
            h();
            this.f4461b.f9087y0.f4614a = -1;
            this.f4465f = null;
            this.f4460a = -1;
            this.f4463d = false;
            androidx.recyclerview.widget.a aVar = this.f4462c;
            if (aVar.f9118u == this) {
                aVar.f9118u = null;
            }
            this.f4462c = null;
            this.f4461b = null;
        }
    }
}
