package com.tencent.mm.plugin.collect.reward.ui;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.m;
import com.tencent.mm.g.a.fx;
import com.tencent.mm.plugin.collect.reward.a.d;
import com.tencent.mm.pluginsdk.ui.a.b;
import com.tencent.mm.pluginsdk.ui.e.j;
import com.tencent.mm.pluginsdk.wallet.PayInfo;
import com.tencent.mm.pluginsdk.wallet.h;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.widget.MMEditText;
import com.tencent.mm.wallet_core.ui.WalletTextView;
import com.tencent.mm.wallet_core.ui.e;
import com.tencent.mm.wallet_core.ui.formview.WalletFormView;
import com.tencent.ttpic.baseutils.IOUtils;
import com.tencent.ytcommon.BuildConfig;

public class QrRewardGrantUI extends QrRewardBaseUI {
    private RadioButton aaX;
    private int cIb;
    private String czZ;
    private String hAh;
    private String kBE;
    private ImageView kDI;
    private TextView kDJ;
    private TextView kDK;
    private WalletTextView kDL;
    private LinearLayout kDM;
    private WalletFormView kDN;
    private MMEditText kDO;
    private Button kDP;
    private int kDQ;
    private int kDR;
    private String kDS;
    private String kDT;
    private String kDU;
    private String kDV;
    private String kDW;
    private String kDX;
    private String kDY;
    private String kDZ;
    private String kEa;
    private int kEb;
    private c<fx> kEc = new 8(this);

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

    public QrRewardGrantUI() {
        AppMethodBeat.i(41072);
        AppMethodBeat.o(41072);
    }

    static /* synthetic */ void a(QrRewardGrantUI qrRewardGrantUI, String str, String str2) {
        AppMethodBeat.i(41082);
        qrRewardGrantUI.dA(str, str2);
        AppMethodBeat.o(41082);
    }

    public void onCreate(Bundle bundle) {
        AppMethodBeat.i(41073);
        super.onCreate(bundle);
        nf(1336);
        this.kEc.dnU();
        setMMTitle(2131302065);
        this.kDQ = getIntent().getIntExtra("key_money_amt", 20000);
        this.kDR = getIntent().getIntExtra("key_amt_type", 0);
        this.kDS = getIntent().getStringExtra("key_qrcode_desc");
        this.cIb = getIntent().getIntExtra("key_channel", 0);
        this.kDU = getIntent().getStringExtra("key_rcvr_open_id");
        this.kDW = getIntent().getStringExtra("key_rcvr_name");
        this.kDX = getIntent().getStringExtra("key_rcvr_true_name");
        this.kDY = getIntent().getStringExtra("key_scan_id");
        this.hAh = getIntent().getStringExtra("key_web_url");
        this.kDZ = getIntent().getStringExtra("key_sxtend_1");
        this.kEa = getIntent().getStringExtra("key_sxtend_2");
        this.kEb = getIntent().getIntExtra("key_max_amt", 20000);
        ab.i("MicroMsg.QrRewardGrantUI", "amtType: %s, channel: %s, maxAmt: %s", new Object[]{Integer.valueOf(this.kDR), Integer.valueOf(this.cIb), Integer.valueOf(this.kEb)});
        initView();
        AppMethodBeat.o(41073);
    }

    public final void initView() {
        AppMethodBeat.i(41074);
        this.kDI = (ImageView) findViewById(2131826730);
        this.kDJ = (TextView) findViewById(2131826731);
        this.kDL = (WalletTextView) findViewById(2131826733);
        this.kDM = (LinearLayout) findViewById(2131826732);
        this.kDN = (WalletFormView) findViewById(2131826734);
        this.kDO = (MMEditText) findViewById(2131826735);
        this.kDP = (Button) findViewById(2131826738);
        this.kDK = (TextView) findViewById(2131826739);
        this.aaX = (RadioButton) findViewById(2131826737);
        this.aaX.setChecked(true);
        this.kDK.setText(getString(2131302080, new Object[]{Math.round(((float) this.kEb) / 100.0f)}));
        b.a(this.kDI, this.kDW, 0.03f, false);
        String eK = e.eK(e.mJ(this.kDW), 10);
        this.kDJ.setText(j.b(this, getString(2131302066, new Object[]{eK})));
        if (this.kDR == 2) {
            ab.i("MicroMsg.QrRewardGrantUI", "edit layout");
            e(this.kDN, 2, false);
            this.kDN.a(new TextWatcher() {
                public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                }

                public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                }

                public final void afterTextChanged(Editable editable) {
                    AppMethodBeat.i(41063);
                    if (editable.toString().startsWith(".")) {
                        editable.insert(0, "0");
                    }
                    String obj = editable.toString();
                    int indexOf = obj.indexOf(".");
                    int length = obj.length();
                    if (indexOf >= 0 && length - indexOf > 3) {
                        editable.delete(indexOf + 3, length);
                    } else if (indexOf > 6) {
                        editable.delete(6, indexOf);
                    } else if (indexOf == -1 && length > 6) {
                        editable.delete(6, length);
                    }
                    length = (int) Math.round(bo.getDouble(editable.toString(), 0.0d) * 100.0d);
                    QrRewardGrantUI.a(QrRewardGrantUI.this, length);
                    QrRewardGrantUI.this.kDQ = length;
                    AppMethodBeat.o(41063);
                }
            });
            this.kDN.setVisibility(0);
            this.kDM.setVisibility(8);
            this.kDN.dOS();
            this.kDP.setEnabled(false);
        } else {
            this.kDL.setText(e.F(((double) this.kDQ) / 100.0d));
            this.kDN.setVisibility(8);
            this.kDM.setVisibility(0);
        }
        this.kDP.setOnClickListener(new 2(this));
        findViewById(2131826736).setOnClickListener(new 3(this));
        this.aaX.setOnCheckedChangeListener(new 4(this));
        AppMethodBeat.o(41074);
    }

    public final boolean c(int i, int i2, String str, m mVar) {
        AppMethodBeat.i(41075);
        if (mVar instanceof com.tencent.mm.plugin.collect.reward.a.e) {
            com.tencent.mm.plugin.collect.reward.a.e eVar = (com.tencent.mm.plugin.collect.reward.a.e) mVar;
            eVar.a(new 7(this, eVar)).b(new 6(this, eVar)).c(new 5(this));
        }
        AppMethodBeat.o(41075);
        return true;
    }

    public void onDestroy() {
        AppMethodBeat.i(41076);
        super.onDestroy();
        ng(1336);
        this.kEc.dead();
        AppMethodBeat.o(41076);
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        AppMethodBeat.i(41077);
        if (i != 1) {
            super.onActivityResult(i, i2, intent);
        } else if (i2 == -1) {
            setResult(-1);
            if (intent != null) {
                dA(intent.getStringExtra("key_reqKey"), intent.getStringExtra("key_trans_id"));
            }
            finish();
            AppMethodBeat.o(41077);
            return;
        }
        AppMethodBeat.o(41077);
    }

    public final int getLayoutId() {
        return 2130970430;
    }

    private void dA(String str, String str2) {
        AppMethodBeat.i(41078);
        ab.i("MicroMsg.QrRewardGrantUI", "do pay check");
        if (bo.isNullOrNil(this.czZ)) {
            this.czZ = str;
        }
        if (bo.isNullOrNil(this.kBE)) {
            this.kBE = str2;
        }
        a(new d(this.czZ, this.kDT, this.kBE, this.kDQ, this.kDU, this.kDV), false, false);
        AppMethodBeat.o(41078);
    }

    static /* synthetic */ void b(QrRewardGrantUI qrRewardGrantUI) {
        AppMethodBeat.i(41080);
        ab.i("MicroMsg.QrRewardGrantUI", "do place order, amt: %s, amtType: %s, payer desc: %s showPayInfo %s", new Object[]{Integer.valueOf(qrRewardGrantUI.kDQ), Integer.valueOf(qrRewardGrantUI.kDR), qrRewardGrantUI.kDO.getText().toString().replace(IOUtils.LINE_SEPARATOR_UNIX, BuildConfig.FLAVOR), Integer.valueOf(qrRewardGrantUI.aaX.isChecked() ? 1 : 0)});
        com.tencent.mm.plugin.collect.reward.a.e eVar = new com.tencent.mm.plugin.collect.reward.a.e(qrRewardGrantUI.kDQ, qrRewardGrantUI.kDR, qrRewardGrantUI.kDW, qrRewardGrantUI.kDS, r5, qrRewardGrantUI.cIb, qrRewardGrantUI.kDY, qrRewardGrantUI.kDU, qrRewardGrantUI.hAh, qrRewardGrantUI.kDZ, qrRewardGrantUI.kEa, r12);
        eVar.z(qrRewardGrantUI);
        qrRewardGrantUI.a(eVar, true, true);
        AppMethodBeat.o(41080);
    }

    static /* synthetic */ void d(QrRewardGrantUI qrRewardGrantUI) {
        AppMethodBeat.i(41081);
        ab.i("MicroMsg.QrRewardGrantUI", "start pay");
        PayInfo payInfo = new PayInfo();
        payInfo.czZ = qrRewardGrantUI.czZ;
        payInfo.cIf = 48;
        Bundle bundle = new Bundle();
        bundle.putString("extinfo_key_1", qrRewardGrantUI.kDW);
        bundle.putString("extinfo_key_2", qrRewardGrantUI.kDX);
        bundle.putString("extinfo_key_3", qrRewardGrantUI.kDS);
        bundle.putString("extinfo_key_7", qrRewardGrantUI.kDO.getText().toString().replace(IOUtils.LINE_SEPARATOR_UNIX, BuildConfig.FLAVOR));
        payInfo.vwh = bundle;
        h.a(qrRewardGrantUI, payInfo, 1);
        AppMethodBeat.o(41081);
    }
}
