package com.scb.phone.view.fragment.purchase; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; import com.google.android.material.textfield.TextInputLayout; import com.scb.phone.R; import com.scb.phone.view.activity.purchase.PurchaseReviewActivity; import com.scb.phone.view.custom.common.AmountEditText; import com.scb.phone.view.custom.common.CustomDialog; import com.scb.phone.view.custom.common.DefaultButton; import com.scb.phone.view.custom.common.NoteEditText; import com.scb.phone.view.fragment.purchase.PurchaseCreditCardInputFragment; import o.C0367Fb; import o.C11582ei; import o.C1189Xo; import o.C1203Xy; import o.C12891fKc; import o.C15602gz; import o.C6583cXR; import o.C7854cwG; import o.InterfaceC13391fZD; import o.InterfaceC8972dat; import o.ZI; import o.fLM; import o.gjJ; import o.nMh; import o.rmb; /* loaded from: classes5.dex */ public class PurchaseCreditCardInputFragment extends Hilt_PurchaseCreditCardInputFragment implements InterfaceC8972dat.LWm { @BindView protected DefaultButton buttonReview; private C1203Xy c; private double d; @BindView protected AmountEditText editAmount; @BindView protected ImageView imageIcon; @BindView protected TextInputLayout inputLayout; @BindView protected NoteEditText noteEditText; @InterfaceC13391fZD public C7854cwG purchaseCreditCardInputpresenter; @BindView protected TextView terminalId; @BindView protected TextView textNumber; @BindView protected TextView textTitle; public static PurchaseCreditCardInputFragment c(C1203Xy c1203Xy) { Bundle bundle = new Bundle(); bundle.putParcelable("com.scb.phone.TransferTabFragment.EXTRA_BILL_SCAN", c1203Xy); PurchaseCreditCardInputFragment purchaseCreditCardInputFragment = new PurchaseCreditCardInputFragment(); purchaseCreditCardInputFragment.setArguments(bundle); return purchaseCreditCardInputFragment; } @Override // androidx.fragment.app.Fragment public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { View inflate = layoutInflater.inflate(R.layout.2131559844, viewGroup, false); ButterKnife.c(this, inflate); this.purchaseCreditCardInputpresenter.e((C7854cwG) this); if (getArguments() != null && getArguments().getParcelable("com.scb.phone.TransferTabFragment.EXTRA_BILL_SCAN") != null) { this.c = (C1203Xy) getArguments().getParcelable("com.scb.phone.TransferTabFragment.EXTRA_BILL_SCAN"); } this.purchaseCreditCardInputpresenter.e = this.c; Context context = getContext(); C12891fKc.azg_(context, nMh.getDrawable(getContext(), R.drawable.shop_large), this.imageIcon, this.c.f.d, context.getResources().getDimensionPixelOffset(R.dimen.f15222131165286), nMh.getColor(context, R.color.f3412131099849)); this.textTitle.setVisibility(0); this.textTitle.setText(this.c.f.f); this.textNumber.setVisibility(8); if (this.c.f.g != null && !this.c.f.g.isEmpty()) { this.terminalId.setVisibility(0); this.terminalId.setText(getString(R.string.terminal_id, this.c.f.k, this.c.f.g)); } if (this.c.f.h != null && Double.parseDouble(this.c.f.h) != 0.0d) { this.d = C6583cXR.c(this.c.f.h).doubleValue(); this.editAmount.setFormattedAmount(this.c.f.h); this.editAmount.setEnabled(false); } this.buttonReview.setButtonEnabled(false); this.inputLayout.setVisibility(0); this.inputLayout.setHint("0.00"); this.editAmount.setOnPasteListener(new AmountEditText.HBt()); this.editAmount.setMaximumDecimalDigit(17); this.editAmount.setOnAmountChangeListener(new AmountEditText.RVV(this) { // from class: com.scb.phone.view.fragment.purchase.PurchaseCreditCardInputFragment.1 private PurchaseCreditCardInputFragment b; { this.b = this; } @Override // com.scb.phone.view.custom.common.AmountEditText.RVV public final void b(double d) { PurchaseCreditCardInputFragment.c(this.b, d); } @Override // com.scb.phone.view.custom.common.AmountEditText.RVV public final void a() { this.b.d(); this.b.aN_(); } }); return inflate; } @OnClick public void onReviewButtonClick() { C7854cwG c7854cwG = this.purchaseCreditCardInputpresenter; String obj = this.noteEditText.mNoteEditText.getText().toString(); if (c7854cwG.f != 0) { if (TextUtils.isEmpty(obj) || ((Boolean) C6583cXR.c(new Object[]{obj}, -1032102340, 1032102340, (int) System.currentTimeMillis())).booleanValue()) { aN_(); y(); C7854cwG c7854cwG2 = this.purchaseCreditCardInputpresenter; double d = this.d; String obj2 = this.noteEditText.mNoteEditText.getText().toString(); c7854cwG2.b.b(new C11582ei(c7854cwG2.e.f8457o, c7854cwG2.d, C15602gz.e(d))); rmb rmbVar = c7854cwG2.b; rmbVar.d(rmbVar.i, new C7854cwG.Sts(c7854cwG2, d, obj2)); return; } ZI.IeS ieS = new ZI.IeS() { // from class: o.cwD @Override // o.ZI.IeS public final void e(Object obj3) { ((InterfaceC8972dat.LWm) obj3).a(); } }; if (c7854cwG.f != 0) { ieS.e(c7854cwG.f); } } } public final void d() { if (this.d == 0.0d || this.editAmount.getText().toString().isEmpty()) { this.inputLayout.setError(getString(R.string.scan_qr_credit_card_error_inline)); this.inputLayout.setErrorEnabled(true); this.buttonReview.setButtonEnabled(false); return; } if (this.d > this.purchaseCreditCardInputpresenter.a) { this.inputLayout.setError(getString(R.string.not_enough_funds_on_selected_account)); this.inputLayout.setErrorEnabled(true); this.buttonReview.setButtonEnabled(false); } else { this.inputLayout.setError(null); this.inputLayout.setErrorEnabled(false); C7854cwG c7854cwG = this.purchaseCreditCardInputpresenter; double d = this.d; this.buttonReview.setButtonEnabled(c7854cwG.c != null && d <= c7854cwG.a && d > 0.0d); } } @Override // o.InterfaceC8972dat.LWm public final void a() { this.noteEditText.d(); } @Override // o.InterfaceC8972dat.LWm public final void b(String str, String str2, final C1189Xo c1189Xo) { CustomDialog b = CustomDialog.b(getContext()); if (gjJ.a(str)) { b.mTitleTextView.setVisibility(0); b.mTitleTextView.setText(str); } if (gjJ.a(str2)) { b.mTextTextView.setVisibility(0); b.mTextTextView.setText(str2); } ((CustomDialog) CustomDialog.e(new Object[]{b.aoT_(R.string.ok, new DialogInterface.OnClickListener(this, c1189Xo) { // from class: o.fvP private C1189Xo b; private PurchaseCreditCardInputFragment c; @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i) { PurchaseReviewActivity.d(this.c.getContext(), this.b, "creditcard"); } { this.c = this; this.b = c1189Xo; } }), Integer.valueOf(R.string.cancel), new DialogInterface.OnClickListener() { // from class: o.fvR @Override // android.content.DialogInterface.OnClickListener public final void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }})).show(); } @Override // o.InterfaceC8972dat.LWm public final void a(C1189Xo c1189Xo) { PurchaseReviewActivity.d(getContext(), c1189Xo, "creditcard"); } static /* synthetic */ void c(PurchaseCreditCardInputFragment purchaseCreditCardInputFragment, double d) { purchaseCreditCardInputFragment.d = d; C7854cwG c7854cwG = purchaseCreditCardInputFragment.purchaseCreditCardInputpresenter; purchaseCreditCardInputFragment.buttonReview.setButtonEnabled(c7854cwG.c != null && d <= c7854cwG.a && d > 0.0d); } public final void b(C0367Fb c0367Fb) { C7854cwG c7854cwG = this.purchaseCreditCardInputpresenter; c7854cwG.d = c0367Fb.g; c7854cwG.c = c0367Fb.q; c7854cwG.a = C6583cXR.c(c0367Fb.d).doubleValue(); C7854cwG c7854cwG2 = this.purchaseCreditCardInputpresenter; double d = this.d; this.buttonReview.setButtonEnabled(c7854cwG2.c != null && d <= c7854cwG2.a && d > 0.0d); AmountEditText amountEditText = this.editAmount; amountEditText.setCurrencyFormattingTextWatcher(new fLM(amountEditText, this.inputLayout, C6583cXR.c(c0367Fb.d).doubleValue(), 0.0d, getResources().getString(R.string.error_limit), getResources().getString(R.string.not_enough_funds_on_selected_account), getResources().getString(R.string.scan_qr_credit_card_error_inline))); if (this.d > this.purchaseCreditCardInputpresenter.a) { this.inputLayout.setError(getString(R.string.not_enough_funds_on_selected_account)); this.inputLayout.setErrorEnabled(true); } else { this.inputLayout.setError(null); this.inputLayout.setErrorEnabled(false); } } }