package com.bytedance.android.livesdk.adminsetting;

import X.0AP;
import X.0CH;
import X.0cm;
import X.0dK;
import X.28K;
import X.2FV;
import X.2He;
import X.7AW;
import X.7s1;
import X.7vl;
import X.8jA;
import X.C0979Ftk;
import X.C0984Ftp;
import X.C0989Ftu;
import X.C0990Ftv;
import X.C0991Ftw;
import X.C0997Fu2;
import X.C0998Fu3;
import X.C0999Fu4;
import X.C1000Fu5;
import X.C1001Fu6;
import X.C1003Fu8;
import X.C1004Fu9;
import X.C1005FuA;
import X.C1011FuG;
import X.C1044Fun;
import X.C1056Fuz;
import X.C2478Gcp;
import X.Crj;
import X.GSF;
import X.LnI;
import X.M12;
import android.app.Dialog;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import androidx.fragment.app.Fragment;
import com.bytedance.android.live.moderator.IModeratorService;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.android.livesdk.moderator.ModeratorPermissionEditFragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.lang.reflect.Field;
import java.util.HashMap;
import kotlin.h.b.n;

public final class LiveAdminSettingDialog extends LiveDialogFragment {
    public static final C1005FuA LIZ = new C1005FuA((byte) 0);
    public final Crj LIZIZ = 7vl.LIZ(C1001Fu6.LIZ);
    public final Crj LIZJ = 7vl.LIZ(C1003Fu8.LIZ);
    public final Crj LIZLLL = 7vl.LIZ(C0979Ftk.LIZ);
    public final Crj LJ = 7vl.LIZ(C0984Ftp.LIZ);
    public final Crj LJFF = 7vl.LIZ(C0999Fu4.LIZ);
    public final Crj LJI = 7vl.LIZ(C1004Fu9.LIZ);
    public final Crj LJII = 7vl.LIZ(new C0997Fu2(this));
    public final Crj LJIIIIZZ = 7vl.LIZ(new C1011FuG(this));
    public HashMap LJIIIZ;

    static {
        Covode.recordClassIndex(11308);
    }

    private final LiveAdminSettingGuideFragment LIZLLL() {
        return (LiveAdminSettingGuideFragment) this.LIZIZ.getValue();
    }

    private final LiveManageListFragment LJ() {
        return (LiveManageListFragment) this.LIZJ.getValue();
    }

    private final LiveCommentSettingFragment LJFF() {
        return (LiveCommentSettingFragment) this.LIZLLL.getValue();
    }

    private final LiveCommentBlockKeywordsFragment LJI() {
        return (LiveCommentBlockKeywordsFragment) this.LJ.getValue();
    }

    private final Fragment LJII() {
        return (Fragment) this.LJFF.getValue();
    }

    private final LiveRankingsSettingFragment LJIIJJI() {
        return (LiveRankingsSettingFragment) this.LJI.getValue();
    }

    private final boolean LJIIL() {
        return ((Boolean) this.LJII.getValue()).booleanValue();
    }

    private final Fragment LJIILIIL() {
        return (Fragment) this.LJIIIIZZ.getValue();
    }

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

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

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

    public final void dismiss() {
        Object obj;
        DataChannel LIZ2 = GSF.LIZ((Fragment) this);
        if (LIZ2 != null) {
            LIZ2.LIZJ(C2478Gcp.class);
        }
        Context context = getContext();
        IBinder iBinder = null;
        if (context != null) {
            obj = LIZ(context, "input_method");
        } else {
            obj = null;
        }
        if (!(obj instanceof InputMethodManager)) {
            obj = null;
        }
        InputMethodManager inputMethodManager = (InputMethodManager) obj;
        if (inputMethodManager != null) {
            View view = getView();
            if (view != null) {
                iBinder = view.getWindowToken();
            }
            inputMethodManager.hideSoftInputFromWindow(iBinder, 0);
        }
        super.dismiss();
    }

    public final C1044Fun LIZ() {
        int i;
        int i2;
        int LIZ2;
        if (LJIIL()) {
            i = 2131887251;
        } else {
            i = 2131887252;
        }
        boolean LJIIL = LJIIL();
        if (LJIIL) {
            i2 = 80;
        } else if (!LJIIL) {
            i2 = 5;
        } else {
            throw new 7AW();
        }
        boolean LJIIL2 = LJIIL();
        int i3 = -1;
        if (LJIIL2) {
            LIZ2 = -1;
        } else if (!LJIIL2) {
            Resources system = Resources.getSystem();
            n.LIZIZ(system, "");
            LIZ2 = LnI.LIZ(TypedValue.applyDimension(1, 490.0f, system.getDisplayMetrics()));
        } else {
            throw new 7AW();
        }
        boolean LJIIL3 = LJIIL();
        if (LJIIL3) {
            i3 = -2;
        } else if (LJIIL3) {
            throw new 7AW();
        }
        C1044Fun fun = new C1044Fun(2131561627);
        fun.LIZ = 0;
        fun.LIZIZ = i;
        fun.LJIIJJI = 18;
        fun.LJI = i2;
        fun.LJII = LIZ2;
        fun.LJIIIIZZ = i3;
        return fun;
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        DataChannel dataChannel = this.LJIILIIL;
        if (dataChannel != null) {
            dataChannel.LIZ((0CH) this, 28K.class, new C0998Fu3(this));
        }
    }

    public final Fragment LIZ(C0989Ftu ftu) {
        switch (C0990Ftv.LIZ[ftu.ordinal()]) {
            case 1:
                return LIZLLL();
            case 2:
                return LJII();
            case 3:
                return LJFF();
            case 4:
                return LJI();
            case 5:
                return LJIIJJI();
            case 6:
                return 0cm.LIZ(IModeratorService.class).getAddModeratorFragment();
            case 7:
                LiveManageListFragment LJ2 = LJ();
                LJ2.LIZ();
                return LJ2;
            case 8:
                LiveManageListFragment LJ3 = LJ();
                LJ3.LIZIZ();
                return LJ3;
            case 9:
                return LJIILIIL();
            case 10:
                return new ModeratorPermissionEditFragment();
            case 11:
                dismiss();
                return null;
            default:
                return null;
        }
    }

    public static Object LIZ(Bundle bundle, String str) {
        try {
            return bundle.get(str);
        } catch (Exception | OutOfMemoryError unused) {
            return null;
        }
    }

    public static Object LIZ(Context context, String str) {
        Object obj;
        MethodCollector.i(8930);
        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(8930);
                    throw th;
                }
                2FV.LIZ = false;
            }
        } else {
            obj = context.getSystemService(str);
        }
        MethodCollector.o(8930);
        return obj;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        Object obj;
        Window window;
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        LIZ(2131367585).setWindowInsetsEnable(true);
        LIZ(2131370149).setOnClickListener(new C1000Fu5(this));
        Bundle arguments = getArguments();
        if (arguments == null || (obj = LIZ(arguments, "argument_initial_page")) == null) {
            obj = C0989Ftu.GUIDE;
        }
        if (!(obj instanceof C0989Ftu)) {
            obj = null;
        }
        C0989Ftu ftu = (C0989Ftu) obj;
        if (ftu != null) {
            0AP LIZ2 = getChildFragmentManager().LIZ();
            Fragment LIZ3 = LIZ(ftu);
            if (LIZ3 != null) {
                LIZ2.LIZ(2131362176, LIZ3);
                LIZ2.LIZIZ();
                DataChannel dataChannel = this.LJIILIIL;
                if (dataChannel != null) {
                    dataChannel.LIZ((0CH) this, C1056Fuz.class, new C0991Ftw(this));
                }
                Dialog dialog = getDialog();
                if (dialog != null && (window = dialog.getWindow()) != null) {
                    0dK.LIZ(window);
                    window.addFlags(Integer.MIN_VALUE);
                    n.LIZIZ(window, "");
                    window.setStatusBarColor(0);
                    window.setNavigationBarColor(-1);
                }
            }
        }
    }
}
