package com.ubt.jimu.widgets; import android.annotation.SuppressLint; import android.content.Context; import android.content.res.TypedArray; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.text.Editable; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.EditText; import com.ubt.jimu.R; import com.ubt.jimu.R$styleable; @SuppressLint({"AppCompatCustomView"}) /* loaded from: classes2.dex */ public class EditTextWithDel extends EditText { private Context a; private Drawable b; public EditTextWithDel(Context context) { this(context, null); } @Override // android.widget.TextView, android.view.View public boolean onTouchEvent(MotionEvent motionEvent) { if (this.b != null && motionEvent.getAction() == 1) { int x = (int) motionEvent.getX(); int y = (int) motionEvent.getY(); Rect rect = new Rect(); rect.right = getMeasuredWidth() - getPaddingRight(); rect.bottom = getMeasuredHeight() - getPaddingBottom(); rect.left = rect.right - this.b.getIntrinsicWidth(); rect.top = getPaddingTop(); if (rect.contains(x, y)) { setText(""); } } return super.onTouchEvent(motionEvent); } public EditTextWithDel(Context context, AttributeSet attributeSet) { super(context, attributeSet); this.a = context; a(attributeSet); } private void a(AttributeSet attributeSet) { TypedArray obtainStyledAttributes = this.a.obtainStyledAttributes(attributeSet, R$styleable.EditTextWithDel); this.b = this.a.getResources().getDrawable(R.drawable.ic_edit_delete); obtainStyledAttributes.getDimension(0, 20.0f); addTextChangedListener(new TextWatcher() { // from class: com.ubt.jimu.widgets.EditTextWithDel.1 @Override // android.text.TextWatcher public void afterTextChanged(Editable editable) { EditTextWithDel.this.a(); } @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) { } }); a(); } public EditTextWithDel(Context context, AttributeSet attributeSet, int i) { this(context, attributeSet); } /* JADX INFO: Access modifiers changed from: private */ public void a() { post(new Runnable() { // from class: com.ubt.jimu.widgets.EditTextWithDel.2 @Override // java.lang.Runnable public void run() { int measuredHeight = (EditTextWithDel.this.getMeasuredHeight() * 3) / 4; EditTextWithDel.this.b.setBounds(0, 0, measuredHeight, measuredHeight); Drawable[] compoundDrawables = EditTextWithDel.this.getCompoundDrawables(); if (EditTextWithDel.this.length() < 1) { EditTextWithDel.this.setCompoundDrawables(compoundDrawables[0], compoundDrawables[1], null, compoundDrawables[3]); } else { EditTextWithDel editTextWithDel = EditTextWithDel.this; editTextWithDel.setCompoundDrawables(compoundDrawables[0], compoundDrawables[1], editTextWithDel.b, compoundDrawables[3]); } } }); } }