package com.bytedance.sdk.component.ef;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View;
import com.bytedance.sdk.component.utils.wey;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes.dex */
public class yz extends lb {
    private View.OnTouchListener ajl;

    /* JADX INFO: renamed from: ef, reason: collision with root package name */
    private float f6613ef;
    private final View.OnTouchListener fm;
    private final wsy jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final long f6614lb;
    private final int ro;
    private String vt;
    private long wsy = -1;
    private float wu;
    private final Context yz;

    public yz(Context context, View.OnTouchListener onTouchListener, int i10, long j10, wsy wsyVar) {
        this.yz = context;
        this.fm = onTouchListener;
        this.ro = i10;
        this.f6614lb = j10;
        this.jnr = wsyVar;
    }

    @Override // com.bytedance.sdk.component.ef.lb
    public void fm(View.OnTouchListener onTouchListener) {
        this.ajl = onTouchListener;
    }

    @Override // android.view.View.OnTouchListener
    @SuppressLint({"ClickableViewAccessibility"})
    public boolean onTouch(View view, MotionEvent motionEvent) {
        int action = motionEvent.getAction();
        motionEvent.getX();
        motionEvent.getY();
        float x10 = motionEvent.getX();
        float y10 = motionEvent.getY();
        if (action == 0) {
            this.wu = x10;
            this.f6613ef = y10;
        } else if (action == 1 && fm(x10, y10, this.wu, this.f6613ef, this.yz)) {
            if (fm(SystemClock.elapsedRealtime())) {
                motionEvent.setAction(3);
                fm(1, x10, y10);
            } else {
                fm(0, x10, y10);
            }
        }
        View.OnTouchListener onTouchListener = this.fm;
        if (onTouchListener != null) {
            onTouchListener.onTouch(view, motionEvent);
        }
        View.OnTouchListener onTouchListener2 = this.ajl;
        if (onTouchListener2 != null) {
            onTouchListener2.onTouch(view, motionEvent);
        }
        return false;
    }

    public void fm(String str) {
        this.vt = str;
    }

    private boolean fm(long j10) {
        long j11 = this.wsy;
        if (j11 == -1) {
            this.wsy = j10;
            return false;
        }
        int i10 = this.ro;
        if (i10 == 1) {
            if (j10 - j11 <= this.f6614lb) {
                return true;
            }
            this.wsy = j10;
            return false;
        }
        if (i10 == 2) {
            if (j10 - j11 <= this.f6614lb) {
                this.wsy = j10;
                return true;
            }
            this.wsy = j10;
        }
        return false;
    }

    private void fm(int i10, float f10, float f11) {
        JSONObject jSONObject = new JSONObject();
        JSONObject jSONObject2 = new JSONObject();
        try {
            jSONObject2.put("is_interceptor", i10);
            jSONObject2.put("click_x", f10);
            jSONObject2.put("click_y", f11);
            jSONObject.put("lp_click_type", this.ro);
            jSONObject.put("lp_click_interval", this.f6614lb);
        } catch (Throwable th) {
            wey.fm("LpClickIntervalTouchListener", "sendLpClickInterceptEvent", th);
        }
        if (com.bytedance.sdk.component.ef.fm.fm.fm().ro() != null) {
            com.bytedance.sdk.component.ef.fm.ro roVarRo = com.bytedance.sdk.component.ef.fm.fm.fm().ro();
            wsy wsyVar = this.jnr;
            roVarRo.fm(wsyVar != null ? wsyVar.getMaterialMeta() : null, this.vt, "click_interval_intercept", jSONObject, jSONObject2);
        }
    }
}
