package com.bytedance.adsdk.ugeno.core.ro;

import android.os.Handler;
import android.os.Looper;
import android.view.MotionEvent;
import android.view.View;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/* JADX INFO: loaded from: classes.dex */
public class fm {
    public String fm = "GesThrough_";
    private List<MotionEvent> ro = new ArrayList();

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private Set<String> f6318lb = Collections.synchronizedSet(new HashSet());

    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar, MotionEvent motionEvent) {
        if (lbVar == null || motionEvent == null || this.ro == null) {
            return;
        }
        fm(lbVar.ku(), lbVar.pkk(), motionEvent);
    }

    public void fm(View view, String str, MotionEvent motionEvent) {
        if (view == null || motionEvent == null || this.ro == null) {
            return;
        }
        this.fm = "GesThrough_".concat(String.valueOf(str));
        int[] iArr = new int[2];
        view.getLocationInWindow(iArr);
        int i10 = iArr[0];
        int i11 = iArr[1];
        if (motionEvent.getAction() == 0) {
            fm();
        }
        MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
        motionEventObtain.offsetLocation(i10, i11);
        this.ro.add(motionEventObtain);
    }

    public boolean fm(MotionEvent motionEvent) {
        if (motionEvent == null || this.f6318lb == null) {
            return false;
        }
        int pointerId = motionEvent.getPointerId(motionEvent.getActionIndex());
        return this.f6318lb.contains(motionEvent.getDownTime() + "_" + pointerId);
    }

    public void fm(com.bytedance.adsdk.ugeno.ro.lb lbVar) {
        if (this.ro.isEmpty() || this.f6318lb == null || lbVar == null || lbVar.ku() == null || lbVar.ku().getRootView() == null) {
            return;
        }
        fm(lbVar.ku());
    }

    public void fm(View view) {
        if (this.ro.isEmpty() || this.f6318lb == null || view == null || view.getRootView() == null) {
            return;
        }
        final View rootView = view.getRootView();
        this.ro.size();
        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { // from class: com.bytedance.adsdk.ugeno.core.ro.fm.1
            @Override // java.lang.Runnable
            public void run() {
                for (MotionEvent motionEvent : fm.this.ro) {
                    if (motionEvent != null) {
                        int pointerId = motionEvent.getPointerId(motionEvent.getActionIndex());
                        fm.this.f6318lb.add(motionEvent.getDownTime() + "_" + pointerId);
                        rootView.dispatchTouchEvent(motionEvent);
                        motionEvent.recycle();
                    }
                }
                fm.this.fm();
            }
        }, 300L);
    }

    public void fm() {
        List<MotionEvent> list = this.ro;
        if (list != null) {
            list.clear();
        }
    }
}
