package com.ss.android.ugc.aweme.account.unbind;

import X.0Gf;
import X.0Gp;
import X.2k8;
import X.2k9;
import X.3af;
import X.7he;
import X.9DY;
import X.C1575RkJ;
import X.C1790Rnm;
import X.C2133RtJ;
import X.C2196RuK;
import X.C2202RuQ;
import X.C2244Rv6;
import X.C2364Rx2;
import X.C2366Rx4;
import X.C2380RxI;
import X.C2383RxL;
import X.C2386RxO;
import X.C2397RxZ;
import X.C2398Rxa;
import X.C2469Ryj;
import X.Crj;
import X.KEP;
import X.Ltt;
import X.M12;
import X.OJq;
import X.Qeg;
import android.os.Bundle;
import android.text.SpannableString;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.account.login.v2.base.BaseAccountFlowFragment;
import com.ss.android.ugc.aweme.account.login.v2.ui.fragments.InputCodeFragmentV2;
import com.ss.android.ugc.aweme.profile.model.User;
import java.util.HashMap;
import java.util.Map;
import kotlin.h.b.n;
import kotlin.o.z;

public final class UnbindInputCodeFragment extends InputCodeFragmentV2 {
    public final Crj LIZ = 7he.LIZ(new C2380RxI(this));
    public HashMap LIZIZ;

    static {
        Covode.recordClassIndex(52228);
    }

    private String LJIIJJI() {
        return (String) this.LIZ.getValue();
    }

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

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

    public final String ax_() {
        return "UnbindInputCodeFragment";
    }

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

    public final C2196RuK LJII() {
        C2196RuK ruK = new C2196RuK();
        ruK.LIZ(LJIIJJI());
        ruK.LIZIZ = C2364Rx2.LIZ.LIZIZ(this);
        ruK.LIZLLL = C2133RtJ.LIZ.LIZLLL(this);
        return ruK;
    }

    public final C2202RuQ LIZLLL() {
        int i;
        C2202RuQ ruQ = new C2202RuQ((String) null, (String) null, false, (String) null, (String) null, false, (String) null, false, false, 2047);
        ruQ.LJ = getString(2131834509);
        if (C2364Rx2.LIZ.LIZ(this)) {
            i = 2131834508;
        } else {
            i = 2131834488;
        }
        ruQ.LJFF = getString(i, new Object[]{LJIIJJI()});
        ruQ.LIZ = " ";
        ruQ.LJIIIZ = false;
        return ruQ;
    }

    public final void LJIIIZ() {
        if (C2364Rx2.LIZ.LIZIZ(this)) {
            C2364Rx2.LIZ.LIZ(this, "resend", new C2397RxZ(this));
        } else {
            C2364Rx2.LIZ.LIZIZ(this, "resend", new C2398Rxa(this));
        }
    }

    private Bundle LIZ(boolean z) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("unbind_success", z);
        bundle.putInt("unbind_type", LJJI().getValue());
        return bundle;
    }

    public final void LIZJ(String str) {
        M12.LIZ(str);
        IUnbindApi iUnbindApi = KEP.LIZ;
        String LIZ2 = C1575RkJ.LIZ(9DY.LJ + "/passport/email/unbind/");
        n.LIZIZ(LIZ2, "");
        iUnbindApi.unbindEmail(str, LIZ2).LIZ(new C2386RxO(this), 0Gp.LIZIZ, (0Gf) null);
    }

    public final void LIZ(0Gp<2k8> r5) {
        if (!OJq.LIZ(r5) || ((2k8) r5.LIZLLL()).LIZIZ == null) {
            new 3af(this).LJ(2131825407);
            return;
        }
        2k9 r0 = ((2k8) r5.LIZLLL()).LIZIZ;
        if (r0 == null) {
            n.LIZIZ();
        }
        if (r0.LIZ == 0) {
            User LJFF = C2469Ryj.LJFF();
            if (C2364Rx2.LIZ.LIZ(this)) {
                n.LIZIZ(LJFF, "");
                LJFF.setPhoneBinded(false);
                LJFF.setBindPhone("");
            } else {
                n.LIZIZ(LJFF, "");
                LJFF.setHasEmail(false);
                LJFF.setEmail("");
                LJFF.setEmailVerified(false);
            }
            LIZIZ(LIZ(true));
            return;
        }
        LIZIZ(LIZ(false));
    }

    public final void LIZ(String str) {
        M12.LIZ(str);
        if (C2364Rx2.LIZ.LIZIZ(this)) {
            M12.LIZ(str);
            C1790Rnm.LIZ.LIZ((BaseAccountFlowFragment) this, str, 22, (Map<String, String>) null).LIZLLL(new C2366Rx4(this)).LIZLLL();
            return;
        }
        M12.LIZ(str);
        C1790Rnm.LIZ.LIZIZ(this, str, 6, (Map<String, String>) null).LIZLLL(new C2244Rv6(this)).LIZLLL();
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        if (!C2364Rx2.LIZ.LIZIZ(this) && !C2364Rx2.LIZ.LIZJ(this)) {
            Qeg LIZ2 = LIZ(2131363236);
            LIZ2.setVisibility(0);
            LIZ2.setTuxFont(41);
            LIZ2.setOnClickListener(new C2383RxL(this));
            String string = getString(2131834590);
            n.LIZIZ(string, "");
            String string2 = getString(2131822335, new Object[]{string});
            n.LIZIZ(string2, "");
            SpannableString spannableString = new SpannableString(string2);
            int LIZ3 = z.LIZ(string2, string, 0, false, 6);
            spannableString.setSpan(new Ltt(43, true), LIZ3, string.length() + LIZ3, 33);
            LIZ2.setText(spannableString);
        }
    }
}
