110 lines
3.8 KiB
Java
110 lines
3.8 KiB
Java
package com.scb.phone.view.custom.common;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.text.Editable;
|
|
import android.text.InputFilter;
|
|
import android.text.TextWatcher;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.ViewGroup;
|
|
import android.widget.EditText;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import butterknife.BindView;
|
|
import butterknife.ButterKnife;
|
|
import butterknife.OnClick;
|
|
import com.scb.phone.R;
|
|
import o.C15715hv;
|
|
import o.nMh;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public class CounterEditText extends RelativeLayout {
|
|
private DefaultButton a;
|
|
private int b;
|
|
private final TextWatcher c;
|
|
|
|
@BindView
|
|
public EditText editText;
|
|
|
|
@BindView
|
|
public TextView errorText;
|
|
|
|
@BindView
|
|
TextView textCounter;
|
|
|
|
@BindView
|
|
TextView titleText;
|
|
|
|
public CounterEditText(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public CounterEditText(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, 0);
|
|
}
|
|
|
|
public CounterEditText(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.b = 20;
|
|
TextWatcher textWatcher = new TextWatcher(this) { // from class: com.scb.phone.view.custom.common.CounterEditText.1
|
|
private CounterEditText d;
|
|
|
|
@Override // android.text.TextWatcher
|
|
public final void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public final void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
}
|
|
|
|
{
|
|
this.d = this;
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public final void afterTextChanged(Editable editable) {
|
|
this.d.textCounter.setText(this.d.getContext().getString(R.string.text_counter, Integer.valueOf(editable.length()), Integer.valueOf(this.d.b)));
|
|
CounterEditText counterEditText = this.d;
|
|
counterEditText.errorText.setVisibility(4);
|
|
counterEditText.editText.setBackground(nMh.getDrawable(counterEditText.getContext(), R.drawable.shape_gray_rounded_rectangle));
|
|
if (this.d.a != null) {
|
|
this.d.a.setButtonEnabled(editable.length() > 0 && editable.length() <= this.d.b);
|
|
}
|
|
}
|
|
};
|
|
this.c = textWatcher;
|
|
LayoutInflater.from(getContext()).inflate(R.layout.2131558859, (ViewGroup) this, true);
|
|
ButterKnife.c(this);
|
|
if (attributeSet != null) {
|
|
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(attributeSet, C15715hv.jbe.CustomCounterEditText, 0, 0);
|
|
try {
|
|
this.b = obtainStyledAttributes.getInteger(0, 20);
|
|
this.titleText.setText(obtainStyledAttributes.getString(2));
|
|
this.editText.setHint(obtainStyledAttributes.getString(1));
|
|
if (this.b > 0) {
|
|
this.editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(this.b)});
|
|
}
|
|
} finally {
|
|
obtainStyledAttributes.recycle();
|
|
}
|
|
}
|
|
this.textCounter.setText(getContext().getString(R.string.text_counter, 0, Integer.valueOf(this.b)));
|
|
this.editText.removeTextChangedListener(textWatcher);
|
|
this.editText.addTextChangedListener(textWatcher);
|
|
}
|
|
|
|
public void setText(String str) {
|
|
this.editText.setText(str);
|
|
}
|
|
|
|
@OnClick
|
|
public void onClickClear() {
|
|
this.editText.setText("");
|
|
}
|
|
|
|
public void setDefaultButton(DefaultButton defaultButton) {
|
|
this.a = defaultButton;
|
|
}
|
|
}
|