package X6FRs_4.KQgRr5e_0.LGe8pk_15;

import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewParent;
/* compiled from: ForwardingListener.java */
/* loaded from: classes.dex */
public abstract class NQvZgp_17 implements View.OnTouchListener, View.OnAttachStateChangeListener {
    public final float KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final int f723KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final View f724KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public Runnable f725KQgRr5e_0;

    /* renamed from: KQgRr5e_0  reason: collision with other field name */
    public final int[] f726KQgRr5e_0 = new int[2];
    public int PGPF6hQ_2;
    public final int QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public Runnable f727QxJ9d_1;

    /* renamed from: QxJ9d_1  reason: collision with other field name */
    public boolean f728QxJ9d_1;

    /* compiled from: ForwardingListener.java */
    /* loaded from: classes.dex */
    public class KQgRr5e_0 implements Runnable {
        public KQgRr5e_0() {
        }

        @Override // java.lang.Runnable
        public void run() {
            ViewParent parent = NQvZgp_17.this.f724KQgRr5e_0.getParent();
            if (parent != null) {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
    }

    /* compiled from: ForwardingListener.java */
    /* loaded from: classes.dex */
    public class QxJ9d_1 implements Runnable {
        public QxJ9d_1() {
        }

        @Override // java.lang.Runnable
        public void run() {
            NQvZgp_17.this.QxJ9d_1();
        }
    }

    public NQvZgp_17(View view) {
        this.f724KQgRr5e_0 = view;
        view.setLongClickable(true);
        view.addOnAttachStateChangeListener(this);
        this.KQgRr5e_0 = ViewConfiguration.get(view.getContext()).getScaledTouchSlop();
        int tapTimeout = ViewConfiguration.getTapTimeout();
        this.f723KQgRr5e_0 = tapTimeout;
        this.QxJ9d_1 = (tapTimeout + ViewConfiguration.getLongPressTimeout()) / 2;
    }

    public abstract X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.Eps4cJe_18 KQgRr5e_0();

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public final void m409KQgRr5e_0() {
        Runnable runnable = this.f727QxJ9d_1;
        if (runnable != null) {
            this.f724KQgRr5e_0.removeCallbacks(runnable);
        }
        Runnable runnable2 = this.f725KQgRr5e_0;
        if (runnable2 != null) {
            this.f724KQgRr5e_0.removeCallbacks(runnable2);
        }
    }

    /* renamed from: KQgRr5e_0  reason: collision with other method in class */
    public abstract boolean m410KQgRr5e_0();

    /* renamed from: QxJ9d_1  reason: collision with other method in class */
    public boolean m411QxJ9d_1() {
        X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.Eps4cJe_18 KQgRr5e_02 = KQgRr5e_0();
        if (KQgRr5e_02 == null || !KQgRr5e_02.m473KQgRr5e_0()) {
            return true;
        }
        KQgRr5e_02.dismiss();
        return true;
    }

    @Override // android.view.View.OnTouchListener
    public boolean onTouch(View view, MotionEvent motionEvent) {
        boolean z;
        boolean z2 = this.f728QxJ9d_1;
        if (z2) {
            z = KQgRr5e_0(motionEvent) || !m411QxJ9d_1();
        } else {
            z = QxJ9d_1(motionEvent) && m410KQgRr5e_0();
            if (z) {
                long uptimeMillis = SystemClock.uptimeMillis();
                MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
                this.f724KQgRr5e_0.onTouchEvent(obtain);
                obtain.recycle();
            }
        }
        this.f728QxJ9d_1 = z;
        return z || z2;
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public void onViewAttachedToWindow(View view) {
    }

    @Override // android.view.View.OnAttachStateChangeListener
    public void onViewDetachedFromWindow(View view) {
        this.f728QxJ9d_1 = false;
        this.PGPF6hQ_2 = -1;
        Runnable runnable = this.f725KQgRr5e_0;
        if (runnable != null) {
            this.f724KQgRr5e_0.removeCallbacks(runnable);
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:12:0x0017, code lost:
        if (r1 != 3) goto L13;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean QxJ9d_1(MotionEvent motionEvent) {
        View view = this.f724KQgRr5e_0;
        if (view.isEnabled()) {
            int actionMasked = motionEvent.getActionMasked();
            if (actionMasked != 0) {
                if (actionMasked != 1) {
                    if (actionMasked == 2) {
                        int findPointerIndex = motionEvent.findPointerIndex(this.PGPF6hQ_2);
                        if (findPointerIndex >= 0 && !KQgRr5e_0(view, motionEvent.getX(findPointerIndex), motionEvent.getY(findPointerIndex), this.KQgRr5e_0)) {
                            m409KQgRr5e_0();
                            view.getParent().requestDisallowInterceptTouchEvent(true);
                            return true;
                        }
                    }
                }
                m409KQgRr5e_0();
            } else {
                this.PGPF6hQ_2 = motionEvent.getPointerId(0);
                if (this.f725KQgRr5e_0 == null) {
                    this.f725KQgRr5e_0 = new KQgRr5e_0();
                }
                view.postDelayed(this.f725KQgRr5e_0, this.f723KQgRr5e_0);
                if (this.f727QxJ9d_1 == null) {
                    this.f727QxJ9d_1 = new QxJ9d_1();
                }
                view.postDelayed(this.f727QxJ9d_1, this.QxJ9d_1);
            }
            return false;
        }
        return false;
    }

    public final boolean KQgRr5e_0(MotionEvent motionEvent) {
        LGe8pk_15 lGe8pk_15;
        View view = this.f724KQgRr5e_0;
        X6FRs_4.KQgRr5e_0.YghfZG_14.XnFJ5_9.Eps4cJe_18 KQgRr5e_02 = KQgRr5e_0();
        if (KQgRr5e_02 == null || !KQgRr5e_02.m473KQgRr5e_0() || (lGe8pk_15 = (LGe8pk_15) KQgRr5e_02.KQgRr5e_0()) == null || !lGe8pk_15.isShown()) {
            return false;
        }
        MotionEvent obtainNoHistory = MotionEvent.obtainNoHistory(motionEvent);
        KQgRr5e_0(view, obtainNoHistory);
        QxJ9d_1(lGe8pk_15, obtainNoHistory);
        boolean KQgRr5e_03 = lGe8pk_15.KQgRr5e_0(obtainNoHistory, this.PGPF6hQ_2);
        obtainNoHistory.recycle();
        int actionMasked = motionEvent.getActionMasked();
        return KQgRr5e_03 && (actionMasked != 1 && actionMasked != 3);
    }

    public static boolean KQgRr5e_0(View view, float f, float f2, float f3) {
        float f4 = -f3;
        return f >= f4 && f2 >= f4 && f < ((float) (view.getRight() - view.getLeft())) + f3 && f2 < ((float) (view.getBottom() - view.getTop())) + f3;
    }

    public final boolean KQgRr5e_0(View view, MotionEvent motionEvent) {
        int[] iArr = this.f726KQgRr5e_0;
        view.getLocationOnScreen(iArr);
        motionEvent.offsetLocation(iArr[0], iArr[1]);
        return true;
    }

    public void QxJ9d_1() {
        m409KQgRr5e_0();
        View view = this.f724KQgRr5e_0;
        if (view.isEnabled() && !view.isLongClickable() && m410KQgRr5e_0()) {
            view.getParent().requestDisallowInterceptTouchEvent(true);
            long uptimeMillis = SystemClock.uptimeMillis();
            MotionEvent obtain = MotionEvent.obtain(uptimeMillis, uptimeMillis, 3, 0.0f, 0.0f, 0);
            view.onTouchEvent(obtain);
            obtain.recycle();
            this.f728QxJ9d_1 = true;
        }
    }

    public final boolean QxJ9d_1(View view, MotionEvent motionEvent) {
        int[] iArr = this.f726KQgRr5e_0;
        view.getLocationOnScreen(iArr);
        motionEvent.offsetLocation(-iArr[0], -iArr[1]);
        return true;
    }
}
