package com.bytedance.android.livesdk.dislike;

import X.2FV;
import X.2He;
import X.2Pr;
import X.7s1;
import X.8jA;
import X.C1044Fun;
import X.C2314GaB;
import X.C2315GaC;
import X.C2330GaR;
import X.C2675Gg0;
import X.C3491GtA;
import X.GZG;
import X.LsC;
import X.M12;
import android.app.Dialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Vibrator;
import android.view.View;
import android.widget.LinearLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.android.livesdk.callback.IHostLongPressCallback;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.h.b.n;

public final class LiveLongPressDialog extends LiveDialogFragment implements DialogInterface {
    public boolean LIZ;
    public IHostLongPressCallback LIZIZ;
    public Room LIZJ;
    public String LIZLLL;
    public String LJ;
    public String LJFF;
    public String LJI;
    public final LsC<View, 2Pr> LJII = new C2314GaB(this);
    public HashMap LJIIIIZZ;

    static {
        Covode.recordClassIndex(15821);
    }

    public final View LIZ(int i) {
        if (this.LJIIIIZZ == null) {
            this.LJIIIIZZ = new HashMap();
        }
        View view = (View) this.LJIIIIZZ.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIIIZZ.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        z_();
    }

    public final void z_() {
        HashMap hashMap = this.LJIIIIZZ;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final void cancel() {
        Dialog dialog = getDialog();
        if (dialog != null) {
            dialog.cancel();
        }
    }

    public final C1044Fun LIZ() {
        C1044Fun fun = new C1044Fun(2131561631);
        fun.LIZIZ = 2131887280;
        fun.LJI = 17;
        fun.LJIIIIZZ = -1;
        return fun;
    }

    public final void onDestroy() {
        LiveLongPressDialog.super.onDestroy();
        GZG gzg = new GZG();
        gzg.LIZ = true;
        C2675Gg0.LIZ().LIZ((Object) gzg);
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Context context = getContext();
        if (context != null) {
            try {
                Object LIZ2 = LIZ(context, "vibrator");
                if (LIZ2 != null) {
                    ((Vibrator) LIZ2).vibrate(15);
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type android.os.Vibrator");
                }
            } catch (Exception unused) {
            }
        }
        Room room = this.LIZJ;
        if (room != null) {
            C2330GaR gaR = C2330GaR.LIZ;
            String str = this.LIZLLL;
            String str2 = "";
            if (str == null) {
                str = str2;
            }
            String str3 = this.LJ;
            if (str3 != null) {
                str2 = str3;
            }
            M12.LIZ(room, str, str2);
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            gaR.LIZ(linkedHashMap, room, str, str2, "long_press");
            C3491GtA LIZ3 = C3491GtA.LJFF.LIZ("live_report_icon_show");
            LIZ3.LIZ("request_page", "long_press");
            LIZ3.LIZ("report_type", "long_press");
            LIZ3.LIZ("show_type", "long_press");
            LIZ3.LIZ();
            LIZ3.LIZ((Map<String, String>) linkedHashMap);
            LIZ3.LIZLLL();
        }
        GZG gzg = new GZG();
        gzg.LIZ = false;
        C2675Gg0.LIZ().LIZ((Object) gzg);
    }

    public static Object LIZ(Context context, String str) {
        Object obj;
        MethodCollector.i(13780);
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!2FV.LIZIZ && "connectivity".equals(str)) {
                try {
                    new 7s1().LIZ();
                    2FV.LIZIZ = true;
                    obj = context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            obj = context.getSystemService(str);
        } else if (2FV.LIZ) {
            synchronized (ClipboardManager.class) {
                try {
                    obj = context.getSystemService(str);
                    if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
                        Field declaredField = ClipboardManager.class.getDeclaredField("mHandler");
                        declaredField.setAccessible(true);
                        declaredField.set(obj, new 2He((Handler) declaredField.get(obj)));
                    }
                } catch (Exception e) {
                    8jA.LIZ(e, "ClipboardManager Handler Reflect Fail");
                } catch (Throwable th) {
                    MethodCollector.o(13780);
                    throw th;
                }
                2FV.LIZ = false;
            }
        } else {
            obj = context.getSystemService(str);
        }
        MethodCollector.o(13780);
        return obj;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        LinearLayout linearLayout = (LinearLayout) LIZ(2131368068);
        LsC<View, 2Pr> lsC = this.LJII;
        if (lsC != null) {
            lsC = new C2315GaC(lsC);
        }
        linearLayout.setOnClickListener((View.OnClickListener) lsC);
        ConstraintLayout LIZ2 = LIZ(2131364127);
        LsC<View, 2Pr> lsC2 = this.LJII;
        if (lsC2 != null) {
            lsC2 = new C2315GaC(lsC2);
        }
        LIZ2.setOnClickListener((View.OnClickListener) lsC2);
        LinearLayout linearLayout2 = (LinearLayout) LIZ(2131369497);
        LsC<View, 2Pr> lsC3 = this.LJII;
        if (lsC3 != null) {
            lsC3 = new C2315GaC(lsC3);
        }
        linearLayout2.setOnClickListener((View.OnClickListener) lsC3);
        if (this.LIZ) {
            LinearLayout linearLayout3 = (LinearLayout) LIZ(2131368068);
            n.LIZIZ(linearLayout3, "");
            linearLayout3.setVisibility(8);
        }
    }
}
