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 YFl 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<ViewGroup> nc = new SoftReference<>(null);

    public YFl(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.YFl.1
                @Override // java.lang.Runnable
                public void run() {
                    YFl.this.nc = new SoftReference(viewGroup);
                }
            });
        }
    }

    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;
        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 i = this.wN;
            if (abs >= i && abs2 >= i) {
                com.bytedance.sdk.component.adexpress.dynamic.tN.qsH qsh2 = this.AlY;
                if (qsh2 != null) {
                    qsh2.YFl();
                }
            } else if ((System.currentTimeMillis() - this.DSW < 200 || (abs < 3.0f && abs2 < 3.0f)) && (qsh = this.AlY) != null) {
                qsh.YFl();
            }
        }
        return true;
    }
}
