package androidx.recyclerview.widget;

import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class e0 implements u1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ n0 f3691a;

    public e0(n0 n0Var) {
        this.f3691a = n0Var;
    }

    @Override // androidx.recyclerview.widget.u1
    public final void a(MotionEvent motionEvent) {
        n0 n0Var = this.f3691a;
        n0Var.f3814y.f1827a.onTouchEvent(motionEvent);
        VelocityTracker velocityTracker = n0Var.f3809t;
        if (velocityTracker != null) {
            velocityTracker.addMovement(motionEvent);
        }
        if (n0Var.f3801l == -1) {
            return;
        }
        int actionMasked = motionEvent.getActionMasked();
        int iFindPointerIndex = motionEvent.findPointerIndex(n0Var.f3801l);
        if (iFindPointerIndex >= 0) {
            n0Var.g(actionMasked, iFindPointerIndex, motionEvent);
        }
        j2 j2Var = n0Var.f3792c;
        if (j2Var == null) {
            return;
        }
        if (actionMasked != 1) {
            if (actionMasked == 2) {
                if (iFindPointerIndex >= 0) {
                    n0Var.o(n0Var.f3804o, iFindPointerIndex, motionEvent);
                    n0Var.m(j2Var);
                    RecyclerView recyclerView = n0Var.f3807r;
                    d0 d0Var = n0Var.f3808s;
                    recyclerView.removeCallbacks(d0Var);
                    d0Var.run();
                    n0Var.f3807r.invalidate();
                    return;
                }
                return;
            }
            if (actionMasked != 3) {
                if (actionMasked != 6) {
                    return;
                }
                int actionIndex = motionEvent.getActionIndex();
                if (motionEvent.getPointerId(actionIndex) == n0Var.f3801l) {
                    n0Var.f3801l = motionEvent.getPointerId(actionIndex == 0 ? 1 : 0);
                    n0Var.o(n0Var.f3804o, actionIndex, motionEvent);
                    return;
                }
                return;
            }
            VelocityTracker velocityTracker2 = n0Var.f3809t;
            if (velocityTracker2 != null) {
                velocityTracker2.clear();
            }
        }
        n0Var.select(null, 0);
        n0Var.f3801l = -1;
    }

    @Override // androidx.recyclerview.widget.u1
    public final boolean d(MotionEvent motionEvent) {
        int iFindPointerIndex;
        n0 n0Var = this.f3691a;
        n0Var.f3814y.f1827a.onTouchEvent(motionEvent);
        int actionMasked = motionEvent.getActionMasked();
        k0 k0Var = null;
        if (actionMasked == 0) {
            n0Var.f3801l = motionEvent.getPointerId(0);
            n0Var.f3793d = motionEvent.getX();
            n0Var.f3794e = motionEvent.getY();
            VelocityTracker velocityTracker = n0Var.f3809t;
            if (velocityTracker != null) {
                velocityTracker.recycle();
            }
            n0Var.f3809t = VelocityTracker.obtain();
            if (n0Var.f3792c == null) {
                ArrayList arrayList = n0Var.f3805p;
                if (!arrayList.isEmpty()) {
                    View viewJ = n0Var.j(motionEvent);
                    int size = arrayList.size() - 1;
                    while (true) {
                        if (size < 0) {
                            break;
                        }
                        k0 k0Var2 = (k0) arrayList.get(size);
                        if (k0Var2.f3752e.itemView == viewJ) {
                            k0Var = k0Var2;
                            break;
                        }
                        size--;
                    }
                }
                if (k0Var != null) {
                    n0Var.f3793d -= k0Var.f3756i;
                    n0Var.f3794e -= k0Var.f3757j;
                    j2 j2Var = k0Var.f3752e;
                    n0Var.i(j2Var, true);
                    if (n0Var.f3790a.remove(j2Var.itemView)) {
                        n0Var.f3802m.getClass();
                        h0.a(j2Var);
                    }
                    n0Var.select(j2Var, k0Var.f3753f);
                    n0Var.o(n0Var.f3804o, 0, motionEvent);
                }
            }
        } else if (actionMasked == 3 || actionMasked == 1) {
            n0Var.f3801l = -1;
            n0Var.select(null, 0);
        } else {
            int i10 = n0Var.f3801l;
            if (i10 != -1 && (iFindPointerIndex = motionEvent.findPointerIndex(i10)) >= 0) {
                n0Var.g(actionMasked, iFindPointerIndex, motionEvent);
            }
        }
        VelocityTracker velocityTracker2 = n0Var.f3809t;
        if (velocityTracker2 != null) {
            velocityTracker2.addMovement(motionEvent);
        }
        return n0Var.f3792c != null;
    }

    @Override // androidx.recyclerview.widget.u1
    public final void e(boolean z10) {
        if (z10) {
            this.f3691a.select(null, 0);
        }
    }
}
