package com.tencent.mm.plugin.account.ui;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.f;
import com.tencent.mm.ai.m;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.account.friend.a.r;
import com.tencent.mm.plugin.account.friend.a.r.b;
import com.tencent.mm.plugin.account.friend.a.z;
import com.tencent.mm.plugin.b.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.base.MMAutoSwitchEditTextView;
import com.tencent.mm.ui.base.h;

public class EmailVerifyUI extends MMActivity implements f {
    private ProgressDialog ehJ = null;
    private TextView gAF;
    private TextView gAG;
    private MMAutoSwitchEditTextView gAH;
    private Button gAI;
    private Button gAJ;
    private String gAK;
    private String gAL;
    private String gAM;
    private String gAN;
    private boolean gAO = false;
    private String gsF;

    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        AppMethodBeat.at(this, z);
    }

    static /* synthetic */ void d(EmailVerifyUI emailVerifyUI) {
        AppMethodBeat.i(124774);
        emailVerifyUI.goBack();
        AppMethodBeat.o(124774);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(124766);
        super.onCreate(bundle);
        initView();
        this.gsF = a.arO();
        AppMethodBeat.o(124766);
    }

    public void onResume() {
        AppMethodBeat.i(124767);
        super.onResume();
        g.Rg().a(481, this);
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",R500_200,");
        g.RN();
        a.f(true, stringBuilder.append(com.tencent.mm.kernel.a.lF("R500_200")).append(",1").toString());
        a.wz("R500_200");
        AppMethodBeat.o(124767);
    }

    public void onPause() {
        AppMethodBeat.i(124768);
        super.onPause();
        g.Rg().b(481, this);
        StringBuilder stringBuilder = new StringBuilder();
        g.RN();
        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",R500_200,");
        g.RN();
        a.f(false, stringBuilder.append(com.tencent.mm.kernel.a.lF("R500_200")).append(",2").toString());
        AppMethodBeat.o(124768);
    }

    public final int getLayoutId() {
        return 2130970985;
    }

    public final void initView() {
        AppMethodBeat.i(124769);
        setMMTitle(2131302248);
        this.gAF = (TextView) findViewById(2131828394);
        this.gAF.setText(Html.fromHtml(getString(2131302231)));
        this.gAG = (TextView) findViewById(2131828395);
        this.gAK = getIntent().getStringExtra("email_address");
        if (bo.isNullOrNil(this.gAK)) {
            ab.w("MicroMsg.EmailVerifyUI", "email add is null or nill");
        } else {
            this.gAG.setText(this.gAK);
        }
        this.gAM = getIntent().getStringExtra("password");
        this.gAL = getIntent().getStringExtra("email_login_page");
        ab.i("MicroMsg.EmailVerifyUI", "user register:email add:[%s], password not allowed to printf, login page:[%s]", new Object[]{this.gAK, this.gAL});
        this.gAH = (MMAutoSwitchEditTextView) findViewById(2131828396);
        this.gAH.setOnInputFinished(new 1(this));
        this.gAH.setOnTextChanged(new 2(this));
        this.gAJ = (Button) findViewById(2131828398);
        this.gAJ.setOnClickListener(new 3(this));
        this.gAI = (Button) findViewById(2131828397);
        if (bo.isNullOrNil(this.gAL) || bo.isNullOrNil(this.gAK)) {
            this.gAI.setVisibility(8);
        } else {
            this.gAI.setVisibility(0);
            this.gAI.setOnClickListener(new 4(this));
        }
        setBackBtn(new 5(this));
        addTextOptionMenu(0, getString(2131296989), new 6(this));
        enableOptionMenu(false);
        AppMethodBeat.o(124769);
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        AppMethodBeat.i(124770);
        if (i == 4 && keyEvent.getRepeatCount() == 0) {
            goBack();
            AppMethodBeat.o(124770);
            return true;
        }
        boolean onKeyDown = super.onKeyDown(i, keyEvent);
        AppMethodBeat.o(124770);
        return onKeyDown;
    }

    private void goBack() {
        AppMethodBeat.i(124771);
        a.wA(this.gsF);
        finish();
        AppMethodBeat.o(124771);
    }

    public void onSceneEnd(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(124772);
        ab.i("MicroMsg.EmailVerifyUI", "onSceneEnd: errType = " + i + " errCode = " + i2 + " errMsg = " + str);
        this.gAO = false;
        if (this.ehJ != null && this.ehJ.isShowing()) {
            this.ehJ.dismiss();
            this.ehJ = null;
        }
        if (mVar.getType() != 481) {
            ab.e("MicroMsg.EmailVerifyUI", "error cgi type callback:[%d]", new Object[]{Integer.valueOf(mVar.getType())});
            AppMethodBeat.o(124772);
            return;
        }
        int i3 = ((r.a) ((z) mVar).ftU.acF()).gvF.vIJ;
        StringBuilder stringBuilder;
        if (i != 0 || i2 != 0) {
            int i4;
            if (!com.tencent.mm.plugin.account.a.a.gkF.a(this, i, i2, str)) {
                switch (i2) {
                    case -34:
                        Toast.makeText(this, 2131302227, 0).show();
                        i4 = 1;
                        break;
                    case -33:
                        h.a(this, 2131302228, 2131302229, null);
                        i4 = 1;
                        break;
                    case -32:
                        h.a(this, 2131302230, 2131302229, null);
                        stringBuilder = new StringBuilder();
                        g.RN();
                        stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",R500_260,");
                        g.RN();
                        a.wB(stringBuilder.append(com.tencent.mm.kernel.a.lF("R500_260")).append(",3").toString());
                        i4 = 1;
                        break;
                    default:
                        boolean i42 = false;
                        break;
                }
            }
            i42 = 1;
            if (i42 != 0) {
                AppMethodBeat.o(124772);
            } else if (i3 == 2) {
                Toast.makeText(this, getString(2131302249, new Object[]{Integer.valueOf(i), Integer.valueOf(i2)}), 0).show();
                AppMethodBeat.o(124772);
            } else {
                if (i3 == 1) {
                    Toast.makeText(this, getString(2131302240, new Object[]{Integer.valueOf(i), Integer.valueOf(i2)}), 0).show();
                }
                AppMethodBeat.o(124772);
            }
        } else if (i3 == 2) {
            a.wA("R200_900_email");
            Intent intent = new Intent(this, RegSetInfoUI.class);
            intent.putExtra("regsetinfo_ticket", ((b) ((z) mVar).ftU.ZS()).gvG.wdB);
            intent.putExtra("regsetinfo_user", this.gAK);
            intent.putExtra("regsetinfo_ismobile", 3);
            intent.putExtra("regsetinfo_NextStyle", ((z) mVar).ajx());
            intent.putExtra("regsetinfo_pwd", this.gAM);
            intent.putExtra("regsetinfo_bind_email", this.gAK);
            startActivity(intent);
            AppMethodBeat.o(124772);
        } else if (i3 == 1) {
            stringBuilder = new StringBuilder();
            g.RN();
            stringBuilder = stringBuilder.append(com.tencent.mm.kernel.a.Rb()).append(",").append(getClass().getName()).append(",R22_resend_email_code_alert,");
            g.RN();
            a.wB(stringBuilder.append(com.tencent.mm.kernel.a.lF("R22_resend_email_code_alert")).append(",3").toString());
            h.bQ(this, getString(2131302241));
            AppMethodBeat.o(124772);
        } else {
            ab.e("MicroMsg.EmailVerifyUI", "err opcode");
            AppMethodBeat.o(124772);
        }
    }
}
