package androidx.recyclerview.widget;

import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.animation.Interpolator;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.recyclerview.widget.RecyclerView;
import com.strmr.ps.R;
import defpackage.ky5;
import defpackage.n41;
import defpackage.sia;
import defpackage.sma;
import defpackage.zt3;
import java.util.ArrayList;
import java.util.WeakHashMap;

/* JADX INFO: loaded from: classes.dex */
public class x extends RecyclerView.n implements RecyclerView.q {
    public Rect aa;
    public long ab;
    public float d;
    public float e;
    public float f;
    public float g;
    public float h;
    public float i;
    public float j;
    public float k;
    public final f m;
    public int o;
    public int q;
    public RecyclerView r;
    public VelocityTracker t;
    public ArrayList u;
    public ArrayList v;
    public zt3 x;
    public d y;
    public final ArrayList a = new ArrayList();
    public final float[] b = new float[2];
    public RecyclerView.ag c = null;
    public int l = -1;
    public int n = 0;
    public final ArrayList p = new ArrayList();
    public final Runnable s = new a();
    public View w = null;
    public final RecyclerView.s z = new b();

    public class a implements Runnable {
        public a() {
        }

        /* JADX WARN: Removed duplicated region for block: B:23:0x007b  */
        /* JADX WARN: Removed duplicated region for block: B:35:0x00c1  */
        @Override // java.lang.Runnable
        /*
            Code decompiled incorrectly, please refer to instructions dump.
        */
        public final void run() {
            int iD;
            int iD2;
            x xVar = x.this;
            if (xVar.c != null) {
                long jCurrentTimeMillis = System.currentTimeMillis();
                long j = xVar.ab;
                long j2 = j == Long.MIN_VALUE ? 0L : jCurrentTimeMillis - j;
                RecyclerView.o layoutManager = xVar.r.getLayoutManager();
                if (xVar.aa == null) {
                    xVar.aa = new Rect();
                }
                layoutManager.calculateItemDecorationsForChild(xVar.c.itemView, xVar.aa);
                if (layoutManager.canScrollHorizontally()) {
                    int i = (int) (xVar.j + xVar.h);
                    int paddingLeft = (i - xVar.aa.left) - xVar.r.getPaddingLeft();
                    float f = xVar.h;
                    iD = ((f >= 0.0f || paddingLeft >= 0) && (f <= 0.0f || (paddingLeft = ((xVar.c.itemView.getWidth() + i) + xVar.aa.right) - (xVar.r.getWidth() - xVar.r.getPaddingRight())) <= 0)) ? 0 : paddingLeft;
                }
                if (layoutManager.canScrollVertically()) {
                    int i2 = (int) (xVar.k + xVar.i);
                    iD2 = (i2 - xVar.aa.top) - xVar.r.getPaddingTop();
                    float f2 = xVar.i;
                    if ((f2 >= 0.0f || iD2 >= 0) && (f2 <= 0.0f || (iD2 = ((xVar.c.itemView.getHeight() + i2) + xVar.aa.bottom) - (xVar.r.getHeight() - xVar.r.getPaddingBottom())) <= 0)) {
                        iD2 = 0;
                    }
                }
                if (iD != 0) {
                    f fVar = xVar.m;
                    RecyclerView recyclerView = xVar.r;
                    int width = xVar.c.itemView.getWidth();
                    xVar.r.getWidth();
                    iD = fVar.d(recyclerView, width, iD, j2);
                }
                int i3 = iD;
                if (iD2 != 0) {
                    f fVar2 = xVar.m;
                    RecyclerView recyclerView2 = xVar.r;
                    int height = xVar.c.itemView.getHeight();
                    xVar.r.getHeight();
                    iD2 = fVar2.d(recyclerView2, height, iD2, j2);
                }
                if (i3 == 0 && iD2 == 0) {
                    xVar.ab = Long.MIN_VALUE;
                    return;
                }
                if (xVar.ab == Long.MIN_VALUE) {
                    xVar.ab = jCurrentTimeMillis;
                }
                xVar.r.scrollBy(i3, iD2);
                RecyclerView.ag agVar = xVar.c;
                if (agVar != null) {
                    xVar.n(agVar);
                }
                xVar.r.removeCallbacks(xVar.s);
                RecyclerView recyclerView3 = xVar.r;
                WeakHashMap weakHashMap = sia.a;
                recyclerView3.postOnAnimation(this);
            }
        }
    }

    public class b implements RecyclerView.s {
        public b() {
        }

        @Override // androidx.recyclerview.widget.RecyclerView.s
        public final boolean a(MotionEvent motionEvent) {
            int iFindPointerIndex;
            x xVar = x.this;
            xVar.x.a.onTouchEvent(motionEvent);
            int actionMasked = motionEvent.getActionMasked();
            e eVar = null;
            if (actionMasked == 0) {
                xVar.l = motionEvent.getPointerId(0);
                xVar.d = motionEvent.getX();
                xVar.e = motionEvent.getY();
                VelocityTracker velocityTracker = xVar.t;
                if (velocityTracker != null) {
                    velocityTracker.recycle();
                }
                xVar.t = VelocityTracker.obtain();
                if (xVar.c == null) {
                    ArrayList arrayList = xVar.p;
                    if (!arrayList.isEmpty()) {
                        View viewK = xVar.k(motionEvent);
                        int size = arrayList.size() - 1;
                        while (true) {
                            if (size < 0) {
                                break;
                            }
                            e eVar2 = (e) arrayList.get(size);
                            if (eVar2.e.itemView == viewK) {
                                eVar = eVar2;
                                break;
                            }
                            size--;
                        }
                    }
                    if (eVar != null) {
                        RecyclerView.ag agVar = eVar.e;
                        xVar.d -= eVar.i;
                        xVar.e -= eVar.j;
                        xVar.j(agVar, true);
                        if (xVar.a.remove(agVar.itemView)) {
                            xVar.m.a(xVar.r, agVar);
                        }
                        xVar.p(agVar, eVar.f);
                        xVar.r(xVar.o, 0, motionEvent);
                    }
                }
            } else if (actionMasked == 3 || actionMasked == 1) {
                xVar.l = -1;
                xVar.p(null, 0);
            } else {
                int i = xVar.l;
                if (i != -1 && (iFindPointerIndex = motionEvent.findPointerIndex(i)) >= 0) {
                    xVar.h(actionMasked, iFindPointerIndex, motionEvent);
                }
            }
            VelocityTracker velocityTracker2 = xVar.t;
            if (velocityTracker2 != null) {
                velocityTracker2.addMovement(motionEvent);
            }
            return xVar.c != null;
        }

        @Override // androidx.recyclerview.widget.RecyclerView.s
        public final void d(boolean z) {
            if (z) {
                x.this.p(null, 0);
            }
        }

        @Override // androidx.recyclerview.widget.RecyclerView.s
        public final void e(MotionEvent motionEvent) {
            x xVar = x.this;
            Runnable runnable = xVar.s;
            xVar.x.a.onTouchEvent(motionEvent);
            VelocityTracker velocityTracker = xVar.t;
            if (velocityTracker != null) {
                velocityTracker.addMovement(motionEvent);
            }
            if (xVar.l == -1) {
                return;
            }
            int actionMasked = motionEvent.getActionMasked();
            int iFindPointerIndex = motionEvent.findPointerIndex(xVar.l);
            if (iFindPointerIndex >= 0) {
                xVar.h(actionMasked, iFindPointerIndex, motionEvent);
            }
            RecyclerView.ag agVar = xVar.c;
            if (agVar == null) {
                return;
            }
            if (actionMasked != 1) {
                if (actionMasked == 2) {
                    if (iFindPointerIndex >= 0) {
                        xVar.r(xVar.o, iFindPointerIndex, motionEvent);
                        xVar.n(agVar);
                        xVar.r.removeCallbacks(runnable);
                        ((a) runnable).run();
                        xVar.r.invalidate();
                        return;
                    }
                    return;
                }
                if (actionMasked != 3) {
                    if (actionMasked != 6) {
                        return;
                    }
                    int actionIndex = motionEvent.getActionIndex();
                    if (motionEvent.getPointerId(actionIndex) == xVar.l) {
                        xVar.l = motionEvent.getPointerId(actionIndex == 0 ? 1 : 0);
                        xVar.r(xVar.o, actionIndex, motionEvent);
                        return;
                    }
                    return;
                }
                VelocityTracker velocityTracker2 = xVar.t;
                if (velocityTracker2 != null) {
                    velocityTracker2.clear();
                }
            }
            xVar.p(null, 0);
            xVar.l = -1;
        }
    }

    public static abstract class c {
        public static final Interpolator b = new a();
        public static final Interpolator c = new b();
        public int a;

        public class a implements Interpolator {
            @Override // android.animation.TimeInterpolator
            public final float getInterpolation(float f) {
                return f * f * f * f * f;
            }
        }

        public class b implements Interpolator {
            @Override // android.animation.TimeInterpolator
            public final float getInterpolation(float f) {
                float f2 = f - 1.0f;
                return (f2 * f2 * f2 * f2 * f2) + 1.0f;
            }
        }

        public static int b(int i, int i2) {
            int i3;
            int i4 = i & 3158064;
            if (i4 == 0) {
                return i;
            }
            int i5 = i & (~i4);
            if (i2 == 0) {
                i3 = i4 >> 2;
            } else {
                int i6 = i4 >> 1;
                i5 |= (-3158065) & i6;
                i3 = (i6 & 3158064) >> 2;
            }
            return i5 | i3;
        }

        public static int c(int i, int i2) {
            int i3;
            int i4 = i & 789516;
            if (i4 == 0) {
                return i;
            }
            int i5 = i & (~i4);
            if (i2 == 0) {
                i3 = i4 << 2;
            } else {
                int i6 = i4 << 1;
                i5 |= (-789517) & i6;
                i3 = (i6 & 789516) << 2;
            }
            return i5 | i3;
        }

        public static void f(RecyclerView recyclerView, RecyclerView.ag agVar, float f, float f2, boolean z) {
            View view = agVar.itemView;
            if (z && view.getTag(R.id.item_touch_helper_previous_elevation) == null) {
                Float fValueOf = Float.valueOf(sia.i(view));
                int childCount = recyclerView.getChildCount();
                float f3 = 0.0f;
                for (int i = 0; i < childCount; i++) {
                    View childAt = recyclerView.getChildAt(i);
                    if (childAt != view) {
                        float fI = sia.i(childAt);
                        if (fI > f3) {
                            f3 = fI;
                        }
                    }
                }
                sia.ad(view, f3 + 1.0f);
                view.setTag(R.id.item_touch_helper_previous_elevation, fValueOf);
            }
            view.setTranslationX(f);
            view.setTranslationY(f2);
        }

        public void a(RecyclerView recyclerView, RecyclerView.ag agVar) {
            View view = agVar.itemView;
            Object tag = view.getTag(R.id.item_touch_helper_previous_elevation);
            if (tag instanceof Float) {
                sia.ad(view, ((Float) tag).floatValue());
            }
            view.setTag(R.id.item_touch_helper_previous_elevation, null);
            view.setTranslationX(0.0f);
            view.setTranslationY(0.0f);
        }

        public final int d(RecyclerView recyclerView, int i, int i2, long j) {
            if (this.a == -1) {
                this.a = recyclerView.getResources().getDimensionPixelSize(R.dimen.item_touch_helper_max_drag_scroll_per_frame);
            }
            int iSignum = (int) (((int) (((int) Math.signum(i2)) * this.a * ((b) c).getInterpolation(Math.min(1.0f, (Math.abs(i2) * 1.0f) / i)))) * ((a) b).getInterpolation(j <= ExoPlayer.DEFAULT_DETACH_SURFACE_TIMEOUT_MS ? j / 2000.0f : 1.0f));
            return iSignum == 0 ? i2 > 0 ? 1 : -1 : iSignum;
        }

        public boolean e() {
            return !(this instanceof ky5);
        }

        public abstract boolean g(RecyclerView recyclerView, RecyclerView.ag agVar, RecyclerView.ag agVar2);

        public void h(RecyclerView.ag agVar, int i) {
        }

        public abstract void i(RecyclerView.ag agVar);
    }

    public class d extends GestureDetector.SimpleOnGestureListener {
        public boolean a = true;

        public d() {
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public final boolean onDown(MotionEvent motionEvent) {
            return true;
        }

        @Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
        public final void onLongPress(MotionEvent motionEvent) {
            View viewK;
            RecyclerView.ag childViewHolder;
            x xVar = x.this;
            f fVar = xVar.m;
            if (!this.a || (viewK = xVar.k(motionEvent)) == null || (childViewHolder = xVar.r.getChildViewHolder(viewK)) == null) {
                return;
            }
            RecyclerView recyclerView = xVar.r;
            fVar.getClass();
            WeakHashMap weakHashMap = sia.a;
            if ((c.b(196611, recyclerView.getLayoutDirection()) & 16711680) != 0) {
                int pointerId = motionEvent.getPointerId(0);
                int i = xVar.l;
                if (pointerId == i) {
                    int iFindPointerIndex = motionEvent.findPointerIndex(i);
                    float x = motionEvent.getX(iFindPointerIndex);
                    float y = motionEvent.getY(iFindPointerIndex);
                    xVar.d = x;
                    xVar.e = y;
                    xVar.i = 0.0f;
                    xVar.h = 0.0f;
                    if (fVar.e()) {
                        xVar.p(childViewHolder, 2);
                    }
                }
            }
        }
    }

    @sma
    public static class e implements Animator.AnimatorListener {
        public final float a;
        public final float b;
        public final float c;
        public final float d;
        public final RecyclerView.ag e;
        public final int f;
        public final ValueAnimator g;
        public boolean h;
        public float i;
        public float j;
        public boolean k = false;
        public boolean l = false;
        public float m;

        public e(RecyclerView.ag agVar, int i, float f, float f2, float f3, float f4) {
            this.f = i;
            this.e = agVar;
            this.a = f;
            this.b = f2;
            this.c = f3;
            this.d = f4;
            ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
            this.g = valueAnimatorOfFloat;
            valueAnimatorOfFloat.addUpdateListener(new ab(this));
            valueAnimatorOfFloat.setTarget(agVar.itemView);
            valueAnimatorOfFloat.addListener(this);
            this.m = 0.0f;
        }

        @Override // android.animation.Animator.AnimatorListener
        public final void onAnimationCancel(Animator animator) {
            this.m = 1.0f;
        }

        @Override // android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            if (!this.l) {
                this.e.setIsRecyclable(true);
            }
            this.l = true;
        }

        @Override // android.animation.Animator.AnimatorListener
        public final void onAnimationRepeat(Animator animator) {
        }

        @Override // android.animation.Animator.AnimatorListener
        public final void onAnimationStart(Animator animator) {
        }
    }

    public static abstract class f extends c {
        public f() {
            this.a = -1;
        }
    }

    public interface g {
        void prepareForDrop(View view, View view2, int i, int i2);
    }

    public x(f fVar) {
        this.m = fVar;
    }

    public static boolean m(View view, float f2, float f3, float f4, float f5) {
        return f2 >= f4 && f2 <= f4 + ((float) view.getWidth()) && f3 >= f5 && f3 <= f5 + ((float) view.getHeight());
    }

    @Override // androidx.recyclerview.widget.RecyclerView.q
    public final void b(View view) {
        o(view);
        RecyclerView.ag childViewHolder = this.r.getChildViewHolder(view);
        if (childViewHolder == null) {
            return;
        }
        RecyclerView.ag agVar = this.c;
        if (agVar != null && childViewHolder == agVar) {
            p(null, 0);
            return;
        }
        j(childViewHolder, false);
        if (this.a.remove(childViewHolder.itemView)) {
            this.m.a(this.r, childViewHolder);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.q
    public final void c(View view) {
    }

    public final void f(RecyclerView recyclerView) {
        RecyclerView recyclerView2 = this.r;
        if (recyclerView2 == recyclerView) {
            return;
        }
        RecyclerView.s sVar = this.z;
        if (recyclerView2 != null) {
            recyclerView2.removeItemDecoration(this);
            this.r.removeOnItemTouchListener(sVar);
            this.r.removeOnChildAttachStateChangeListener(this);
            ArrayList arrayList = this.p;
            int size = arrayList.size();
            while (true) {
                size--;
                if (size < 0) {
                    break;
                }
                e eVar = (e) arrayList.get(0);
                eVar.g.cancel();
                this.m.a(this.r, eVar.e);
            }
            arrayList.clear();
            this.w = null;
            VelocityTracker velocityTracker = this.t;
            if (velocityTracker != null) {
                velocityTracker.recycle();
                this.t = null;
            }
            d dVar = this.y;
            if (dVar != null) {
                dVar.a = false;
                this.y = null;
            }
            if (this.x != null) {
                this.x = null;
            }
        }
        this.r = recyclerView;
        Resources resources = recyclerView.getResources();
        this.f = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_velocity);
        this.g = resources.getDimension(R.dimen.item_touch_helper_swipe_escape_max_velocity);
        this.q = ViewConfiguration.get(this.r.getContext()).getScaledTouchSlop();
        this.r.addItemDecoration(this);
        this.r.addOnItemTouchListener(sVar);
        this.r.addOnChildAttachStateChangeListener(this);
        this.y = new d();
        this.x = new zt3(this.r.getContext(), this.y);
    }

    public final int g(int i) {
        if ((i & 12) == 0) {
            return 0;
        }
        int i2 = this.h > 0.0f ? 8 : 4;
        VelocityTracker velocityTracker = this.t;
        f fVar = this.m;
        if (velocityTracker != null && this.l > -1) {
            float f2 = this.g;
            fVar.getClass();
            velocityTracker.computeCurrentVelocity(1000, f2);
            float xVelocity = this.t.getXVelocity(this.l);
            float yVelocity = this.t.getYVelocity(this.l);
            int i3 = xVelocity > 0.0f ? 8 : 4;
            float fAbs = Math.abs(xVelocity);
            if ((i3 & i) != 0 && i2 == i3 && fAbs >= this.f && fAbs > Math.abs(yVelocity)) {
                return i3;
            }
        }
        float width = this.r.getWidth();
        fVar.getClass();
        float f3 = width * 0.5f;
        if ((i & i2) == 0 || Math.abs(this.h) <= f3) {
            return 0;
        }
        return i2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.n
    public final void getItemOffsets(Rect rect, View view, RecyclerView recyclerView, RecyclerView.ac acVar) {
        rect.setEmpty();
    }

    public final void h(int i, int i2, MotionEvent motionEvent) {
        View viewK;
        if (this.c == null && i == 2 && this.n != 2) {
            this.m.getClass();
            if (this.r.getScrollState() == 1) {
                return;
            }
            RecyclerView.o layoutManager = this.r.getLayoutManager();
            int i3 = this.l;
            RecyclerView.ag childViewHolder = null;
            if (i3 != -1) {
                int iFindPointerIndex = motionEvent.findPointerIndex(i3);
                float x = motionEvent.getX(iFindPointerIndex) - this.d;
                float y = motionEvent.getY(iFindPointerIndex) - this.e;
                float fAbs = Math.abs(x);
                float fAbs2 = Math.abs(y);
                float f2 = this.q;
                if ((fAbs >= f2 || fAbs2 >= f2) && ((fAbs <= fAbs2 || !layoutManager.canScrollHorizontally()) && ((fAbs2 <= fAbs || !layoutManager.canScrollVertically()) && (viewK = k(motionEvent)) != null))) {
                    childViewHolder = this.r.getChildViewHolder(viewK);
                }
            }
            if (childViewHolder == null) {
                return;
            }
            RecyclerView recyclerView = this.r;
            WeakHashMap weakHashMap = sia.a;
            int iB = (c.b(196611, recyclerView.getLayoutDirection()) & 65280) >> 8;
            if (iB == 0) {
                return;
            }
            float x2 = motionEvent.getX(i2);
            float y2 = motionEvent.getY(i2);
            float f3 = x2 - this.d;
            float f4 = y2 - this.e;
            float fAbs3 = Math.abs(f3);
            float fAbs4 = Math.abs(f4);
            float f5 = this.q;
            if (fAbs3 >= f5 || fAbs4 >= f5) {
                if (fAbs3 > fAbs4) {
                    if (f3 < 0.0f && (iB & 4) == 0) {
                        return;
                    }
                    if (f3 > 0.0f && (iB & 8) == 0) {
                        return;
                    }
                } else {
                    if (f4 < 0.0f && (iB & 1) == 0) {
                        return;
                    }
                    if (f4 > 0.0f && (iB & 2) == 0) {
                        return;
                    }
                }
                this.i = 0.0f;
                this.h = 0.0f;
                this.l = motionEvent.getPointerId(0);
                p(childViewHolder, 1);
            }
        }
    }

    public final int i(int i) {
        if ((i & 3) == 0) {
            return 0;
        }
        int i2 = this.i > 0.0f ? 2 : 1;
        VelocityTracker velocityTracker = this.t;
        f fVar = this.m;
        if (velocityTracker != null && this.l > -1) {
            float f2 = this.g;
            fVar.getClass();
            velocityTracker.computeCurrentVelocity(1000, f2);
            float xVelocity = this.t.getXVelocity(this.l);
            float yVelocity = this.t.getYVelocity(this.l);
            int i3 = yVelocity > 0.0f ? 2 : 1;
            float fAbs = Math.abs(yVelocity);
            if ((i3 & i) != 0 && i3 == i2 && fAbs >= this.f && fAbs > Math.abs(xVelocity)) {
                return i3;
            }
        }
        float height = this.r.getHeight();
        fVar.getClass();
        float f3 = height * 0.5f;
        if ((i & i2) == 0 || Math.abs(this.i) <= f3) {
            return 0;
        }
        return i2;
    }

    public final void j(RecyclerView.ag agVar, boolean z) {
        ArrayList arrayList = this.p;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            e eVar = (e) arrayList.get(size);
            if (eVar.e == agVar) {
                eVar.k |= z;
                if (!eVar.l) {
                    eVar.g.cancel();
                }
                arrayList.remove(size);
                return;
            }
        }
    }

    public final View k(MotionEvent motionEvent) {
        float x = motionEvent.getX();
        float y = motionEvent.getY();
        RecyclerView.ag agVar = this.c;
        if (agVar != null) {
            View view = agVar.itemView;
            if (m(view, x, y, this.j + this.h, this.k + this.i)) {
                return view;
            }
        }
        ArrayList arrayList = this.p;
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            e eVar = (e) arrayList.get(size);
            View view2 = eVar.e.itemView;
            if (m(view2, x, y, eVar.i, eVar.j)) {
                return view2;
            }
        }
        return this.r.findChildViewUnder(x, y);
    }

    public final void l(float[] fArr) {
        if ((this.o & 12) != 0) {
            fArr[0] = (this.j + this.h) - this.c.itemView.getLeft();
        } else {
            fArr[0] = this.c.itemView.getTranslationX();
        }
        if ((this.o & 3) != 0) {
            fArr[1] = (this.k + this.i) - this.c.itemView.getTop();
        } else {
            fArr[1] = this.c.itemView.getTranslationY();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final void n(RecyclerView.ag agVar) {
        ArrayList arrayList;
        int i;
        int bottom;
        int iAbs;
        int top;
        int iAbs2;
        int left;
        int iAbs3;
        int right;
        int iAbs4;
        int i2;
        int i3;
        int i4;
        if (this.r.isLayoutRequested()) {
            return;
        }
        char c2 = 2;
        if (this.n != 2) {
            return;
        }
        f fVar = this.m;
        fVar.getClass();
        int i5 = (int) (this.j + this.h);
        int i6 = (int) (this.k + this.i);
        if (Math.abs(i6 - agVar.itemView.getTop()) >= agVar.itemView.getHeight() * 0.5f || Math.abs(i5 - agVar.itemView.getLeft()) >= agVar.itemView.getWidth() * 0.5f) {
            ArrayList arrayList2 = this.u;
            if (arrayList2 == null) {
                this.u = new ArrayList();
                this.v = new ArrayList();
            } else {
                arrayList2.clear();
                this.v.clear();
            }
            int iRound = Math.round(this.j + this.h);
            int iRound2 = Math.round(this.k + this.i);
            int width = agVar.itemView.getWidth() + iRound;
            int height = agVar.itemView.getHeight() + iRound2;
            int i7 = (iRound + width) / 2;
            int i8 = (iRound2 + height) / 2;
            RecyclerView.o layoutManager = this.r.getLayoutManager();
            int childCount = layoutManager.getChildCount();
            int i9 = 0;
            while (i9 < childCount) {
                char c3 = c2;
                View childAt = layoutManager.getChildAt(i9);
                if (childAt != agVar.itemView && childAt.getBottom() >= iRound2 && childAt.getTop() <= height && childAt.getRight() >= iRound && childAt.getLeft() <= width) {
                    RecyclerView.ag childViewHolder = this.r.getChildViewHolder(childAt);
                    int iAbs5 = Math.abs(i7 - ((childAt.getRight() + childAt.getLeft()) / 2));
                    int iAbs6 = Math.abs(i8 - ((childAt.getBottom() + childAt.getTop()) / 2));
                    int i10 = (iAbs6 * iAbs6) + (iAbs5 * iAbs5);
                    i2 = iRound;
                    int size = this.u.size();
                    i3 = iRound2;
                    i4 = width;
                    int i11 = 0;
                    int i12 = 0;
                    while (i11 < size) {
                        int i13 = size;
                        if (i10 <= ((Integer) this.v.get(i11)).intValue()) {
                            break;
                        }
                        i12++;
                        i11++;
                        size = i13;
                    }
                    this.u.add(i12, childViewHolder);
                    this.v.add(i12, Integer.valueOf(i10));
                } else {
                    i2 = iRound;
                    i3 = iRound2;
                    i4 = width;
                }
                i9++;
                c2 = c3;
                iRound = i2;
                iRound2 = i3;
                width = i4;
            }
            ArrayList arrayList3 = this.u;
            if (arrayList3.size() == 0) {
                return;
            }
            int width2 = agVar.itemView.getWidth() + i5;
            int height2 = agVar.itemView.getHeight() + i6;
            int left2 = i5 - agVar.itemView.getLeft();
            int top2 = i6 - agVar.itemView.getTop();
            int size2 = arrayList3.size();
            RecyclerView.ag agVar2 = null;
            int i14 = -1;
            int i15 = 0;
            while (i15 < size2) {
                RecyclerView.ag agVar3 = (RecyclerView.ag) arrayList3.get(i15);
                if (left2 <= 0 || (right = agVar3.itemView.getRight() - width2) >= 0) {
                    arrayList = arrayList3;
                    i = width2;
                } else {
                    arrayList = arrayList3;
                    i = width2;
                    if (agVar3.itemView.getRight() > agVar.itemView.getRight() && (iAbs4 = Math.abs(right)) > i14) {
                        i14 = iAbs4;
                        agVar2 = agVar3;
                    }
                }
                if (left2 < 0 && (left = agVar3.itemView.getLeft() - i5) > 0 && agVar3.itemView.getLeft() < agVar.itemView.getLeft() && (iAbs3 = Math.abs(left)) > i14) {
                    i14 = iAbs3;
                    agVar2 = agVar3;
                }
                if (top2 < 0 && (top = agVar3.itemView.getTop() - i6) > 0 && agVar3.itemView.getTop() < agVar.itemView.getTop() && (iAbs2 = Math.abs(top)) > i14) {
                    i14 = iAbs2;
                    agVar2 = agVar3;
                }
                if (top2 > 0 && (bottom = agVar3.itemView.getBottom() - height2) < 0 && agVar3.itemView.getBottom() > agVar.itemView.getBottom() && (iAbs = Math.abs(bottom)) > i14) {
                    i14 = iAbs;
                    agVar2 = agVar3;
                }
                i15++;
                arrayList3 = arrayList;
                width2 = i;
            }
            if (agVar2 == null) {
                this.u.clear();
                this.v.clear();
                return;
            }
            int absoluteAdapterPosition = agVar2.getAbsoluteAdapterPosition();
            agVar.getAbsoluteAdapterPosition();
            if (fVar.g(this.r, agVar, agVar2)) {
                RecyclerView recyclerView = this.r;
                RecyclerView.o layoutManager2 = recyclerView.getLayoutManager();
                if (layoutManager2 instanceof g) {
                    ((g) layoutManager2).prepareForDrop(agVar.itemView, agVar2.itemView, i5, i6);
                    return;
                }
                if (layoutManager2.canScrollHorizontally()) {
                    if (layoutManager2.getDecoratedLeft(agVar2.itemView) <= recyclerView.getPaddingLeft()) {
                        recyclerView.scrollToPosition(absoluteAdapterPosition);
                    }
                    if (layoutManager2.getDecoratedRight(agVar2.itemView) >= recyclerView.getWidth() - recyclerView.getPaddingRight()) {
                        recyclerView.scrollToPosition(absoluteAdapterPosition);
                    }
                }
                if (layoutManager2.canScrollVertically()) {
                    if (layoutManager2.getDecoratedTop(agVar2.itemView) <= recyclerView.getPaddingTop()) {
                        recyclerView.scrollToPosition(absoluteAdapterPosition);
                    }
                    if (layoutManager2.getDecoratedBottom(agVar2.itemView) >= recyclerView.getHeight() - recyclerView.getPaddingBottom()) {
                        recyclerView.scrollToPosition(absoluteAdapterPosition);
                    }
                }
            }
        }
    }

    public final void o(View view) {
        if (view == this.w) {
            this.w = null;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.n
    public final void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ac acVar) {
        float f2;
        float f3;
        if (this.c != null) {
            float[] fArr = this.b;
            l(fArr);
            f2 = fArr[0];
            f3 = fArr[1];
        } else {
            f2 = 0.0f;
            f3 = 0.0f;
        }
        RecyclerView.ag agVar = this.c;
        this.m.getClass();
        ArrayList arrayList = this.p;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            e eVar = (e) arrayList.get(i);
            RecyclerView.ag agVar2 = eVar.e;
            float f4 = eVar.a;
            float f5 = eVar.c;
            if (f4 == f5) {
                eVar.i = agVar2.itemView.getTranslationX();
            } else {
                eVar.i = n41.a(f5, f4, eVar.m, f4);
            }
            float f6 = eVar.b;
            float f7 = eVar.d;
            if (f6 == f7) {
                eVar.j = agVar2.itemView.getTranslationY();
            } else {
                eVar.j = n41.a(f7, f6, eVar.m, f6);
            }
            int iSave = canvas.save();
            c.f(recyclerView, eVar.e, eVar.i, eVar.j, false);
            canvas.restoreToCount(iSave);
        }
        if (agVar != null) {
            int iSave2 = canvas.save();
            c.f(recyclerView, agVar, f2, f3, true);
            canvas.restoreToCount(iSave2);
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.n
    public final void onDrawOver(Canvas canvas, RecyclerView recyclerView, RecyclerView.ac acVar) {
        boolean z = false;
        if (this.c != null) {
            float[] fArr = this.b;
            l(fArr);
            float f2 = fArr[0];
            float f3 = fArr[1];
        }
        RecyclerView.ag agVar = this.c;
        this.m.getClass();
        ArrayList arrayList = this.p;
        int size = arrayList.size();
        for (int i = 0; i < size; i++) {
            e eVar = (e) arrayList.get(i);
            int iSave = canvas.save();
            View view = eVar.e.itemView;
            canvas.restoreToCount(iSave);
        }
        if (agVar != null) {
            canvas.restoreToCount(canvas.save());
        }
        for (int i2 = size - 1; i2 >= 0; i2--) {
            e eVar2 = (e) arrayList.get(i2);
            boolean z2 = eVar2.l;
            if (z2 && !eVar2.h) {
                arrayList.remove(i2);
            } else if (!z2) {
                z = true;
            }
        }
        if (z) {
            recyclerView.invalidate();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:21:0x0050  */
    /* JADX WARN: Type inference failed for: r0v6, types: [android.view.ViewParent] */
    /* JADX WARN: Type inference failed for: r12v1 */
    /* JADX WARN: Type inference failed for: r12v10 */
    /* JADX WARN: Type inference failed for: r12v11 */
    /* JADX WARN: Type inference failed for: r12v2 */
    /* JADX WARN: Type inference failed for: r12v3, types: [boolean] */
    /* JADX WARN: Type inference failed for: r12v4 */
    /* JADX WARN: Type inference failed for: r12v5 */
    /* JADX WARN: Type inference failed for: r12v6 */
    /* JADX WARN: Type inference failed for: r12v7, types: [boolean] */
    /* JADX WARN: Type inference failed for: r12v9 */
    /* JADX WARN: Type inference failed for: r2v1, types: [androidx.recyclerview.widget.RecyclerView$ag] */
    /* JADX WARN: Type inference failed for: r3v1 */
    /* JADX WARN: Type inference failed for: r3v11 */
    /* JADX WARN: Type inference failed for: r3v14 */
    /* JADX WARN: Type inference failed for: r3v15 */
    /* JADX WARN: Type inference failed for: r3v2, types: [androidx.recyclerview.widget.x$c, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r3v3, types: [androidx.recyclerview.widget.x$c] */
    /* JADX WARN: Type inference failed for: r3v4 */
    /* JADX WARN: Type inference fix 'apply assigned field type' failed
    java.lang.UnsupportedOperationException: ArgType.getObject(), call class: class jadx.core.dex.instructions.args.ArgType$UnknownArg
    	at jadx.core.dex.instructions.args.ArgType.getObject(ArgType.java:593)
    	at jadx.core.dex.attributes.nodes.ClassTypeVarsAttr.getTypeVarsMapFor(ClassTypeVarsAttr.java:35)
    	at jadx.core.dex.nodes.utils.TypeUtils.replaceClassGenerics(TypeUtils.java:177)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.insertExplicitUseCast(FixTypesVisitor.java:397)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.tryFieldTypeWithNewCasts(FixTypesVisitor.java:359)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.applyFieldType(FixTypesVisitor.java:309)
    	at jadx.core.dex.visitors.typeinference.FixTypesVisitor.visit(FixTypesVisitor.java:94)
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void p(RecyclerView.ag agVar, int i) {
        ?? r3;
        ?? r12;
        boolean z;
        ?? r122;
        ?? r32;
        int iC;
        int i2;
        char c2;
        float fSignum;
        Object obj;
        if (agVar == this.c && i == this.n) {
            return;
        }
        this.ab = Long.MIN_VALUE;
        int i3 = this.n;
        j(agVar, true);
        this.n = i;
        if (i == 2) {
            if (agVar == null) {
                throw new IllegalArgumentException("Must pass a ViewHolder when dragging");
            }
            this.w = agVar.itemView;
        }
        int i4 = (1 << ((i * 8) + 8)) - 1;
        ?? r2 = this.c;
        f fVar = this.m;
        if (r2 != 0) {
            if (r2.itemView.getParent() != null) {
                if (i3 == 2) {
                    i2 = 0;
                } else if (this.n == 2) {
                    iC = 0;
                    i2 = iC;
                } else {
                    fVar.getClass();
                    RecyclerView recyclerView = this.r;
                    WeakHashMap weakHashMap = sia.a;
                    int iB = (c.b(196611, recyclerView.getLayoutDirection()) & 65280) >> 8;
                    if (iB != 0) {
                        if (Math.abs(this.h) > Math.abs(this.i)) {
                            int iG = g(iB);
                            if (iG > 0) {
                                iC = c.c(iG, this.r.getLayoutDirection());
                            } else {
                                iC = i(iB);
                                if (iC <= 0) {
                                }
                            }
                            i2 = iC;
                        } else {
                            int i5 = i(iB);
                            if (i5 > 0) {
                                iC = i5;
                            } else {
                                int iG2 = g(iB);
                                if (iG2 > 0) {
                                    iC = c.c(iG2, this.r.getLayoutDirection());
                                }
                            }
                            i2 = iC;
                        }
                    }
                }
                VelocityTracker velocityTracker = this.t;
                if (velocityTracker != null) {
                    velocityTracker.recycle();
                    this.t = null;
                }
                char c3 = 4;
                float fSignum2 = 0.0f;
                if (i2 == 1 || i2 == 2) {
                    c2 = 0;
                    fSignum = Math.signum(this.i) * this.r.getHeight();
                    obj = null;
                } else if (i2 == 4 || i2 == 8 || i2 == 16 || i2 == 32) {
                    c2 = 0;
                    fSignum2 = Math.signum(this.h) * this.r.getWidth();
                    obj = null;
                    fSignum = 0.0f;
                } else {
                    obj = null;
                    fSignum = 0.0f;
                    c2 = 0;
                }
                if (i3 == 2) {
                    c3 = '\b';
                } else if (i2 > 0) {
                    c3 = 2;
                }
                float[] fArr = this.b;
                l(fArr);
                char c4 = c3;
                ?? r123 = c2;
                y yVar = new y(this, r2, i3, fArr[c2], fArr[1], fSignum2, fSignum, i2, r2);
                RecyclerView recyclerView2 = this.r;
                fVar.getClass();
                RecyclerView.l itemAnimator = recyclerView2.getItemAnimator();
                long j = itemAnimator == null ? c4 == '\b' ? 200L : 250L : c4 == '\b' ? itemAnimator.e : itemAnimator.d;
                ValueAnimator valueAnimator = yVar.g;
                valueAnimator.setDuration(j);
                this.p.add(yVar);
                r2.setIsRecyclable(r123);
                valueAnimator.start();
                r32 = fVar;
                z = true;
                r122 = r123;
            } else {
                r122 = 0;
                o(r2.itemView);
                ?? r33 = fVar;
                r33.a(this.r, r2);
                z = false;
                r32 = r33;
            }
            this.c = null;
            r3 = r32;
            r12 = r122;
        } else {
            r3 = fVar;
            r12 = 0;
            z = false;
        }
        if (agVar != null) {
            RecyclerView recyclerView3 = this.r;
            r3.getClass();
            WeakHashMap weakHashMap2 = sia.a;
            this.o = (c.b(196611, recyclerView3.getLayoutDirection()) & i4) >> (this.n * 8);
            this.j = agVar.itemView.getLeft();
            this.k = agVar.itemView.getTop();
            this.c = agVar;
            if (i == 2) {
                agVar.itemView.performHapticFeedback(r12 == true ? 1 : 0);
            }
        }
        ?? parent = this.r.getParent();
        if (parent != 0) {
            ?? r124 = r12;
            if (this.c != null) {
                r124 = 1;
            }
            parent.requestDisallowInterceptTouchEvent(r124);
        }
        if (!z) {
            this.r.getLayoutManager().requestSimpleAnimationsInNextLayout();
        }
        r3.h(this.c, this.n);
        this.r.invalidate();
    }

    public final void q(RecyclerView.ag agVar) {
        RecyclerView recyclerView = this.r;
        this.m.getClass();
        WeakHashMap weakHashMap = sia.a;
        if ((c.b(196611, recyclerView.getLayoutDirection()) & 16711680) == 0) {
            Log.e("ItemTouchHelper", "Start drag has been called but dragging is not enabled");
            return;
        }
        if (agVar.itemView.getParent() != this.r) {
            Log.e("ItemTouchHelper", "Start drag has been called with a view holder which is not a child of the RecyclerView which is controlled by this ItemTouchHelper.");
            return;
        }
        VelocityTracker velocityTracker = this.t;
        if (velocityTracker != null) {
            velocityTracker.recycle();
        }
        this.t = VelocityTracker.obtain();
        this.i = 0.0f;
        this.h = 0.0f;
        p(agVar, 2);
    }

    public final void r(int i, int i2, MotionEvent motionEvent) {
        float x = motionEvent.getX(i2);
        float y = motionEvent.getY(i2);
        float f2 = x - this.d;
        this.h = f2;
        this.i = y - this.e;
        if ((i & 4) == 0) {
            this.h = Math.max(0.0f, f2);
        }
        if ((i & 8) == 0) {
            this.h = Math.min(0.0f, this.h);
        }
        if ((i & 1) == 0) {
            this.i = Math.max(0.0f, this.i);
        }
        if ((i & 2) == 0) {
            this.i = Math.min(0.0f, this.i);
        }
    }
}
