package com.scb.phone.view.custom.common; import android.content.Context; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.View; import o.fJJ; /* loaded from: classes5.dex */ public class DateInputText extends ClearableEditText { private Sts c; private TextWatcher d; /* loaded from: classes5.dex */ public interface Sts { void c(String str); } public DateInputText(Context context) { super(context); this.d = new fJJ(this) { // from class: com.scb.phone.view.custom.common.DateInputText.5 private DateInputText d; { this.d = this; } @Override // o.fJJ, android.text.TextWatcher public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { StringBuilder sb = new StringBuilder(charSequence.toString().replaceAll("\\D+", "")); int i4 = i + i3; if (sb.length() > 2) { sb.insert(2, "/"); if (i == 2 && i3 > 0) { i4 += i3; } if (sb.length() > 5) { sb.insert(5, "/"); if (i == 5 && i3 > 0) { i4 += i3; } } } this.d.inputEditText.removeTextChangedListener(this); this.d.setText(sb.toString()); this.d.inputEditText.addTextChangedListener(this); this.d.setSelection(Math.min(i4, sb.length())); if (this.d.c != null) { this.d.c.c(this.d.inputEditText.getText().toString()); } } }; setInputType(4); setMaxLength(10); setDigitsFilter("0123456789/"); this.inputEditText.addTextChangedListener(this.d); } public DateInputText(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.d = new fJJ(this) { // from class: com.scb.phone.view.custom.common.DateInputText.5 private DateInputText d; { this.d = this; } @Override // o.fJJ, android.text.TextWatcher public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { StringBuilder sb = new StringBuilder(charSequence.toString().replaceAll("\\D+", "")); int i4 = i + i3; if (sb.length() > 2) { sb.insert(2, "/"); if (i == 2 && i3 > 0) { i4 += i3; } if (sb.length() > 5) { sb.insert(5, "/"); if (i == 5 && i3 > 0) { i4 += i3; } } } this.d.inputEditText.removeTextChangedListener(this); this.d.setText(sb.toString()); this.d.inputEditText.addTextChangedListener(this); this.d.setSelection(Math.min(i4, sb.length())); if (this.d.c != null) { this.d.c.c(this.d.inputEditText.getText().toString()); } } }; setInputType(4); setMaxLength(10); setDigitsFilter("0123456789/"); this.inputEditText.addTextChangedListener(this.d); } public DateInputText(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.d = new fJJ(this) { // from class: com.scb.phone.view.custom.common.DateInputText.5 private DateInputText d; { this.d = this; } @Override // o.fJJ, android.text.TextWatcher public final void onTextChanged(CharSequence charSequence, int i2, int i22, int i3) { StringBuilder sb = new StringBuilder(charSequence.toString().replaceAll("\\D+", "")); int i4 = i2 + i3; if (sb.length() > 2) { sb.insert(2, "/"); if (i2 == 2 && i3 > 0) { i4 += i3; } if (sb.length() > 5) { sb.insert(5, "/"); if (i2 == 5 && i3 > 0) { i4 += i3; } } } this.d.inputEditText.removeTextChangedListener(this); this.d.setText(sb.toString()); this.d.inputEditText.addTextChangedListener(this); this.d.setSelection(Math.min(i4, sb.length())); if (this.d.c != null) { this.d.c.c(this.d.inputEditText.getText().toString()); } } }; setInputType(4); setMaxLength(10); setDigitsFilter("0123456789/"); this.inputEditText.addTextChangedListener(this.d); } public void setOnEditTextClickListener(View.OnClickListener onClickListener) { this.inputEditText.setOnClickListener(onClickListener); } public void setDateUpdatedListener(Sts sts) { this.c = sts; } }