package n;

import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewConfiguration;

/* JADX INFO: loaded from: classes.dex */
public final class D0 extends TouchDelegate {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final View f14685a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Rect f14686b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Rect f14687c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Rect f14688d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final int f14689e;

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

    public D0(Rect rect, Rect rect2, View view) {
        super(rect, view);
        int scaledTouchSlop = ViewConfiguration.get(view.getContext()).getScaledTouchSlop();
        this.f14689e = scaledTouchSlop;
        Rect rect3 = new Rect();
        this.f14686b = rect3;
        Rect rect4 = new Rect();
        this.f14688d = rect4;
        Rect rect5 = new Rect();
        this.f14687c = rect5;
        rect3.set(rect);
        rect4.set(rect);
        int i = -scaledTouchSlop;
        rect4.inset(i, i);
        rect5.set(rect2);
        this.f14685a = view;
    }

    @Override // android.view.TouchDelegate
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        boolean z8;
        boolean z9;
        int x8 = (int) motionEvent.getX();
        int y8 = (int) motionEvent.getY();
        int action = motionEvent.getAction();
        boolean z10 = true;
        if (action != 0) {
            if (action == 1 || action == 2) {
                z9 = this.f14690f;
                if (z9 && !this.f14688d.contains(x8, y8)) {
                    z10 = z9;
                    z8 = false;
                }
            } else {
                if (action == 3) {
                    z9 = this.f14690f;
                    this.f14690f = false;
                }
                z8 = true;
                z10 = false;
            }
            z10 = z9;
            z8 = true;
        } else if (this.f14686b.contains(x8, y8)) {
            this.f14690f = true;
            z8 = true;
        } else {
            z8 = true;
            z10 = false;
        }
        if (!z10) {
            return false;
        }
        Rect rect = this.f14687c;
        View view = this.f14685a;
        if (!z8 || rect.contains(x8, y8)) {
            motionEvent.setLocation(x8 - rect.left, y8 - rect.top);
        } else {
            motionEvent.setLocation(view.getWidth() / 2, view.getHeight() / 2);
        }
        return view.dispatchTouchEvent(motionEvent);
    }
}
