package com.bytedance.sdk.openadsdk.core.lb;

import android.graphics.Point;
import android.util.SparseArray;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.sdk.openadsdk.api.reward.BackupConstant;
import com.bytedance.sdk.openadsdk.core.gof;

/* JADX INFO: loaded from: classes2.dex */
public abstract class lb implements View.OnClickListener, View.OnTouchListener {
    protected static int ai = 8;
    protected View wbw;
    protected float wey = -1.0f;
    protected float sds = -1.0f;
    protected float maa = -1.0f;
    protected float lse = -1.0f;
    protected long hlt = -1;
    protected long hi = -1;
    protected int nt = -1;
    protected int mq = BackupConstant.UNFINISHED_FAIL_CODE;
    protected int gzf = -1;
    protected boolean ol = true;

    /* JADX INFO: renamed from: ha, reason: collision with root package name */
    public SparseArray<fm> f7149ha = new SparseArray<>();
    private float fm = 0.0f;
    private float ro = 0.0f;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private float f7150lb = 0.0f;
    private float yz = 0.0f;
    private long jnr = 0;
    private int ajl = 0;
    private int wsy = 0;

    public static class fm {
        public int fm;

        /* JADX INFO: renamed from: lb, reason: collision with root package name */
        public double f7151lb;
        public double ro;
        public long yz;

        public fm(int i10, double d10, double d11, long j10) {
            this.fm = i10;
            this.ro = d10;
            this.f7151lb = d11;
            this.yz = j10;
        }
    }

    static {
        if (gof.fm() != null) {
            ai = gof.ro();
        }
    }

    private boolean fm(View view, Point point) {
        int i10;
        int i11;
        int i12;
        int i13;
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            for (int i14 = 0; i14 < viewGroup.getChildCount(); i14++) {
                View childAt = viewGroup.getChildAt(i14);
                if (ro.lb(childAt)) {
                    int[] iArr = new int[2];
                    childAt.getLocationOnScreen(iArr);
                    return view.isShown() && (i10 = point.x) >= (i11 = iArr[0]) && i10 <= childAt.getWidth() + i11 && (i12 = point.y) >= (i13 = iArr[1]) && i12 <= childAt.getHeight() + i13;
                }
                if (fm(childAt, point)) {
                    return true;
                }
            }
        }
        return false;
    }

    public boolean ajl() {
        return this.ol;
    }

    public abstract void fm(View view, float f10, float f11, float f12, float f13, SparseArray<fm> sparseArray, boolean z10);

    @Override // android.view.View.OnClickListener
    public void onClick(View view) {
        if (com.bytedance.sdk.openadsdk.core.settings.wsy.fm()) {
            fm(view, this.wey, this.sds, this.maa, this.lse, this.f7149ha, this.ol);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0072  */
    @Override // android.view.View.OnTouchListener
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public boolean onTouch(View view, MotionEvent motionEvent) {
        this.mq = motionEvent.getDeviceId();
        this.nt = motionEvent.getToolType(0);
        this.gzf = motionEvent.getSource();
        int actionMasked = motionEvent.getActionMasked();
        int i10 = 1;
        if (actionMasked != 0) {
            int i11 = 3;
            if (actionMasked == 1) {
                this.maa = motionEvent.getRawX();
                this.lse = motionEvent.getRawY();
                this.hi = System.currentTimeMillis();
                if (Math.abs(this.maa - this.ajl) >= ai || Math.abs(this.lse - this.wsy) >= ai) {
                    this.ol = false;
                }
                Point point = new Point((int) this.maa, (int) this.lse);
                if (view != null && !ro.lb(view) && fm((View) view.getParent(), point)) {
                    return true;
                }
            } else if (actionMasked != 2) {
                i11 = actionMasked != 3 ? -1 : 4;
            } else {
                this.f7150lb = Math.abs(motionEvent.getX() - this.fm) + this.f7150lb;
                this.yz = Math.abs(motionEvent.getY() - this.ro) + this.yz;
                this.fm = motionEvent.getX();
                this.ro = motionEvent.getY();
                if (System.currentTimeMillis() - this.jnr > 200) {
                    float f10 = this.f7150lb;
                    int i12 = ai;
                    if (f10 <= i12 && this.yz <= i12) {
                        i10 = 2;
                    }
                    this.maa = motionEvent.getRawX();
                    this.lse = motionEvent.getRawY();
                    if (Math.abs(this.maa - this.ajl) >= ai || Math.abs(this.lse - this.wsy) >= ai) {
                        this.ol = false;
                    }
                }
            }
            i10 = i11;
        } else {
            this.ajl = (int) motionEvent.getRawX();
            this.wsy = (int) motionEvent.getRawY();
            this.wey = motionEvent.getRawX();
            this.sds = motionEvent.getRawY();
            this.hlt = System.currentTimeMillis();
            this.nt = motionEvent.getToolType(0);
            this.mq = motionEvent.getDeviceId();
            this.gzf = motionEvent.getSource();
            this.f7150lb = 0.0f;
            this.yz = 0.0f;
            this.jnr = System.currentTimeMillis();
            this.ol = true;
            this.wbw = view;
            com.bytedance.sdk.openadsdk.core.duv.lb.fm(motionEvent);
            this.fm = motionEvent.getX();
            this.ro = motionEvent.getY();
            i10 = 0;
        }
        this.f7149ha.put(motionEvent.getActionMasked(), new fm(i10, motionEvent.getSize(), motionEvent.getPressure(), System.currentTimeMillis()));
        return false;
    }
}
