discord-jadx/app/src/main/java/c/i/a/g/j/a.java

192 lines
6.8 KiB
Java

package c.i.a.g.j;
import android.animation.AnimatorSet;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import com.google.android.material.R;
import com.google.android.material.animation.AnimationUtils;
import com.google.android.material.textfield.TextInputLayout;
/* compiled from: ClearTextEndIconDelegate */
public class a extends m {
public final TextWatcher d = new C0116a();
public final View.OnFocusChangeListener e = new b();
public final TextInputLayout.OnEditTextAttachedListener f = new c();
public final TextInputLayout.OnEndIconChangedListener g = new d();
public AnimatorSet h;
public ValueAnimator i;
/* compiled from: ClearTextEndIconDelegate */
/* renamed from: c.i.a.g.j.a$a reason: collision with other inner class name */
public class C0116a implements TextWatcher {
public C0116a() {
}
@Override // android.text.TextWatcher
public void afterTextChanged(@NonNull Editable editable) {
if (a.this.a.getSuffixText() == null) {
a.this.d(editable.length() > 0);
}
}
@Override // android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override // android.text.TextWatcher
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
}
/* compiled from: ClearTextEndIconDelegate */
public class b implements View.OnFocusChangeListener {
public b() {
}
@Override // android.view.View.OnFocusChangeListener
public void onFocusChange(View view, boolean z2) {
boolean z3 = true;
boolean z4 = !TextUtils.isEmpty(((EditText) view).getText());
a aVar = a.this;
if (!z4 || !z2) {
z3 = false;
}
aVar.d(z3);
}
}
/* compiled from: ClearTextEndIconDelegate */
public class c implements TextInputLayout.OnEditTextAttachedListener {
public c() {
}
/* JADX WARNING: Code restructure failed: missing block: B:6:0x0019, code lost:
if ((r0.getText().length() > 0) != false) goto L_0x001d;
*/
@Override // com.google.android.material.textfield.TextInputLayout.OnEditTextAttachedListener
public void onEditTextAttached(@NonNull TextInputLayout textInputLayout) {
EditText editText = textInputLayout.getEditText();
boolean z2 = true;
if (editText.hasFocus()) {
}
z2 = false;
textInputLayout.setEndIconVisible(z2);
textInputLayout.setEndIconCheckable(false);
editText.setOnFocusChangeListener(a.this.e);
editText.removeTextChangedListener(a.this.d);
editText.addTextChangedListener(a.this.d);
}
}
/* compiled from: ClearTextEndIconDelegate */
public class d implements TextInputLayout.OnEndIconChangedListener {
/* compiled from: ClearTextEndIconDelegate */
/* renamed from: c.i.a.g.j.a$d$a reason: collision with other inner class name */
public class RunnableC0117a implements Runnable {
public final /* synthetic */ EditText i;
public RunnableC0117a(EditText editText) {
this.i = editText;
}
@Override // java.lang.Runnable
public void run() {
this.i.removeTextChangedListener(a.this.d);
}
}
public d() {
}
@Override // com.google.android.material.textfield.TextInputLayout.OnEndIconChangedListener
public void onEndIconChanged(@NonNull TextInputLayout textInputLayout, int i) {
EditText editText = textInputLayout.getEditText();
if (editText != null && i == 2) {
editText.post(new RunnableC0117a(editText));
if (editText.getOnFocusChangeListener() == a.this.e) {
editText.setOnFocusChangeListener(null);
}
}
}
}
/* compiled from: ClearTextEndIconDelegate */
public class e implements View.OnClickListener {
public e() {
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
Editable text = a.this.a.getEditText().getText();
if (text != null) {
text.clear();
}
a.this.a.refreshEndIconDrawableState();
}
}
public a(@NonNull TextInputLayout textInputLayout) {
super(textInputLayout);
}
@Override // c.i.a.g.j.m
public void a() {
this.a.setEndIconDrawable(AppCompatResources.getDrawable(this.b, R.drawable.mtrl_ic_cancel));
TextInputLayout textInputLayout = this.a;
textInputLayout.setEndIconContentDescription(textInputLayout.getResources().getText(R.string.clear_text_end_icon_content_description));
this.a.setEndIconOnClickListener(new e());
this.a.addOnEditTextAttachedListener(this.f);
this.a.addOnEndIconChangedListener(this.g);
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.8f, 1.0f);
ofFloat.setInterpolator(AnimationUtils.LINEAR_OUT_SLOW_IN_INTERPOLATOR);
ofFloat.setDuration(150L);
ofFloat.addUpdateListener(new e(this));
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(0.0f, 1.0f);
TimeInterpolator timeInterpolator = AnimationUtils.LINEAR_INTERPOLATOR;
ofFloat2.setInterpolator(timeInterpolator);
ofFloat2.setDuration(100L);
ofFloat2.addUpdateListener(new d(this));
AnimatorSet animatorSet = new AnimatorSet();
this.h = animatorSet;
animatorSet.playTogether(ofFloat, ofFloat2);
this.h.addListener(new b(this));
ValueAnimator ofFloat3 = ValueAnimator.ofFloat(1.0f, 0.0f);
ofFloat3.setInterpolator(timeInterpolator);
ofFloat3.setDuration(100L);
ofFloat3.addUpdateListener(new d(this));
this.i = ofFloat3;
ofFloat3.addListener(new c(this));
}
@Override // c.i.a.g.j.m
public void c(boolean z2) {
if (this.a.getSuffixText() != null) {
d(z2);
}
}
public final void d(boolean z2) {
boolean z3 = this.a.isEndIconVisible() == z2;
if (z2 && !this.h.isRunning()) {
this.i.cancel();
this.h.start();
if (z3) {
this.h.end();
}
} else if (!z2) {
this.h.cancel();
this.i.start();
if (z3) {
this.i.end();
}
}
}
}