what-the-bank/sources/com/scb/phone/view/custom/easycash/CustomDeltaSlider.java

348 lines
11 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.scb.phone.view.custom.easycash;
import android.content.Context;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatSeekBar;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.scb.phone.R;
import com.scb.phone.view.custom.ScbTextInputLayout;
import com.scb.phone.view.custom.common.AmountEditText;
import com.scb.phone.view.custom.easycash.CustomDeltaSlider;
import o.C6583cXR;
import o.IS;
import o.nMh;
/* loaded from: classes5.dex */
public class CustomDeltaSlider extends RelativeLayout implements AmountEditText.RVV {
protected HBt a;
int b;
public int c;
int d;
@BindView
ImageButton decreaseButton;
private double e;
@BindView
AmountEditText etCustomAmount;
private int f;
private boolean g;
private double i;
@BindView
ImageButton increaseButton;
private boolean j;
@BindView
TextView maxValueLabel;
@BindView
TextView minValueLabel;
@BindView
AppCompatSeekBar slider;
@BindView
ScbTextInputLayout stilCustomAmount;
@BindView
TextView valueLabel;
/* loaded from: classes5.dex */
public interface HBt {
void b(double d);
void c(double d);
void d(double d);
}
public CustomDeltaSlider(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.g = false;
this.j = true;
this.e = 0.0d;
this.i = 0.0d;
((LayoutInflater) context.getSystemService("layout_inflater")).inflate(R.layout.2131558990, (ViewGroup) this, true);
ButterKnife.c(this);
setBackgroundResource(R.drawable.bg_white_with_border);
}
public CustomDeltaSlider(Context context) {
this(context, (AttributeSet) null);
}
public CustomDeltaSlider(Context context, byte b) {
this(context);
this.j = false;
}
public final void b(IS is, HBt hBt) {
d(is, hBt, false);
}
public void setUpEditFieldOnFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener) {
this.etCustomAmount.setOnFocusChangeListener(onFocusChangeListener);
}
@Override // android.view.View
protected Parcelable onSaveInstanceState() {
return super.onSaveInstanceState();
}
protected void c(final int i) {
this.increaseButton.setOnClickListener(new View.OnClickListener(this, i) { // from class: o.eCQ
private int a;
private CustomDeltaSlider d;
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
CustomDeltaSlider.c(this.d, this.a);
}
{
this.d = this;
this.a = i;
}
});
this.decreaseButton.setOnClickListener(new View.OnClickListener(this, i) { // from class: o.eCR
private CustomDeltaSlider b;
private int e;
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
CustomDeltaSlider.a(this.b, this.e);
}
{
this.b = this;
this.e = i;
}
});
}
/* JADX INFO: Access modifiers changed from: protected */
public final int c() {
return ((int) Math.ceil(this.e / this.f)) * this.f;
}
private void d() {
double d = this.etCustomAmount.isFocused() ? this.e : this.c;
if (d <= this.d && this.decreaseButton.isEnabled()) {
this.decreaseButton.setEnabled(false);
}
if (d >= this.b && this.increaseButton.isEnabled()) {
this.increaseButton.setEnabled(false);
}
if (d > this.d && !this.decreaseButton.isEnabled()) {
this.decreaseButton.setEnabled(true);
}
if (d >= this.b || this.increaseButton.isEnabled()) {
return;
}
this.increaseButton.setEnabled(true);
}
public void setNewActualValue(int i) {
if (TextUtils.isEmpty(this.etCustomAmount.getText())) {
i = (int) this.i;
}
e(C6583cXR.e(i, this.d, this.b));
if (this.d == this.b) {
this.slider.setEnabled(false);
AppCompatSeekBar appCompatSeekBar = this.slider;
appCompatSeekBar.setProgress(appCompatSeekBar.getMax());
} else {
this.slider.setEnabled(true);
AppCompatSeekBar appCompatSeekBar2 = this.slider;
double d = this.d;
appCompatSeekBar2.setProgress((int) (((i - d) / (this.b - d)) * 100.0d));
}
}
/* JADX INFO: Access modifiers changed from: private */
public void e(int i) {
this.c = i;
double d = i;
this.valueLabel.setText((String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()));
this.etCustomAmount.setFormattedAmount((String) C6583cXR.c(new Object[]{Double.valueOf(d)}, -150997759, 150997764, (int) System.currentTimeMillis()));
d();
}
public void setSliderListener(HBt hBt) {
this.slider.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(this, hBt) { // from class: com.scb.phone.view.custom.easycash.CustomDeltaSlider.5
private HBt d;
private CustomDeltaSlider e;
{
this.e = this;
this.d = hBt;
}
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public final void onProgressChanged(SeekBar seekBar, int i, boolean z) {
if (this.e.g) {
int i2 = this.e.d;
int round = Math.round(i * ((this.e.b - this.e.d) / 100.0f));
int e = CustomDeltaSlider.e(this.e, Math.round((i2 + round) / r5.f) * this.e.f);
this.e.e(e);
this.d.d(e);
}
}
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public final void onStartTrackingTouch(SeekBar seekBar) {
this.e.g = true;
}
@Override // android.widget.SeekBar.OnSeekBarChangeListener
public final void onStopTrackingTouch(SeekBar seekBar) {
this.e.g = false;
this.d.b(this.e.c);
}
});
}
public void setDelta(int i) {
this.f = i;
c(i);
}
public void setMinValue(int i) {
this.d = i;
TextView textView = this.minValueLabel;
if (this.j) {
textView.setText((String) C6583cXR.c(new Object[]{Double.valueOf(i)}, -150997759, 150997764, (int) System.currentTimeMillis()));
} else {
textView.setText(C6583cXR.b(i));
}
}
public void setMaxValue(int i) {
this.b = i;
TextView textView = this.maxValueLabel;
if (this.j) {
textView.setText((String) C6583cXR.c(new Object[]{Double.valueOf(i)}, -150997759, 150997764, (int) System.currentTimeMillis()));
} else {
textView.setText(C6583cXR.b(i));
}
}
public void setEnable(boolean z) {
this.decreaseButton.setEnabled(z);
this.increaseButton.setEnabled(z);
this.slider.setEnabled(z);
if (z) {
this.decreaseButton.setAlpha(1.0f);
this.increaseButton.setAlpha(1.0f);
this.slider.setAlpha(1.0f);
} else {
this.decreaseButton.setColorFilter(nMh.getColor(getContext(), R.color.f13682131100876));
this.decreaseButton.setAlpha(0.4f);
this.increaseButton.setColorFilter(nMh.getColor(getContext(), R.color.f13682131100876));
this.increaseButton.setAlpha(0.4f);
this.slider.setAlpha(0.4f);
}
d();
}
@Override // com.scb.phone.view.custom.common.AmountEditText.RVV
public final void b(double d) {
this.e = d;
d();
}
@Override // com.scb.phone.view.custom.common.AmountEditText.RVV
public final void a() {
setNewActualValue((int) (Math.ceil(this.e / this.f) * this.f));
this.a.b(this.c);
C6583cXR.d(this);
}
public static /* synthetic */ void a(CustomDeltaSlider customDeltaSlider, int i) {
customDeltaSlider.setNewActualValue((((int) Math.ceil(customDeltaSlider.e / customDeltaSlider.f)) * customDeltaSlider.f) - i);
C6583cXR.d(customDeltaSlider);
customDeltaSlider.etCustomAmount.clearFocus();
customDeltaSlider.a.b(customDeltaSlider.c);
}
public static /* synthetic */ void c(CustomDeltaSlider customDeltaSlider, int i) {
customDeltaSlider.setNewActualValue((((int) Math.ceil(customDeltaSlider.e / customDeltaSlider.f)) * customDeltaSlider.f) + i);
C6583cXR.d(customDeltaSlider);
customDeltaSlider.etCustomAmount.clearFocus();
customDeltaSlider.a.b(customDeltaSlider.c);
}
static /* bridge */ /* synthetic */ int e(CustomDeltaSlider customDeltaSlider, int i) {
int i2 = customDeltaSlider.b;
if (i > i2) {
return i2;
}
int i3 = customDeltaSlider.d;
return i < i3 ? i3 : i;
}
public final void d(IS is, HBt hBt, boolean z) {
int i = (int) is.a;
int i2 = (int) is.b;
double c = C6583cXR.c(is.c, i, i2);
this.a = new HBt(this, hBt) { // from class: com.scb.phone.view.custom.easycash.CustomDeltaSlider.4
private HBt d;
private CustomDeltaSlider e;
{
this.e = this;
this.d = hBt;
}
@Override // com.scb.phone.view.custom.easycash.CustomDeltaSlider.HBt
public final void b(double d) {
this.d.b(d);
}
@Override // com.scb.phone.view.custom.easycash.CustomDeltaSlider.HBt
public final void c(double d) {
this.d.c(d);
}
@Override // com.scb.phone.view.custom.easycash.CustomDeltaSlider.HBt
public final void d(double d) {
CustomDeltaSlider customDeltaSlider = this.e;
C6583cXR.d(customDeltaSlider);
customDeltaSlider.etCustomAmount.clearFocus();
this.d.d(d);
}
};
this.e = c;
this.i = c;
setMinValue(i);
setMaxValue(i2);
this.slider.setMax(100);
setNewActualValue((int) c);
setDelta((int) is.d);
setSliderListener(this.a);
d();
this.a.c(this.c);
this.stilCustomAmount.setHint("");
this.etCustomAmount.setCustomHint("");
if (z) {
this.valueLabel.setVisibility(8);
this.stilCustomAmount.setVisibility(0);
} else {
this.valueLabel.setVisibility(0);
this.stilCustomAmount.setVisibility(8);
}
this.etCustomAmount.setOnAmountChangeListener(this);
}
}