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

import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.View;
import com.bytedance.sdk.openadsdk.utils.zan;

/* JADX INFO: loaded from: classes2.dex */
public class gqi {
    private int ajl;
    private final fm fm;
    private float jnr;
    private boolean ku;
    private int wsy;
    private float yz;
    private final boolean ro = false;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private boolean f7345lb = false;
    private boolean wu = true;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private boolean f7344ef = false;
    private final View.OnTouchListener vt = new View.OnTouchListener() { // from class: com.bytedance.sdk.openadsdk.core.widget.gqi.1
        @Override // android.view.View.OnTouchListener
        @SuppressLint({"ClickableViewAccessibility"})
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (gqi.this.fm.lse()) {
                return !gqi.this.f7345lb;
            }
            float x10 = motionEvent.getX();
            float y10 = motionEvent.getY();
            int action = motionEvent.getAction();
            if (action == 0) {
                gqi gqiVar = gqi.this;
                gqiVar.ku = gqiVar.fm(motionEvent);
                gqi.this.yz = x10;
                gqi.this.jnr = y10;
                gqi.this.ajl = (int) x10;
                gqi.this.wsy = (int) y10;
                gqi.this.wu = true;
                if (gqi.this.fm != null && gqi.this.f7345lb) {
                    gqi.this.fm.fm(view, true);
                }
            } else if (action == 1) {
                if (Math.abs(x10 - gqi.this.ajl) > 20.0f || Math.abs(y10 - gqi.this.wsy) > 20.0f) {
                    gqi.this.wu = false;
                }
                gqi.this.wu = true;
                gqi.this.f7344ef = false;
                gqi.this.yz = 0.0f;
                gqi.this.jnr = 0.0f;
                gqi.this.ajl = 0;
                if (gqi.this.fm != null) {
                    gqi.this.fm.fm(view, gqi.this.wu);
                }
                gqi.this.ku = false;
            } else if (action == 3) {
                gqi.this.ku = false;
            }
            return !gqi.this.f7345lb;
        }
    };

    public interface fm {
        void fm(View view, boolean z10);

        boolean lse();
    }

    public gqi(fm fmVar) {
        this.fm = fmVar;
    }

    public void fm(boolean z10) {
        this.f7345lb = z10;
    }

    public void fm(View view) {
        if (view != null) {
            view.setOnTouchListener(this.vt);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public boolean fm(MotionEvent motionEvent) {
        if (motionEvent.getActionMasked() != 0) {
            return false;
        }
        int iLb = zan.lb(com.bytedance.sdk.openadsdk.core.gof.fm().getApplicationContext());
        int iJnr = zan.jnr(com.bytedance.sdk.openadsdk.core.gof.fm().getApplicationContext());
        float rawX = motionEvent.getRawX();
        float rawY = motionEvent.getRawY();
        float f10 = iLb;
        if (rawX <= f10 * 0.01f || rawX >= f10 * 0.99f) {
            return true;
        }
        float f11 = iJnr;
        return rawY <= 0.01f * f11 || rawY >= f11 * 0.99f;
    }
}
