package o; import android.text.Editable; import android.text.Selection; import android.text.Spannable; import android.text.TextWatcher; import android.widget.EditText; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import o.C16349neT; /* loaded from: classes.dex */ final class sUH implements TextWatcher { private final boolean b; C16349neT.IeS c; final EditText e; private int f = Integer.MAX_VALUE; private int a = 0; boolean d = true; @Override // android.text.TextWatcher public final void afterTextChanged(Editable editable) { } @Override // android.text.TextWatcher public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } /* JADX INFO: Access modifiers changed from: package-private */ public sUH(EditText editText, boolean z) { this.e = editText; this.b = z; } @Override // android.text.TextWatcher public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { if (this.e.isInEditMode() || !this.d) { return; } if ((this.b || C16349neT.b()) && i2 <= i3 && (charSequence instanceof Spannable)) { int a = C16349neT.e().a(); if (a != 0) { if (a == 1) { C16349neT.e().e((Spannable) charSequence, i, i + i3, this.f, this.a); return; } else if (a != 3) { return; } } C16349neT e = C16349neT.e(); if (this.c == null) { this.c = new HBt(this.e); } e.c(this.c); } } /* loaded from: classes.dex */ static class HBt extends C16349neT.IeS { private final Reference e; HBt(EditText editText) { this.e = new WeakReference(editText); } @Override // o.C16349neT.IeS public final void b() { super.b(); sUH.yf_(this.e.get(), 1); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void yf_(EditText editText, int i) { if (i == 1 && editText != null && editText.isAttachedToWindow()) { Editable editableText = editText.getEditableText(); int selectionStart = Selection.getSelectionStart(editableText); int selectionEnd = Selection.getSelectionEnd(editableText); C16349neT.e().b(editableText); lHn.xS_(editableText, selectionStart, selectionEnd); } } }