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

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.m;
import com.tencent.mm.model.r;
import com.tencent.mm.platformtools.x;
import com.tencent.mm.plugin.wallet.a.s;
import com.tencent.mm.plugin.wallet.balance.a.e;
import com.tencent.mm.plugin.wallet_core.c.y;
import com.tencent.mm.plugin.wallet_core.d.b;
import com.tencent.mm.plugin.wallet_core.model.Bankcard;
import com.tencent.mm.plugin.wallet_core.model.ak;
import com.tencent.mm.plugin.wallet_core.model.g;
import com.tencent.mm.plugin.wallet_core.ui.view.c;
import com.tencent.mm.pluginsdk.wallet.h;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.al;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.sdk.platformtools.d;
import com.tencent.mm.ui.base.a;
import com.tencent.mm.ui.base.n;
import com.tencent.mm.wallet_core.c.ad;
import com.tencent.mm.wallet_core.c.ae;
import com.tencent.mm.wallet_core.c.z;
import com.tencent.mm.wallet_core.ui.WalletBaseUI;
import com.tencent.mm.wallet_core.ui.formview.WalletFormView;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;

@a(2)
public class WalletBalanceSaveUI extends WalletBaseUI {
    protected Button gHn;
    private final int gnS = com.tencent.mm.bz.a.fromDPToPix(ah.getContext(), 270);
    private View jcl;
    protected WalletFormView kGa;
    protected double pQV;
    private HashMap<String, Integer> pas = new HashMap();
    private ArrayList<Bankcard> tgB;
    protected Bankcard tgC;
    private String tgD;
    protected LinearLayout tgF;

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

    public WalletBalanceSaveUI() {
        AppMethodBeat.i(45479);
        AppMethodBeat.o(45479);
    }

    static /* synthetic */ void f(WalletBalanceSaveUI walletBalanceSaveUI) {
        AppMethodBeat.i(45488);
        walletBalanceSaveUI.cu();
        AppMethodBeat.o(45488);
    }

    public boolean c(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(45480);
        if (i == 0 && i2 == 0) {
            if (mVar instanceof e) {
                boolean a;
                e eVar = (e) mVar;
                if ("1".equals(eVar.cRb)) {
                    ab.i("MicroMsg.WalletBalanceSaveUI", "need realname verify");
                    Bundle bundle = new Bundle();
                    bundle.putString("realname_verify_process_jump_activity", ".balance.ui.WalletBalanceSaveUI");
                    bundle.putString("realname_verify_process_jump_plugin", "wallet");
                    bwP();
                    a = com.tencent.mm.plugin.wallet_core.id_verify.util.a.a(this, bundle, null, 0);
                } else if ("2".equals(eVar.cRb)) {
                    ab.i("MicroMsg.WalletBalanceSaveUI", "need upload credit");
                    a = com.tencent.mm.plugin.wallet_core.id_verify.util.a.a(this, eVar.cRc, eVar.cRf, eVar.cRd, eVar.cRe, bwP(), null);
                } else {
                    ab.i("MicroMsg.WalletBalanceSaveUI", "realnameGuideFlag =  " + eVar.cRb);
                    a = false;
                }
                if (a) {
                    AppMethodBeat.o(45480);
                } else {
                    String str2;
                    String str3 = ((e) mVar).cBT;
                    ad.o(11, str3, i2);
                    if (this.tgC == null) {
                        str2 = BuildConfig.FLAVOR;
                    } else {
                        str2 = this.tgC.field_bindSerial;
                    }
                    h.a(this, str2, str3, BuildConfig.FLAVOR, 11, 1);
                }
            } else if (mVar instanceof y) {
                cfk();
                cu();
            }
            AppMethodBeat.o(45480);
        } else {
            if (mVar instanceof e) {
                ad.o(11, BuildConfig.FLAVOR, i2);
            }
            AppMethodBeat.o(45480);
        }
        return false;
    }

    private void cfk() {
        int i;
        AppMethodBeat.i(45481);
        s.cNC();
        ak cND = s.cND();
        this.tgB = cND.cQD();
        this.tgC = cND.a(this.tgB, null, false, true);
        if (this.tgC != null && bo.isNullOrNil(this.tgC.field_forbidWord)) {
            this.tgC = null;
            i = 0;
            while (i < this.tgB.size()) {
                if (this.tgB.get(i) != null && bo.isNullOrNil(((Bankcard) this.tgB.get(i)).field_forbidWord)) {
                    this.tgC = (Bankcard) this.tgB.get(i);
                    break;
                }
                i++;
            }
        }
        if (!(this.tgC == null || bo.isNullOrNil(this.tgC.field_forbidWord))) {
            this.tgC = null;
        }
        ArrayList arrayList = this.tgB;
        if (arrayList != null) {
            for (i = 0; i < arrayList.size(); i++) {
                ab.v("MicroMsg.WalletBalanceSaveUI", "pos %s word %s", new Object[]{Integer.valueOf(i), ((Bankcard) arrayList.get(i)).field_forbidWord});
            }
        }
        AppMethodBeat.o(45481);
    }

    public final int getLayoutId() {
        return 2130971053;
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(45482);
        super.onCreate(bundle);
        if (!r.YM()) {
            a(new com.tencent.mm.plugin.wallet_core.c.ab(), false, false);
        }
        cfk();
        this.tgD = getString(2131304574);
        initView();
        cu();
        z.hL(3, 0);
        AppMethodBeat.o(45482);
    }

    public final void initView() {
        AppMethodBeat.i(45483);
        setMMTitle(2131304580);
        this.jcl = findViewById(2131828642);
        this.kGa = (WalletFormView) findViewById(2131822842);
        com.tencent.mm.wallet_core.ui.formview.a.f(this.kGa);
        this.kGa.getTitleTv().setText(ae.dOd());
        e(this.kGa, 2, false);
        this.gHn = (Button) findViewById(2131822846);
        this.gHn.setOnClickListener(new 1(this));
        this.tgF = (LinearLayout) findViewById(2131828607);
        if (this.tgF != null) {
            this.tgF.setOnClickListener(new 2(this));
        }
        this.obM = new 3(this);
        AppMethodBeat.o(45483);
    }

    private void cu() {
        AppMethodBeat.i(45484);
        if (this.tgF != null) {
            if (this.tgC != null) {
                final ImageView imageView = (ImageView) this.tgF.findViewById(2131828609);
                String str = BuildConfig.FLAVOR;
                com.tencent.mm.plugin.wallet_core.model.e i = b.i(this, this.tgC.field_bankcardType, this.tgC.cPb());
                if (i != null) {
                    str = i.oRi;
                }
                imageView.setImageBitmap(null);
                if (this.tgC.cPc()) {
                    imageView.setBackgroundResource(2130840657);
                } else {
                    Bitmap a = x.a(new c(str));
                    x.a(new x.a() {
                        public final void m(String str, Bitmap bitmap) {
                            AppMethodBeat.i(45478);
                            al.d(new 1(this, bitmap));
                            AppMethodBeat.o(45478);
                        }
                    });
                    if (!(a == null || a == null)) {
                        imageView.setImageBitmap(d.a(a, getResources().getDimensionPixelOffset(2131428760), getResources().getDimensionPixelOffset(2131428760), true, false));
                    }
                }
                ((TextView) this.tgF.findViewById(2131828610)).setText(getString(2131304572, new Object[]{this.tgC.field_bankName, this.tgC.field_bankcardTail}));
                ((TextView) this.tgF.findViewById(2131820694)).setText(this.tgC.field_bankcardTypeName);
                if (bo.isNullOrNil(this.tgC.field_avail_save_wording)) {
                    ab.i("MicroMsg.WalletBalanceSaveUI", "hy: wording's missing. use default");
                    ((TextView) this.tgF.findViewById(2131828611)).setText(BuildConfig.FLAVOR);
                    AppMethodBeat.o(45484);
                    return;
                }
                ((TextView) this.tgF.findViewById(2131828611)).setText(this.tgC.field_avail_save_wording);
                AppMethodBeat.o(45484);
                return;
            }
            ((TextView) this.tgF.findViewById(2131828610)).setText(this.tgD);
            ((TextView) this.tgF.findViewById(2131828611)).setText(BuildConfig.FLAVOR);
            ((ImageView) this.tgF.findViewById(2131828609)).setImageBitmap(null);
            ((TextView) this.tgF.findViewById(2131820694)).setText(getString(2131304571));
        }
        AppMethodBeat.o(45484);
    }

    /* Access modifiers changed, original: protected */
    public void cNd() {
        AppMethodBeat.i(45485);
        if (this.tgC != null) {
            a(new e(this.pQV, "CNY", this.tgC.field_bindSerial, this.tgC.field_bankcardType), true, true);
            AppMethodBeat.o(45485);
            return;
        }
        g cPl = g.cPl();
        if (cPl.aFF()) {
            com.tencent.mm.ui.base.h.b(this, cPl.pbp, getString(2131297061), true);
            AppMethodBeat.o(45485);
            return;
        }
        a(new e(this.pQV, "CNY", BuildConfig.FLAVOR, BuildConfig.FLAVOR), true, true);
        AppMethodBeat.o(45485);
    }

    public final int getForceOrientation() {
        return 1;
    }

    static /* synthetic */ void a(WalletBalanceSaveUI walletBalanceSaveUI) {
        List linkedList;
        AppMethodBeat.i(45486);
        walletBalanceSaveUI.pas.clear();
        final com.tencent.mm.ui.widget.d dVar = new com.tencent.mm.ui.widget.d(walletBalanceSaveUI, 2, true);
        if (walletBalanceSaveUI.tgB == null) {
            linkedList = new LinkedList();
        } else {
            Object linkedList2 = walletBalanceSaveUI.tgB;
        }
        int size = linkedList2.size();
        for (int i = 0; i < linkedList2.size(); i++) {
            Bankcard bankcard = (Bankcard) linkedList2.get(i);
            if (!(walletBalanceSaveUI.tgC == null || bo.isNullOrNil(bankcard.field_bindSerial) || !walletBalanceSaveUI.tgC.field_bindSerial.equals(bankcard.field_bindSerial))) {
                size = i;
            }
        }
        dVar.rBl = new 4(walletBalanceSaveUI, linkedList2, dVar);
        dVar.rBm = new n.d() {
            public final void onMMMenuItemSelected(MenuItem menuItem, int i) {
                AppMethodBeat.i(45475);
                if (dVar != null) {
                    dVar.cpE();
                    if (i < linkedList2.size()) {
                        WalletBalanceSaveUI.this.tgC = (Bankcard) WalletBalanceSaveUI.this.tgB.get(i);
                        WalletBalanceSaveUI.f(WalletBalanceSaveUI.this);
                        AppMethodBeat.o(45475);
                        return;
                    }
                    WalletBalanceSaveUI.this.tgC = null;
                    WalletBalanceSaveUI.f(WalletBalanceSaveUI.this);
                }
                AppMethodBeat.o(45475);
            }
        };
        View inflate = View.inflate(walletBalanceSaveUI, 2130971046, null);
        inflate.findViewById(2131828599).setVisibility(8);
        ((TextView) inflate.findViewById(2131828598)).setText(2131304523);
        dVar.pIf = true;
        dVar.zQA = size;
        dVar.zQy = true;
        dVar.F(inflate, false);
        dVar.cpD();
        AppMethodBeat.o(45486);
    }

    static /* synthetic */ void b(WalletBalanceSaveUI walletBalanceSaveUI) {
        AppMethodBeat.i(45487);
        if (walletBalanceSaveUI.jcl != null) {
            int[] iArr = new int[2];
            walletBalanceSaveUI.gHn.getLocationInWindow(iArr);
            int ge = (com.tencent.mm.bz.a.ge(walletBalanceSaveUI) - r0) - com.tencent.mm.bz.a.fromDPToPix(walletBalanceSaveUI, 30);
            ab.d("MicroMsg.WalletBalanceSaveUI", "scrollToFormEditPosAfterShowTenPay, editText locationY: %s, height: %s, diff: %s, hardcodeKeyboardHeight: %s", new Object[]{Integer.valueOf(iArr[1] + walletBalanceSaveUI.gHn.getHeight()), Integer.valueOf(com.tencent.mm.bz.a.ge(walletBalanceSaveUI)), Integer.valueOf(ge), Integer.valueOf(walletBalanceSaveUI.gnS)});
            if (ge > 0 && ge < walletBalanceSaveUI.gnS) {
                ab.d("MicroMsg.WalletBalanceSaveUI", "scrollToFormEditPosAfterShowTenPay, scrollDistance: %s", new Object[]{Integer.valueOf(walletBalanceSaveUI.gnS - ge)});
                walletBalanceSaveUI.jcl.post(new 6(walletBalanceSaveUI, r0));
            }
        }
        AppMethodBeat.o(45487);
    }
}
