package com.ss.android.ugc.aweme.profile.ui;

import X.0HH;
import X.1hK;
import X.2cN;
import X.2uR;
import X.3c7;
import X.3c9;
import X.3cC;
import X.3cI;
import X.4Dd;
import X.4ZZ;
import X.C1079Mjy;
import X.C1083Mk2;
import X.C1084Mk3;
import X.C5321OQy;
import X.C5322OQz;
import X.DMD;
import X.DME;
import X.DRB;
import X.ElZ;
import X.FO8;
import X.JJh;
import X.LsC;
import X.M12;
import X.OPB;
import X.PhE;
import X.Pkb;
import X.PlI;
import android.app.Dialog;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.utils.KeyboardUtils;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;

public final class ProfileEditContentFragment extends ProfileEditInputFragment {
    public static final FO8 LJIILL = new FO8((byte) 0);
    public String LIZ = "";
    public boolean LIZIZ;
    public String LIZJ = "";
    public int LIZLLL;
    public boolean LJFF;
    public boolean LJI = true;
    public LsC<? super Editable, Boolean> LJII;
    public Pkb<Object> LJIIIIZZ;
    public String LJIIIZ;
    public String LJIIJ;
    public TextView LJIIJJI;
    public EditText LJIIL;
    public 4ZZ LJIILIIL;
    public TextView LJIILJJIL;
    public String LJIJI = "";
    public C1079Mjy LJIJJ;
    public DRB LJIJJLI;
    public SparseArray LJIL;

    static {
        Covode.recordClassIndex(99071);
    }

    public static final ProfileEditContentFragment LIZ(String str, String str2, String str3, int i, boolean z, Bundle bundle) {
        return LJIILL.LIZ(str, str2, str3, i, z, bundle);
    }

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

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

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

    public final EditText LIZ() {
        EditText editText = this.LJIIL;
        if (editText == null) {
            n.LIZ("");
        }
        return editText;
    }

    public final 4ZZ LIZJ() {
        4ZZ r1 = this.LJIILIIL;
        if (r1 == null) {
            n.LIZ("");
        }
        return r1;
    }

    public final TextView LIZLLL() {
        TextView textView = this.LJIILJJIL;
        if (textView == null) {
            n.LIZ("");
        }
        return textView;
    }

    public final void onDestroy() {
        ProfileEditContentFragment.super.onDestroy();
        this.LJIJJ.LIZ();
    }

    public final void LJ() {
        DRB drb = this.LJIJJLI;
        if (drb != null) {
            EditText editText = this.LJIIL;
            if (editText == null) {
                n.LIZ("");
            }
            drb.LIZ(editText.getText().toString());
        }
    }

    public ProfileEditContentFragment() {
        Pkb<Object> pkb = new Pkb<>();
        n.LIZIZ(pkb, "");
        this.LJIIIIZZ = pkb;
        this.LJIJJ = new C1079Mjy();
        this.LJIIIZ = "";
        this.LJIIJ = "";
    }

    public final boolean dn_() {
        Dialog dialog;
        EditText editText = this.LJIIL;
        if (editText == null) {
            n.LIZ("");
        }
        KeyboardUtils.LIZJ(editText);
        if (getDialog() != null && (dialog = getDialog()) != null && dialog.isShowing() && isResumed()) {
            try {
                dismiss();
            } catch (Exception e) {
                0HH.LIZ(e);
            }
        }
        return true;
    }

    public final void LIZ(DRB drb) {
        M12.LIZ(drb);
        this.LJIJJLI = drb;
    }

    public final boolean LIZ(Editable editable) {
        LsC<? super Editable, Boolean> lsC = this.LJII;
        if (lsC == null || ((Boolean) lsC.invoke(editable)).booleanValue()) {
            return true;
        }
        return false;
    }

    public final void onCreate(Bundle bundle) {
        String str;
        ProfileEditContentFragment.super.onCreate(bundle);
        if (getArguments() != null) {
            Bundle arguments = getArguments();
            if (arguments == null) {
                n.LIZIZ();
            }
            String string = arguments.getString("content_name");
            if (string == null) {
                n.LIZIZ();
            }
            this.LJIJI = string;
            Bundle arguments2 = getArguments();
            if (arguments2 == null) {
                n.LIZIZ();
            }
            String string2 = arguments2.getString("content_value");
            if (string2 == null) {
                n.LIZIZ();
            }
            this.LIZ = string2;
            Bundle arguments3 = getArguments();
            if (arguments3 == null) {
                n.LIZIZ();
            }
            this.LIZIZ = arguments3.getBoolean("is_edit_enabled");
            Bundle arguments4 = getArguments();
            if (arguments4 == null) {
                n.LIZIZ();
            }
            String string3 = arguments4.getString("edit_hint");
            if (string3 == null) {
                n.LIZIZ();
            }
            this.LIZJ = string3;
            Bundle arguments5 = getArguments();
            if (arguments5 == null) {
                n.LIZIZ();
            }
            this.LIZLLL = arguments5.getInt("content_max_length");
            Bundle arguments6 = getArguments();
            if (arguments6 == null) {
                n.LIZIZ();
            }
            this.LJFF = arguments6.getBoolean("is_enable_null");
            Bundle arguments7 = getArguments();
            String str2 = null;
            if (arguments7 != null) {
                str = arguments7.getString("enter_method");
            } else {
                str = null;
            }
            this.LJIIIZ = str;
            Bundle arguments8 = getArguments();
            if (arguments8 != null) {
                str2 = arguments8.getString("btn_name");
            }
            this.LJIIJ = str2;
        }
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        Window window;
        M12.LIZ(layoutInflater);
        View LIZ2 = 0HH.LIZ(layoutInflater, 2131560795, viewGroup, false);
        JJh jJh = JJh.LIZ;
        1hK activity = getActivity();
        Dialog dialog = getDialog();
        if (dialog != null) {
            window = dialog.getWindow();
        } else {
            window = null;
        }
        jJh.LIZ(activity, window, true);
        View findViewById = LIZ2.findViewById(2131371877);
        n.LIZIZ(findViewById, "");
        this.LJIIJJI = (TextView) findViewById;
        View findViewById2 = LIZ2.findViewById(2131364628);
        n.LIZIZ(findViewById2, "");
        this.LJIIL = (EditText) findViewById2;
        4ZZ findViewById3 = LIZ2.findViewById(2131366351);
        n.LIZIZ(findViewById3, "");
        this.LJIILIIL = findViewById3;
        View findViewById4 = LIZ2.findViewById(2131371951);
        n.LIZIZ(findViewById4, "");
        LIZ((TextView) findViewById4);
        View findViewById5 = LIZ2.findViewById(2131371949);
        n.LIZIZ(findViewById5, "");
        this.LJIILJJIL = (TextView) findViewById5;
        View findViewById6 = LIZ2.findViewById(2131366351);
        if (findViewById6 != null) {
            findViewById6.setOnClickListener(new C5322OQz(this));
        }
        TextView textView = this.LJIIJJI;
        if (textView == null) {
            n.LIZ("");
        }
        textView.setText(this.LJIJI);
        4ZZ r1 = this.LJIILIIL;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.setIconRes(2131755737);
        2cN LIZ3 = this.LJIIIIZZ.LJI(3000, TimeUnit.MILLISECONDS).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(C1083Mk2.LIZ(C1084Mk3.LIZ)).LIZ(new DMD(LIZ2), DME.LIZ);
        n.LIZIZ(LIZ3, "");
        4Dd.LIZ(LIZ3, this.LJIJJ);
        EditText editText = this.LJIIL;
        if (editText == null) {
            n.LIZ("");
        }
        editText.addTextChangedListener(new C5321OQy(this));
        EditText editText2 = this.LJIIL;
        if (editText2 == null) {
            n.LIZ("");
        }
        editText2.setText(this.LIZ);
        EditText editText3 = this.LJIIL;
        if (editText3 == null) {
            n.LIZ("");
        }
        EditText editText4 = this.LJIIL;
        if (editText4 == null) {
            n.LIZ("");
        }
        editText3.setSelection(editText4.getText().length());
        EditText editText5 = this.LJIIL;
        if (editText5 == null) {
            n.LIZ("");
        }
        editText5.setFocusable(true);
        EditText editText6 = this.LJIIL;
        if (editText6 == null) {
            n.LIZ("");
        }
        editText6.setFocusableInTouchMode(true);
        EditText editText7 = this.LJIIL;
        if (editText7 == null) {
            n.LIZ("");
        }
        editText7.requestFocus();
        this.LJIILLIIL = LIZ2.findViewById(2131367895);
        3cI LJIIIZ2 = LJIIIZ();
        3cC LIZIZ2 = LIZIZ(this.LJIJI);
        3cI r6 = new 3c9();
        r6.LIZ("save");
        String string = getString(2131824457);
        n.LIZIZ(string, "");
        r6.LIZ(string);
        r6.LIZ(new OPB(this));
        3c7 r5 = this.LJIILLIIL;
        if (r5 != null) {
            2uR r12 = new 2uR();
            r12.LIZ(new 3cI[]{LJIIIZ2});
            r12.LIZ(LIZIZ2);
            r12.LIZIZ(new 3cI[]{r6});
            r12.LIZLLL = true;
            r5.setNavActions(r12);
        }
        if (!this.LIZIZ) {
            EditText editText8 = this.LJIIL;
            if (editText8 == null) {
                n.LIZ("");
            }
            editText8.setEnabled(false);
            EditText editText9 = this.LJIIL;
            if (editText9 == null) {
                n.LIZ("");
            }
            editText9.setFocusable(false);
            EditText editText10 = this.LJIIL;
            if (editText10 == null) {
                n.LIZ("");
            }
            editText10.setFocusableInTouchMode(false);
            4ZZ r0 = this.LJIILIIL;
            if (r0 == null) {
                n.LIZ("");
            }
            r0.setVisibility(8);
        }
        LJIIIIZZ();
        if (!this.LJI || TextUtils.isEmpty(this.LIZJ)) {
            TextView textView2 = this.LJIILJJIL;
            if (textView2 == null) {
                n.LIZ("");
            }
            textView2.setVisibility(8);
        } else {
            TextView textView3 = this.LJIILJJIL;
            if (textView3 == null) {
                n.LIZ("");
            }
            textView3.setVisibility(0);
            TextView textView4 = this.LJIILJJIL;
            if (textView4 == null) {
                n.LIZ("");
            }
            textView4.setText(this.LIZJ);
        }
        if (this.LIZLLL > 0) {
            LJI().setVisibility(0);
        }
        EditText editText11 = this.LJIIL;
        if (editText11 == null) {
            n.LIZ("");
        }
        editText11.setOnEditorActionListener(ElZ.LIZ);
        return LIZ2;
    }
}
