package o; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.EditText; import o.fLJ; /* loaded from: classes5.dex */ public final class fLJ implements TextWatcher { private EditText a; public IeS b; private String c; String d = ""; public boolean e; private Sts f; /* loaded from: classes5.dex */ public interface IeS { void b(String str); void e(String str); } /* loaded from: classes5.dex */ public interface Sts { String c(String str); } @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) { } public fLJ(EditText editText, String str, Sts sts) { this.a = editText; this.c = str; this.f = sts; editText.setOnFocusChangeListener(new View.OnFocusChangeListener(this) { // from class: o.fLQ private fLJ b; @Override // android.view.View.OnFocusChangeListener public final void onFocusChange(View view, boolean z) { fLJ.IeS ieS; fLJ.IeS ieS2; fLJ flj = this.b; if (!z && (ieS2 = flj.b) != null) { ieS2.b(flj.d); } else if (z && flj.e && (ieS = flj.b) != null) { ieS.e(flj.d); } } { this.b = this; } }); } @Override // android.text.TextWatcher public final void afterTextChanged(Editable editable) { String str; this.a.removeTextChangedListener(this); String obj = editable.toString(); String c = this.f.c(obj); if (obj.length() > this.c.length() || ((str = this.d) != null && str.equals(c))) { editable.replace(0, editable.length(), this.d); this.a.addTextChangedListener(this); return; } editable.replace(0, editable.length(), c); this.d = editable.toString(); this.a.addTextChangedListener(this); if (this.d.length() >= this.c.length()) { IeS ieS = this.b; if (ieS != null) { ieS.b(this.d); return; } return; } IeS ieS2 = this.b; if (ieS2 != null) { ieS2.e(this.d); } } }