what-the-bank/sources/com/scb/phone/view/custom/common/CustomDeltaInput.java

401 lines
13 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.custom.common;
import android.content.Context;
import android.os.Parcelable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.scb.phone.R;
import com.scb.phone.view.custom.common.AmountEditText;
import com.scb.phone.view.custom.common.CustomDeltaInput;
import java.math.BigDecimal;
import o.C6583cXR;
/* loaded from: classes5.dex */
public class CustomDeltaInput extends LinearLayout {
private RVV a;
private double b;
public double c;
@BindView
public RelativeLayout container;
private double d;
@BindView
ImageButton decreaseButton;
protected Sts e;
@BindView
public TextView errorMessage;
private HBt f;
private LWm g;
@BindView
ImageButton increaseButton;
@BindView
public AmountEditText inputValue;
private TextWatcher j;
@BindView
TextView limitMessage;
/* loaded from: classes5.dex */
public interface HBt {
void c(double d, boolean z);
}
/* loaded from: classes5.dex */
public interface LWm {
void b();
}
/* loaded from: classes5.dex */
public interface RVV {
void aP_();
}
/* loaded from: classes5.dex */
public interface Sts {
void h();
void j();
}
public CustomDeltaInput(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
LayoutInflater.from(context).inflate(R.layout.2131558989, (ViewGroup) this, true);
ButterKnife.c(this);
this.decreaseButton.setEnabled(false);
this.j = new TextWatcher(this) { // from class: com.scb.phone.view.custom.common.CustomDeltaInput.5
private CustomDeltaInput e;
@Override // android.text.TextWatcher
public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override // android.text.TextWatcher
public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
{
this.e = this;
}
@Override // android.text.TextWatcher
public final void afterTextChanged(Editable editable) {
this.e.inputValue.removeTextChangedListener(this);
int selectionStart = this.e.inputValue.getSelectionStart();
int length = this.e.inputValue.getText().length();
if (!TextUtils.isEmpty(editable.toString())) {
this.e.setActualValue(C6583cXR.c(editable.toString()).doubleValue());
} else {
this.e.c = 0.0d;
}
this.e.inputValue.addTextChangedListener(this);
if (this.e.inputValue.getText().length() - length == 1) {
selectionStart++;
}
if (selectionStart >= this.e.inputValue.getText().length()) {
selectionStart = this.e.inputValue.getText().length();
}
this.e.inputValue.setSelection(selectionStart);
}
};
this.inputValue.setImeOptions(6);
this.inputValue.addTextChangedListener(this.j);
this.inputValue.setCustomHint(getResources().getString(R.string.transfer_to_account_amount_hint));
this.inputValue.setHandleDismissKeyboard(new AmountEditText.LWm(this) { // from class: o.eBv
private CustomDeltaInput d;
@Override // com.scb.phone.view.custom.common.AmountEditText.LWm
public final void d() {
CustomDeltaInput.b(this.d);
}
{
this.d = this;
}
});
this.inputValue.setOnEditorActionListener(new TextView.OnEditorActionListener(this) { // from class: o.eBs
private CustomDeltaInput b;
@Override // android.widget.TextView.OnEditorActionListener
public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
return CustomDeltaInput.b(this.b, i);
}
{
this.b = this;
}
});
}
public CustomDeltaInput(Context context) {
this(context, null);
}
@Override // android.view.View
protected Parcelable onSaveInstanceState() {
return super.onSaveInstanceState();
}
public void setContentDescriptionView(String str) {
this.increaseButton.setContentDescription(str);
this.decreaseButton.setContentDescription(str);
this.inputValue.setContentDescription(str);
}
/* JADX INFO: Access modifiers changed from: protected */
public void b(final double d) {
this.increaseButton.setOnClickListener(new View.OnClickListener(this, d) { // from class: o.eBu
private CustomDeltaInput b;
private double c;
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
CustomDeltaInput.d(this.b, this.c);
}
{
this.b = this;
this.c = d;
}
});
this.decreaseButton.setOnClickListener(new View.OnClickListener(this, d) { // from class: o.eBr
private CustomDeltaInput b;
private double c;
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
CustomDeltaInput.a(this.b, this.c);
}
{
this.b = this;
this.c = d;
}
});
}
private void i() {
if (this.c <= this.d && this.decreaseButton.isEnabled()) {
this.decreaseButton.setEnabled(false);
}
if (this.c >= this.b && this.increaseButton.isEnabled()) {
this.increaseButton.setEnabled(false);
}
if (this.c > this.d && !this.decreaseButton.isEnabled()) {
this.decreaseButton.setEnabled(true);
}
if (this.c >= this.b || this.increaseButton.isEnabled()) {
return;
}
this.increaseButton.setEnabled(true);
}
/* JADX INFO: Access modifiers changed from: protected */
public final void e(double d) {
setActualValue(C6583cXR.c(d, this.d, this.b));
}
public void setActualValue(double d) {
this.c = d;
this.inputValue.setText(C6583cXR.b(d));
i();
HBt hBt = this.f;
if (hBt != null) {
boolean e = e();
if (!e) {
this.errorMessage.setVisibility(0);
} else {
this.errorMessage.setVisibility(8);
}
hBt.c(d, e);
}
}
public void setActualValueUI(double d) {
this.inputValue.setText(C6583cXR.b(d));
i();
HBt hBt = this.f;
if (hBt != null) {
boolean e = e();
if (!e) {
this.errorMessage.setVisibility(0);
} else {
this.errorMessage.setVisibility(8);
}
hBt.c(d, e);
}
}
public final boolean e() {
return BigDecimal.valueOf(this.c).compareTo(BigDecimal.valueOf(this.d)) >= 0 && BigDecimal.valueOf(this.c).compareTo(BigDecimal.valueOf(this.b)) <= 0;
}
public void setDelta(double d) {
b(d);
}
public void setErrorMessage(String str) {
this.errorMessage.setText(str);
}
public final void a() {
if (getContext() != null) {
this.limitMessage.setVisibility(0);
this.limitMessage.setText(String.format(getContext().getString(R.string.personal_limit_max_label), C6583cXR.b(this.b)));
}
}
public final void c() {
this.inputValue.setCustomHint(String.format("%s - %s", C6583cXR.b(this.d), C6583cXR.b(this.b)));
}
public void setOnFocusLostListener(View.OnFocusChangeListener onFocusChangeListener) {
setOnFocusLostListener(onFocusChangeListener, true);
}
public void setOnFocusLostListener(final View.OnFocusChangeListener onFocusChangeListener, final boolean z) {
this.inputValue.setOnFocusChangeListener(new View.OnFocusChangeListener(this, z, onFocusChangeListener) { // from class: o.eBt
private View.OnFocusChangeListener a;
private boolean b;
private CustomDeltaInput d;
@Override // android.view.View.OnFocusChangeListener
public final void onFocusChange(View view, boolean z2) {
CustomDeltaInput.aoE_(this.d, this.b, this.a, view, z2);
}
{
this.d = this;
this.b = z;
this.a = onFocusChangeListener;
}
});
}
public void setOnClickInputAmountListener(View.OnClickListener onClickListener) {
this.inputValue.setOnClickListener(onClickListener);
}
public void setHint(int i) {
this.inputValue.setHint(i);
}
public static /* synthetic */ void d(CustomDeltaInput customDeltaInput, double d) {
customDeltaInput.setActualValue(C6583cXR.c(BigDecimal.valueOf(customDeltaInput.c).add(BigDecimal.valueOf(d)).doubleValue(), customDeltaInput.d, customDeltaInput.b));
Sts sts = customDeltaInput.e;
if (sts != null) {
sts.j();
}
customDeltaInput.inputValue.requestFocus();
}
public static /* synthetic */ void a(CustomDeltaInput customDeltaInput, double d) {
customDeltaInput.setActualValue(C6583cXR.c(BigDecimal.valueOf(customDeltaInput.c).subtract(BigDecimal.valueOf(d)).doubleValue(), customDeltaInput.d, customDeltaInput.b));
Sts sts = customDeltaInput.e;
if (sts != null) {
sts.h();
}
customDeltaInput.inputValue.requestFocus();
}
public static /* synthetic */ void b(CustomDeltaInput customDeltaInput) {
customDeltaInput.limitMessage.setFocusable(true);
customDeltaInput.limitMessage.setFocusableInTouchMode(true);
customDeltaInput.limitMessage.requestFocus();
RVV rvv = customDeltaInput.a;
if (rvv != null) {
double d = customDeltaInput.c;
if (!customDeltaInput.e()) {
customDeltaInput.errorMessage.setVisibility(0);
} else {
customDeltaInput.errorMessage.setVisibility(8);
}
rvv.aP_();
}
}
public static /* synthetic */ void aoE_(CustomDeltaInput customDeltaInput, boolean z, View.OnFocusChangeListener onFocusChangeListener, View view, boolean z2) {
AmountEditText amountEditText = (AmountEditText) view;
if (z && !z2 && amountEditText.getText().toString().isEmpty()) {
amountEditText.removeTextChangedListener(customDeltaInput.j);
customDeltaInput.setActualValue(customDeltaInput.d);
amountEditText.addTextChangedListener(customDeltaInput.j);
}
if (onFocusChangeListener != null) {
onFocusChangeListener.onFocusChange(view, z2);
}
}
public static /* synthetic */ boolean b(CustomDeltaInput customDeltaInput, int i) {
if (i != 6) {
return false;
}
C6583cXR.d(customDeltaInput);
customDeltaInput.limitMessage.setFocusable(true);
customDeltaInput.limitMessage.setFocusableInTouchMode(true);
customDeltaInput.limitMessage.requestFocus();
LWm lWm = customDeltaInput.g;
if (lWm != null) {
double d = customDeltaInput.c;
if (!customDeltaInput.e()) {
customDeltaInput.errorMessage.setVisibility(0);
} else {
customDeltaInput.errorMessage.setVisibility(8);
}
lWm.b();
}
return true;
}
public void setOnValueChangedListener(HBt hBt) {
this.f = hBt;
}
public void setOnKeyboardDoneListener(LWm lWm) {
this.g = lWm;
}
public void setOnIncrementChangeListener(Sts sts) {
this.e = sts;
}
public void setOnDismissKeyboardListener(RVV rvv) {
this.a = rvv;
}
public void setMinValue(double d) {
this.d = d;
}
public void setMaxValue(double d) {
this.b = d;
}
public void setActualValueOnly(double d) {
this.c = d;
}
public final double d() {
return this.d;
}
public final double b() {
return this.b;
}
}