package com.bytedance.sdk.component.adexpress.dynamic.tN.YFl;

import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import java.lang.ref.SoftReference;
/* loaded from: classes2.dex */
public class DSW implements View.OnTouchListener {
    private static int tN = 10;
    private com.bytedance.sdk.component.adexpress.dynamic.tN.qsH AlY;
    private float Sg;
    private float YFl;
    private int wN;
    private RectF vc = new RectF();
    private long DSW = 0;
    private final int qsH = 200;
    private final int NjR = 3;
    private SoftReference<View> nc = new SoftReference<>(null);

    public DSW(com.bytedance.sdk.component.adexpress.dynamic.tN.qsH qsh, int i, final ViewGroup viewGroup) {
        this.wN = tN;
        this.AlY = qsh;
        if (i > 0) {
            this.wN = i;
        }
        if (viewGroup != null) {
            viewGroup.post(new Runnable() { // from class: com.bytedance.sdk.component.adexpress.dynamic.tN.YFl.DSW.1
                @Override // java.lang.Runnable
                public void run() {
                    View findViewById = viewGroup.findViewById(2097610746);
                    DSW.this.nc = new SoftReference(findViewById);
                }
            });
        }
    }

    private RectF YFl(View view) {
        if (view == null) {
            return new RectF();
        }
        int[] iArr = new int[2];
        view.getLocationOnScreen(iArr);
        int i = iArr[0];
        return new RectF(i, iArr[1], i + view.getWidth(), iArr[1] + view.getHeight());
    }

    @Override // android.view.View.OnTouchListener
    public boolean onTouch(View view, MotionEvent motionEvent) {
        com.bytedance.sdk.component.adexpress.dynamic.tN.qsH qsh;
        com.bytedance.sdk.component.adexpress.dynamic.tN.qsH qsh2;
        int action = motionEvent.getAction();
        if (action == 0) {
            this.vc = YFl(this.nc.get());
            this.YFl = motionEvent.getRawX();
            this.Sg = motionEvent.getRawY();
            this.DSW = System.currentTimeMillis();
        } else if (action == 1) {
            RectF rectF = this.vc;
            if (rectF != null && !rectF.contains(this.YFl, this.Sg)) {
                return false;
            }
            float rawX = motionEvent.getRawX();
            float rawY = motionEvent.getRawY();
            float abs = Math.abs(rawX - this.YFl);
            float abs2 = Math.abs(rawY - this.Sg);
            int Sg = com.bytedance.sdk.component.adexpress.AlY.qsH.Sg(com.bytedance.sdk.component.adexpress.AlY.YFl(), Math.abs(rawX - this.YFl));
            int i = tN;
            if (abs < i || abs2 < i) {
                if ((System.currentTimeMillis() - this.DSW < 200 || (abs < 3.0f && abs2 < 3.0f)) && (qsh = this.AlY) != null) {
                    qsh.YFl();
                }
            } else if (rawX > this.YFl && Sg > this.wN && (qsh2 = this.AlY) != null) {
                qsh2.YFl();
            }
        }
        return true;
    }
}
