package com.ss.android.ugc.aweme.compliance.business.filtervideo.ui.fragment;

import X.0HH;
import X.7he;
import X.7s1;
import X.8jA;
import X.AnonymousClass2FV;
import X.AnonymousClass3D0;
import X.C00802He;
import X.C03012Pr;
import X.C07562fU;
import X.C09512id;
import X.C09612in;
import X.C09682iu;
import X.C09692iv;
import X.C09702iw;
import X.C09752j1;
import X.C16292tZ;
import X.C16632u7;
import X.C16712uF;
import X.C16722uG;
import X.C16732uH;
import X.C16742uI;
import X.C16752uJ;
import X.C16762uK;
import X.C16782uM;
import X.C16812uP;
import X.C16822uQ;
import X.C16832uR;
import X.C17742vu;
import X.C23293Bp;
import X.C30953c7;
import X.C30973c9;
import X.C31003cC;
import X.C31063cI;
import X.Crj;
import X.Lpk;
import X.Ls2;
import X.LsC;
import X.M12;
import X.Qeg;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.text.InputFilter;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.CompoundButton;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.foundation.fragment.BaseFragment;
import com.bytedance.ies.foundation.fragment.BaseFragmentViewModel;
import com.ss.android.ugc.aweme.compliance.business.filtervideo.viewmodel.FilterVideoKeywordsViewModel;
import java.lang.reflect.Field;
import java.util.Objects;
import kotlin.h.b.n;

public final class AddOrModifyKeywordFragment extends BaseFragment {
    public final Crj LJ = 7he.LIZ(new C09752j1(this));
    public final Crj LJFF = 7he.LIZ(new C16822uQ(this));
    public final Crj LJI = 7he.LIZ(new C16812uP(this));
    public final Crj LJII = 7he.LIZ(new C16632u7(this));
    public SparseArray LJIIIIZZ;

    static {
        Covode.recordClassIndex(60880);
    }

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

    public final FilterVideoKeywordsViewModel LIZ() {
        return (FilterVideoKeywordsViewModel) this.LJ.getValue();
    }

    public final AnonymousClass3D0 LIZIZ() {
        return (AnonymousClass3D0) this.LJFF.getValue();
    }

    public final AnonymousClass3D0 LIZJ() {
        return (AnonymousClass3D0) this.LJI.getValue();
    }

    public final C23293Bp LIZLLL() {
        return (C23293Bp) this.LJII.getValue();
    }

    public final void LJI() {
        SparseArray sparseArray = this.LJIIIIZZ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

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

    public final void onDestroy() {
        LIZ().LIZIZ = null;
        super.onDestroy();
    }

    public final void LJII() {
        if ((LIZIZ().LJI() || LIZJ().LJI()) && LIZ(2131366038).length() > 0) {
            ((C30953c7) LIZ(2131371242)).LIZ((Object) "save", (LsC<? super C31063cI, C03012Pr>) C16722uG.LIZ);
        } else {
            ((C30953c7) LIZ(2131371242)).LIZ((Object) "save", (LsC<? super C31063cI, C03012Pr>) C16732uH.LIZ);
        }
    }

    public final void LJIIIIZZ() {
        Object obj;
        Context context = getContext();
        IBinder iBinder = null;
        if (context != null) {
            obj = LIZ(context, "input_method");
        } else {
            obj = null;
        }
        Objects.requireNonNull(obj, "null cannot be cast to non-null type android.view.inputmethod.InputMethodManager");
        InputMethodManager inputMethodManager = (InputMethodManager) obj;
        ConstraintLayout LIZ = LIZ(2131363673);
        if (LIZ != null) {
            iBinder = LIZ.getWindowToken();
        }
        inputMethodManager.hideSoftInputFromWindow(iBinder, 0);
    }

    private final void LJIIIZ() {
        C09512id r3 = LIZ().LIZIZ;
        if (r3 != null) {
            Qeg LIZ = LIZ(2131363988);
            n.LIZIZ(LIZ, "");
            LIZ.setVisibility(0);
            LIZ(2131363988).setOnClickListener(new C16292tZ(r3, this));
            LIZ(2131366038).setText(r3.LIZ);
            for (Integer intValue : r3.LIZIZ) {
                int intValue2 = intValue.intValue();
                if (intValue2 == 0) {
                    LIZIZ().LIZJ(true);
                } else if (intValue2 == 1) {
                    LIZJ().LIZJ(true);
                }
            }
        }
    }

    public static void LIZ(C23293Bp r1) {
        r1.show();
        C07562fU.LIZ.LIZ(r1);
    }

    public final void onCreate(Bundle bundle) {
        LIZ((LsC<? super BaseFragmentViewModel, C03012Pr>) C16712uF.LIZ);
        super.onCreate(bundle);
    }

    public static Object LIZ(Context context, String str) {
        Object obj;
        MethodCollector.i(1169);
        if (Build.VERSION.SDK_INT > 27 || !"clipboard".equals(str)) {
            if (!AnonymousClass2FV.LIZIZ && "connectivity".equals(str)) {
                try {
                    new 7s1().LIZ();
                    AnonymousClass2FV.LIZIZ = true;
                    obj = context.getSystemService(str);
                } catch (Throwable unused) {
                }
            }
            obj = context.getSystemService(str);
        } else if (AnonymousClass2FV.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 C00802He((Handler) declaredField.get(obj)));
                    }
                } catch (Exception e) {
                    8jA.LIZ(e, "ClipboardManager Handler Reflect Fail");
                } catch (Throwable th) {
                    MethodCollector.o(1169);
                    throw th;
                }
                AnonymousClass2FV.LIZ = false;
            }
        } else {
            obj = context.getSystemService(str);
        }
        MethodCollector.o(1169);
        return obj;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        C16832uR r4 = new C16832uR();
        C30973c9 r1 = new C30973c9();
        String string = getString(2131822315);
        n.LIZIZ(string, "");
        r1.LIZ(string);
        r1.LIZJ = true;
        r1.LIZ((Ls2<C03012Pr>) new C09682iu(this));
        r1.LIZ(C17742vu.SECONDARY);
        r4.LIZ(r1);
        C31003cC r12 = new C31003cC();
        String string2 = getString(2131826432);
        n.LIZIZ(string2, "");
        r12.LIZ(string2);
        r4.LIZ(r12);
        C30973c9 r13 = new C30973c9();
        String string3 = getString(2131831880);
        n.LIZIZ(string3, "");
        r13.LIZ(string3);
        r13.LIZ((Object) "save");
        r13.LIZJ = false;
        r13.LIZ((Ls2<C03012Pr>) new C09612in(this));
        r4.LIZIZ(r13);
        ((C30953c7) LIZ(2131371242)).setNavActions(r4);
        ((C30953c7) LIZ(2131371242)).LIZ(true);
        LIZIZ().LIZ((CompoundButton.OnCheckedChangeListener) new C16752uJ(this));
        LIZJ().LIZ((CompoundButton.OnCheckedChangeListener) new C16762uK(this));
        Qeg LIZ = LIZ(2131363249);
        n.LIZIZ(LIZ, "");
        LIZ.setText("0/70");
        Lpk LIZ2 = LIZ(2131366038);
        n.LIZIZ(LIZ2, "");
        LIZ2.setFilters(new InputFilter.LengthFilter[]{new InputFilter.LengthFilter(70)});
        LIZ(2131366038).addTextChangedListener(new C16782uM(this));
        LIZ(2131366038).setOnEditorActionListener(C16742uI.LIZ);
        LIZ(2131366038).setOnFocusChangeListener(new C09692iv(this));
        LIZ(2131363673).setOnTouchListener(new C09702iw(this));
        LJIIIZ();
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131559415, viewGroup, false);
    }
}
