package com.ss.android.ugc.aweme.account.login.v2.ui.fragments;

import X.1I0;
import X.1hK;
import X.2cN;
import X.2dS;
import X.2nK;
import X.4vZ;
import X.7Xg;
import X.7he;
import X.9A4;
import X.C1790Rnm;
import X.C2012RrM;
import X.C2045Rrt;
import X.C2046Rru;
import X.C2094Rsg;
import X.C2133RtJ;
import X.C2160Rtk;
import X.C2162Rtm;
import X.C2180Ru4;
import X.C2202RuQ;
import X.C2247Rv9;
import X.C2361Rwz;
import X.C2362Rx0;
import X.C2368Rx6;
import X.C2379RxH;
import X.C2390RxS;
import X.C2391RxT;
import X.C2393RxV;
import X.C2401Rxd;
import X.C2415Rxr;
import X.C2416Rxs;
import X.C2671S4t;
import X.Crj;
import X.JLi;
import X.JtF;
import X.M12;
import X.S91;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
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.timer.TimerHolder;
import com.ss.android.ugc.aweme.account.login.v2.ui.AccountKeyBoardHelper;
import java.util.HashMap;
import kotlin.h.b.n;

public final class PhoneSignUpFragment extends BaseI18nLoginFragment implements 1I0 {
    public static final C2012RrM LIZLLL = new C2012RrM((byte) 0);
    public C2415Rxr LIZ;
    public long LIZIZ = System.currentTimeMillis();
    public 2cN LIZJ;
    public boolean LJIIL;
    public final Crj LJIILIIL = 7he.LIZ(new C2401Rxd(this));
    public HashMap LJIILJJIL;

    static {
        Covode.recordClassIndex(51912);
    }

    private final 9A4 LJIIIZ() {
        return (9A4) this.LJIILIIL.getValue();
    }

    public final int LIZ() {
        return 2131558764;
    }

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

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

    public final String az_() {
        return "PhoneEmailSignUpStep";
    }

    public final void LJFF() {
        ((C2671S4t) LIZ(2131368476)).LIZIZ(true);
    }

    public final void LJI() {
        C2671S4t s4t = (C2671S4t) LIZ(2131368476);
        if (s4t != null) {
            s4t.LIZ(true);
        }
    }

    public final void onDestroyView() {
        super.onDestroyView();
        2cN r0 = this.LIZJ;
        if (r0 != null) {
            r0.dispose();
        }
        LJIIJ();
    }

    public final void onStop() {
        PhoneSignUpFragment.super.onStop();
        LJIIIZ().LIZIZ();
    }

    public final C2202RuQ LIZLLL() {
        return new C2202RuQ((String) null, (String) null, false, (String) null, (String) null, false, (String) null, false, true, 1023);
    }

    public final void onStart() {
        PhoneSignUpFragment.super.onStart();
        if (AccountKeyBoardHelper.LIZLLL.LIZ()) {
            C2094Rsg.LIZ(((C2361Rwz) LIZ(2131368479)).getInputView().getEditText());
        } else {
            ((C2361Rwz) LIZ(2131368479)).getInputView().getEditText().requestFocus();
        }
    }

    public final void LJII() {
        String string;
        String string2;
        if (!2dS.LIZ(((C2361Rwz) LIZ(2131368479)).getCountryCodeString())) {
            LIZ(false, false);
        } else if (getActivity() != null) {
            String countryCodeString = ((C2361Rwz) LIZ(2131368479)).getCountryCodeString();
            boolean LIZIZ2 = 2dS.LIZIZ(countryCodeString);
            if (2dS.LIZIZ(countryCodeString)) {
                string = getString(2131832107);
                n.LIZIZ(string, "");
                string2 = getString(2131832106);
                n.LIZIZ(string2, "");
            } else {
                string = getString(2131832106);
                n.LIZIZ(string, "");
                string2 = getString(2131832107);
                n.LIZIZ(string2, "");
            }
            String fullPhoneNumber = ((C2361Rwz) LIZ(2131368479)).getFullPhoneNumber();
            1hK activity = getActivity();
            if (activity == null) {
                n.LIZIZ();
            }
            n.LIZIZ(activity, "");
            String string3 = getString(2131832108);
            n.LIZIZ(string3, "");
            String string4 = getString(2131832105, new Object[]{fullPhoneNumber});
            n.LIZIZ(string4, "");
            String LJIJJLI = LJIJJLI();
            n.LIZIZ(LJIJJLI, "");
            C2415Rxr rxr = new C2415Rxr(activity, new C2416Rxs(string3, string4, string, string2, LJIJJLI, fullPhoneNumber));
            this.LIZ = rxr;
            rxr.LIZ = new C2393RxV(this);
            C2415Rxr rxr2 = this.LIZ;
            if (rxr2 == null) {
                n.LIZIZ();
            }
            rxr2.LIZIZ = new C2390RxS(this, LIZIZ2);
            C2415Rxr rxr3 = this.LIZ;
            if (rxr3 == null) {
                n.LIZIZ();
            }
            rxr3.LIZJ = new C2391RxT(this, LIZIZ2);
            4vZ.LIZ(this.LIZ);
        }
    }

    public final void onCreate(Bundle bundle) {
        PhoneSignUpFragment.super.onCreate(bundle);
        LJIIIZ().LIZ();
    }

    public final void LIZ(boolean z) {
        String str;
        if (z) {
            str = "phone_verification_click_whatsapp";
        } else {
            str = "phone_verification_click_sms";
        }
        JtF jtF = new JtF();
        jtF.LIZ("enter_type", LJIJJLI());
        2nK.LIZ(str, jtF.LIZ);
    }

    public final void LIZ(int i, String str) {
        M12.LIZ(str);
        JLi LIZ2 = LIZ(2131368478);
        if (LIZ2 != null) {
            LIZ2.LIZ(str);
        }
    }

    public final void LIZIZ(boolean z, boolean z2) {
        C2133RtJ.LIZ.LIZ((Fragment) this, ((C2361Rwz) LIZ(2131368479)).getPhoneNumberObject());
        Bundle arguments = getArguments();
        if (arguments == null) {
            arguments = new Bundle();
        }
        arguments.putInt("next_page", C2162Rtm.PHONE_SMS_SIGN_UP.getValue());
        arguments.putInt("current_scene", C2160Rtk.SIGN_UP.getValue());
        arguments.putBoolean("code_sent", z2);
        arguments.putBoolean("use_whatsapp", z);
        n.LIZIZ(arguments, "");
        LIZ(arguments);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        ((C2361Rwz) LIZ(2131368479)).getInputView().setTextWatcher(new C2379RxH(this));
        S91.LIZ(getContext(), (TextView) LIZ(2131368477), 1);
        ((C2361Rwz) LIZ(2131368479)).LIZ();
        if (!this.LJIIL) {
            LJIIIZ().LIZ(((C2361Rwz) LIZ(2131368479)).getEditText());
            this.LJIIL = true;
        }
        if (7Xg.LIZIZ.LIZJ()) {
            String string = getString(2131827155);
            n.LIZIZ(string, "");
            ((C2671S4t) LIZ(2131368476)).setButtonText(string);
        }
        LIZ(LIZ(2131368476), new C2362Rx0(this));
    }

    public final void LIZ(boolean z, boolean z2) {
        String str;
        C2180Ru4 ru4;
        C2247Rv9 LIZ2 = TimerHolder.LIZIZ.LIZ(getActivity(), ((C2361Rwz) LIZ(2131368479)).getFullPhoneNumber(), C2160Rtk.SIGN_UP);
        if (LIZ2 != null && (ru4 = LIZ2.LIZ) != null && ru4.LIZLLL()) {
            LIZIZ(z, false);
        } else if (z) {
            String LIZ3 = C2368Rx6.LIZ(((C2361Rwz) LIZ(2131368479)).getPhoneNumberObject());
            n.LIZIZ(LIZ3, "");
            C1790Rnm.LIZ.LIZ((BaseAccountFlowFragment) this, LIZ3, C2160Rtk.SIGN_UP, C2162Rtm.PHONE_SMS_SIGN_UP, "user_click", "").LIZLLL(new C2045Rrt(this)).LIZLLL();
        } else {
            C1790Rnm rnm = C1790Rnm.LIZ;
            String LIZ4 = C2368Rx6.LIZ(((C2361Rwz) LIZ(2131368479)).getPhoneNumberObject());
            n.LIZIZ(LIZ4, "");
            C2160Rtk rtk = C2160Rtk.SIGN_UP;
            C2162Rtm rtm = C2162Rtm.PHONE_SMS_SIGN_UP;
            if (z2) {
                str = "choose_dialog";
            } else {
                str = null;
            }
            C1790Rnm.LIZ(rnm, this, LIZ4, rtk, rtm, "", "user_click", str, 128).LIZLLL(new C2046Rru(this)).LIZLLL();
        }
    }

    public final void onActivityResult(int i, int i2, Intent intent) {
        PhoneSignUpFragment.super.onActivityResult(i, i2, intent);
        LJIIIZ().LIZ(i, i2, intent);
    }
}
