package com.tencent.mm.plugin.wallet.pwd.ui;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Looper;
import android.os.Parcelable;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.view.ViewStub;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.m;
import com.tencent.mm.plugin.wallet.a.s;
import com.tencent.mm.plugin.wallet_core.c.t;
import com.tencent.mm.plugin.wallet_core.c.y;
import com.tencent.mm.plugin.wallet_core.model.Bankcard;
import com.tencent.mm.plugin.wallet_core.model.ElementQuery;
import com.tencent.mm.plugin.wallet_core.model.aj;
import com.tencent.mm.plugin.wallet_core.model.r;
import com.tencent.mm.plugin.wallet_core.ui.WalletConfirmCardIDUI;
import com.tencent.mm.plugin.wallet_core.ui.j;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ak;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.base.a;
import com.tencent.mm.ui.base.h;
import com.tencent.mm.wallet_core.ui.WalletBaseUI;
import com.tencent.mm.wallet_core.ui.e;
import com.tencent.mm.wallet_core.ui.formview.WalletFormView;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

@a(3)
public class WalletForgotPwdUI extends WalletBaseUI implements WalletFormView.a {
    private LinearLayout eol;
    private Button gEZ;
    private ListView gKd;
    private ArrayList<Bankcard> tlM = new ArrayList();
    c tmk = new 8(this);
    private WalletFormView trA;
    private WalletFormView trB;
    private int trC = 1;
    private boolean trD = false;
    private boolean trE = false;
    c trF = new 7(this);
    private List<ElementQuery> trx = new LinkedList();
    /* renamed from: try */
    private Bankcard f1try;
    private a trz;

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

    public WalletForgotPwdUI() {
        AppMethodBeat.i(46289);
        AppMethodBeat.o(46289);
    }

    static /* synthetic */ void a(WalletForgotPwdUI walletForgotPwdUI) {
        AppMethodBeat.i(46303);
        walletForgotPwdUI.ari();
        AppMethodBeat.o(46303);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(46290);
        super.onCreate(bundle);
        setMMTitle(2131305138);
        this.trE = this.mBundle.getBoolean("key_is_force_bind", false);
        if (!this.trE) {
            a(new y(null, 6), true, true);
            AM(4);
        }
        initView();
        com.tencent.mm.sdk.b.a.xxA.c(this.trF);
        com.tencent.mm.sdk.b.a.xxA.c(this.tmk);
        AppMethodBeat.o(46290);
    }

    public void onDestroy() {
        AppMethodBeat.i(46291);
        com.tencent.mm.sdk.b.a.xxA.d(this.trF);
        com.tencent.mm.sdk.b.a.xxA.d(this.tmk);
        super.onDestroy();
        AppMethodBeat.o(46291);
    }

    public void onResume() {
        AppMethodBeat.i(46292);
        super.onResume();
        update();
        AppMethodBeat.o(46292);
    }

    private void update() {
        AppMethodBeat.i(46293);
        s.cNC();
        this.tlM = s.cND().cQB();
        if (this.tlM == null || this.tlM.size() == 0 || this.trE) {
            ab.i("MicroMsg.WalletForgotPwdUI", "No bound bankcard process %s", new Object[]{Boolean.valueOf(this.trE)});
            this.tlM = new ArrayList();
            this.eol.setVisibility(0);
            this.gKd.setVisibility(8);
            setMMTitle(2131304785);
            ((TextView) findViewById(2131828798)).setText(getString(2131305098));
            WalletFormView walletFormView = this.trB;
            s.cNC();
            walletFormView.setText(e.atv(s.cND().bhp()));
            AppMethodBeat.o(46293);
            return;
        }
        ab.i("MicroMsg.WalletForgotPwdUI", "domestic process!");
        if (com.tencent.mm.wallet_core.a.aE(this) != null) {
            a(new t(), true, false);
        }
        this.eol.setVisibility(8);
        this.gEZ.setVisibility(8);
        findViewById(2131828804).setVisibility(0);
        this.trz = new a(this, this);
        this.gKd.setAdapter(this.trz);
        this.trz.items = this.tlM;
        this.trz.notifyDataSetChanged();
        AppMethodBeat.o(46293);
    }

    public void initView() {
        AppMethodBeat.i(46294);
        this.gKd = (ListView) findViewById(2131828799);
        this.eol = (LinearLayout) findViewById(2131828800);
        this.trB = (WalletFormView) findViewById(2131828681);
        this.trA = (WalletFormView) findViewById(2131828801);
        com.tencent.mm.wallet_core.ui.formview.a.b(this.trA);
        if (this.mBundle.getBoolean("key_is_paymanager", false)) {
            com.tencent.mm.wallet_core.ui.formview.a.d(this, this.trB);
        } else {
            com.tencent.mm.wallet_core.ui.formview.a.e(this, this.trB);
        }
        this.trB.setOnInputValidChangeListener(this);
        this.trA.setOnInputValidChangeListener(this);
        this.gEZ = (Button) findViewById(2131822846);
        this.gEZ.setOnClickListener(new 1(this));
        this.trD = false;
        s.cNC();
        this.tlM = s.cND().cQB();
        update();
        findViewById(2131828804).setOnClickListener(new 2(this));
        arW();
        a(this.trA, 0, false, false);
        this.trA.setOnInfoIvClickListener(new 3(this));
        this.trA.getInfoIv().setImageResource(2131232128);
        this.trA.getInfoIv().setVisibility(0);
        AppMethodBeat.o(46294);
    }

    private void ari() {
        AppMethodBeat.i(46296);
        Bundle bundle = new Bundle();
        bundle.putBoolean("key_is_reset_with_new_card", this.mBundle.getBoolean("key_is_reset_with_new_card", false));
        cOC();
        if (this.f1try == null && !this.trD) {
            a(new t(null, this.trA.getText(), null), true, true);
            AppMethodBeat.o(46296);
        } else if (this.trD) {
            aj cRh = r.cPE().cRh();
            if (bo.isNullOrNil(cRh.field_find_passwd_url)) {
                bundle.putBoolean("key_is_force_bind", true);
                bundle.putBoolean("key_is_reset_with_new_card", true);
                if (dOD() != null) {
                    dOD().a(this, 0, bundle);
                }
                AppMethodBeat.o(46296);
                return;
            }
            ab.i("MicroMsg.WalletForgotPwdUI", "hy: not support bind new bankcard. start to url");
            e.n(this, cRh.field_find_passwd_url, false);
            AppMethodBeat.o(46296);
        } else {
            com.tencent.mm.wallet_core.c aE = com.tencent.mm.wallet_core.a.aE(this);
            bundle.putParcelable("key_bankcard", this.f1try);
            ElementQuery elementQuery = new ElementQuery();
            for (Parcelable parcelable : this.trx) {
                ab.i("MicroMsg.WalletForgotPwdUI", "helios:::" + parcelable.pbn);
                if (!bo.isNullOrNil(parcelable.pbn) && !bo.isNullOrNil(this.f1try.field_bankcardType) && parcelable.pbn.trim().equals(this.f1try.field_bankcardType.trim())) {
                    break;
                }
            }
            Parcelable parcelable2 = elementQuery;
            bundle.putParcelable("elemt_query", parcelable2);
            if (aE != null) {
                aE.a(this, 0, bundle);
            }
            AppMethodBeat.o(46296);
        }
    }

    public final int getLayoutId() {
        return 2130971099;
    }

    public final boolean c(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(46297);
        ab.i("MicroMsg.WalletForgotPwdUI", " errCode: %s errMsg :  scene: ", new Object[]{Integer.valueOf(i2), str, mVar});
        if (i == 0 && i2 == 0) {
            String str2;
            if (mVar instanceof t) {
                t tVar = (t) mVar;
                Bundle bundle = new Bundle();
                if (bo.isNullOrNil(tVar.kaE)) {
                    this.trx = tVar.tum;
                    ab.i("MicroMsg.WalletForgotPwdUI", "scene case 1 mCardId is null");
                    AppMethodBeat.o(46297);
                    return true;
                } else if (tVar.tun == null) {
                    bundle.putString("bank_name", BuildConfig.FLAVOR);
                    bundle.putParcelable("elemt_query", new ElementQuery());
                    bundle.putString("key_card_id", this.trA.getText());
                    bundle.putBoolean("key_is_reset_with_new_card", true);
                    com.tencent.mm.wallet_core.a.j(this, bundle);
                } else if (tVar.tun.isError()) {
                    ab.i("MicroMsg.WalletForgotPwdUI", "scene case 2 mTargetElement is error");
                    h.g(this, 2131304582, 2131297061);
                    AppMethodBeat.o(46297);
                    return true;
                } else {
                    int i3;
                    str2 = "MicroMsg.WalletForgotPwdUI";
                    String str3 = "scene case 3 bankcards size %d";
                    Object[] objArr = new Object[1];
                    if (this.tlM == null) {
                        i3 = 0;
                    } else {
                        i3 = this.tlM.size();
                    }
                    objArr[0] = Integer.valueOf(i3);
                    ab.i(str2, str3, objArr);
                    if (this.tlM == null || this.tlM.size() == 0) {
                        cOC();
                        bundle.putString("bank_name", tVar.tun.nuL);
                        bundle.putParcelable("elemt_query", tVar.tun);
                        bundle.putString("key_card_id", this.trA.getText());
                        bundle.putBoolean("key_is_reset_with_new_card", true);
                        com.tencent.mm.wallet_core.a.j(this, bundle);
                        AppMethodBeat.o(46297);
                        return true;
                    }
                }
            } else if (mVar instanceof y) {
                String str4 = "MicroMsg.WalletForgotPwdUI";
                str2 = "scene case queryBound adapter is null ? %s";
                Object[] objArr2 = new Object[1];
                objArr2[0] = Boolean.valueOf(this.trz == null);
                ab.i(str4, str2, objArr2);
                if (this.trz != null) {
                    ArrayList arrayList = null;
                    if (r.cPI() != null) {
                        arrayList = r.cPI().cQB();
                    }
                    com.tencent.mm.wallet_core.c aE = com.tencent.mm.wallet_core.a.aE(this);
                    if (aE != null) {
                        aE.dNE();
                        ArrayList arrayList2 = new ArrayList();
                        ArrayList arrayList3 = new ArrayList();
                        Iterator it = arrayList.iterator();
                        while (it.hasNext()) {
                            Bankcard bankcard = (Bankcard) it.next();
                            if (bankcard.field_bankcardTag == 1) {
                                arrayList2.add(bankcard);
                            } else if (bankcard.field_bankcardTag == 2) {
                                arrayList3.add(bankcard);
                            }
                        }
                        if (arrayList2.size() > 0) {
                            this.tlM = arrayList2;
                        } else {
                            this.tlM = arrayList3;
                        }
                    }
                    str4 = "MicroMsg.WalletForgotPwdUI";
                    str2 = "scene case queryBound adapter update bankcardsize:  %d";
                    Object[] objArr3 = new Object[1];
                    objArr3[0] = Integer.valueOf(this.tlM == null ? 0 : this.tlM.size());
                    ab.i(str4, str2, objArr3);
                    this.trz.items = this.tlM;
                    new ak(Looper.getMainLooper()).post(new Runnable() {
                        public final void run() {
                            AppMethodBeat.i(46275);
                            WalletForgotPwdUI.this.trz.notifyDataSetChanged();
                            WalletForgotPwdUI.c(WalletForgotPwdUI.this);
                            AppMethodBeat.o(46275);
                        }
                    });
                }
            }
        }
        AppMethodBeat.o(46297);
        return false;
    }

    public final boolean bNf() {
        return true;
    }

    private boolean arW() {
        AppMethodBeat.i(46298);
        if (this.gKd.getVisibility() == 0 || (this.trB.asa() && this.trA.asa())) {
            this.gEZ.setEnabled(true);
            this.gEZ.setClickable(true);
            AppMethodBeat.o(46298);
            return true;
        }
        this.gEZ.setEnabled(false);
        this.gEZ.setClickable(false);
        AppMethodBeat.o(46298);
        return false;
    }

    public final void hY(boolean z) {
        AppMethodBeat.i(46299);
        arW();
        AppMethodBeat.o(46299);
    }

    public boolean cNR() {
        return true;
    }

    public final int getForceOrientation() {
        return 1;
    }

    public final boolean bwP() {
        AppMethodBeat.i(46300);
        if (this.tlM == null || this.tlM.size() == 0) {
            aj cRh = r.cPE().cRh();
            if (bo.isNullOrNil(cRh.field_find_passwd_url) && bo.isNullOrNil(cRh.field_forget_passwd_url)) {
                AppMethodBeat.o(46300);
                return false;
            }
            AppMethodBeat.o(46300);
            return true;
        }
        AppMethodBeat.o(46300);
        return false;
    }

    public final boolean bwQ() {
        AppMethodBeat.i(46301);
        AM(bwP() ? 4 : 0);
        AppMethodBeat.o(46301);
        return true;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        AppMethodBeat.i(46302);
        super.onActivityResult(i, i, intent);
        if (i2 == -1 && 1 == i) {
            this.trA.set3DesValStr(intent.getStringExtra("key_bankcard_id"));
            ari();
        }
        AppMethodBeat.o(46302);
    }

    private void cOC() {
        AppMethodBeat.i(46295);
        this.mBundle.remove("elemt_query");
        this.mBundle.remove("key_bankcard");
        this.mBundle.remove("bank_name");
        this.mBundle.remove("key_card_id");
        AppMethodBeat.o(46295);
    }

    static /* synthetic */ void c(WalletForgotPwdUI walletForgotPwdUI) {
        AppMethodBeat.i(46304);
        if (!"1".equals(r.cPE().cRh().field_reset_passwd_flag)) {
            ab.i("MicroMsg.WalletForgotPwdUI", "hy: not support bind new");
            AppMethodBeat.o(46304);
        } else if (bo.isNullOrNil(r.cPE().cRh().field_find_passwd_url)) {
            ab.i("MicroMsg.WalletForgotPwdUI", "hy: support bind new directly");
            ((ViewStub) walletForgotPwdUI.findViewById(2131828802)).inflate();
            ((WalletFormView) walletForgotPwdUI.findViewById(2131828796)).setOnClickListener(new 6(walletForgotPwdUI));
            AppMethodBeat.o(46304);
        } else {
            CharSequence spannableString;
            ab.i("MicroMsg.WalletForgotPwdUI", "hy: support bind new h5");
            ((ViewStub) walletForgotPwdUI.findViewById(2131828803)).inflate();
            TextView textView = (TextView) walletForgotPwdUI.findViewById(2131828797);
            j jVar = new j(walletForgotPwdUI);
            jVar.tHw = new 5(walletForgotPwdUI);
            String string;
            if (r.cPI().cQp()) {
                string = walletForgotPwdUI.getString(2131305093);
                spannableString = new SpannableString(string);
                spannableString.setSpan(jVar, string.length() - 12, string.length(), 33);
            } else {
                string = walletForgotPwdUI.getString(2131305094);
                spannableString = new SpannableString(string);
                spannableString.setSpan(jVar, 0, string.length(), 18);
            }
            textView.setText(spannableString);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            AppMethodBeat.o(46304);
        }
    }

    static /* synthetic */ void a(WalletForgotPwdUI walletForgotPwdUI, String str, String str2, Bitmap bitmap) {
        AppMethodBeat.i(46305);
        Bundle bundle = new Bundle();
        bundle.putString("key_bankcard_id", str);
        bundle.putString("key_bankcard_des", str2);
        bundle.putParcelable("key_bankcard_cropimg", bitmap);
        bundle.putBoolean("key_is_reset_with_new_card", true);
        com.tencent.mm.wallet_core.c aE = com.tencent.mm.wallet_core.a.aE(walletForgotPwdUI);
        if (aE != null) {
            aE.a(walletForgotPwdUI, WalletConfirmCardIDUI.class, bundle, 1);
        }
        AppMethodBeat.o(46305);
    }
}
