167 lines
4.9 KiB
Java
167 lines
4.9 KiB
Java
package com.ubt.jimu.controller.component;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Rect;
|
|
import android.graphics.RectF;
|
|
import android.text.TextUtils;
|
|
import android.util.AttributeSet;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.controller.util.ScreenUtil;
|
|
import com.ubt.jimu.controller.view.control.SuperControlView;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DeleteView extends SuperControlView {
|
|
private Context B;
|
|
private float C;
|
|
private float D;
|
|
private float E;
|
|
private RectF F;
|
|
private RectF G;
|
|
private Paint H;
|
|
private Paint I;
|
|
private Bitmap J;
|
|
private Bitmap K;
|
|
private Paint L;
|
|
private boolean M;
|
|
private RectF N;
|
|
private String O;
|
|
private boolean P;
|
|
private DeleteViewAnimatorListener Q;
|
|
|
|
public interface DeleteViewAnimatorListener {
|
|
void a();
|
|
}
|
|
|
|
public DeleteView(Context context) {
|
|
super(context);
|
|
this.C = 0.0f;
|
|
this.P = false;
|
|
this.B = context;
|
|
j();
|
|
}
|
|
|
|
private void i() {
|
|
int a = ScreenUtil.a(this.B);
|
|
this.E = this.B.getResources().getDimension(R.dimen.grid_view_width) * 2.0f;
|
|
this.D = this.B.getResources().getDimension(R.dimen.grid_view_width) * 2.0f;
|
|
this.H = new Paint();
|
|
this.I = new Paint();
|
|
this.I.setAlpha(190);
|
|
this.I.setFlags(3);
|
|
this.H.setAntiAlias(true);
|
|
this.H.setColor(this.B.getResources().getColor(R.color.color_F6B8D4));
|
|
this.L = new Paint();
|
|
this.L.setColor(this.B.getResources().getColor(R.color.bg_aaFFFFFF));
|
|
this.L.setTextSize(this.B.getResources().getDimension(R.dimen.txt_title_1));
|
|
this.F = new RectF(this.C, -this.D, a, 0.0f);
|
|
this.J = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.recycle_close);
|
|
this.K = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.recycle_open);
|
|
this.F.centerX();
|
|
this.F.centerY();
|
|
float f = this.C;
|
|
float f2 = this.D;
|
|
this.G = new RectF(f, -f2, f2 + f, 0.0f);
|
|
this.N = new RectF();
|
|
}
|
|
|
|
private void j() {
|
|
}
|
|
|
|
public void a(String str) {
|
|
if (this.M) {
|
|
this.O = str;
|
|
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
|
RectF rectF = this.G;
|
|
float f = this.E;
|
|
rectF.set(0.0f, 0.0f, f, f);
|
|
RectF rectF2 = this.N;
|
|
float f2 = this.E;
|
|
rectF2.set(f2 / 1.2f, f2 / 3.5f, f2, f2);
|
|
invalidate();
|
|
}
|
|
}
|
|
|
|
public void f() {
|
|
if (this.M) {
|
|
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
|
RectF rectF = this.G;
|
|
float f = this.E;
|
|
rectF.set(0.0f, 0.0f, f, f);
|
|
}
|
|
this.N.set(-10.0f, -10.0f, -10.0f, -10.0f);
|
|
this.O = "";
|
|
invalidate();
|
|
}
|
|
|
|
public void g() {
|
|
if (this.M) {
|
|
f();
|
|
this.F.set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
this.G.set(0.0f, 0.0f, 0.0f, 0.0f);
|
|
invalidate();
|
|
DeleteViewAnimatorListener deleteViewAnimatorListener = this.Q;
|
|
if (deleteViewAnimatorListener != null) {
|
|
deleteViewAnimatorListener.a();
|
|
}
|
|
this.M = false;
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
|
public RectF getDeleteViewRectF() {
|
|
return this.F;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.SuperControlView
|
|
public float[] getViewCenterXY() {
|
|
return new float[0];
|
|
}
|
|
|
|
public void h() {
|
|
if (this.M) {
|
|
return;
|
|
}
|
|
this.F.set(0.0f, 0.0f, ScreenUtil.a(this.B), this.D);
|
|
RectF rectF = this.G;
|
|
float f = this.E;
|
|
rectF.set(0.0f, 0.0f, f, f);
|
|
invalidate();
|
|
this.M = true;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
|
|
protected void onDraw(Canvas canvas) {
|
|
canvas.drawRect(this.F, this.H);
|
|
if (this.P) {
|
|
canvas.drawBitmap(this.K, (Rect) null, this.G, this.I);
|
|
} else {
|
|
canvas.drawBitmap(this.J, (Rect) null, this.G, this.I);
|
|
}
|
|
if (!TextUtils.isEmpty(this.O)) {
|
|
canvas.drawText(this.O, this.N.centerX(), this.N.centerY(), this.L);
|
|
}
|
|
super.onDraw(canvas);
|
|
}
|
|
|
|
public void setDeleteViewAnimatorListener(DeleteViewAnimatorListener deleteViewAnimatorListener) {
|
|
this.Q = deleteViewAnimatorListener;
|
|
}
|
|
|
|
public void setOverlapState(boolean z) {
|
|
this.P = z;
|
|
}
|
|
|
|
public DeleteView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.C = 0.0f;
|
|
this.P = false;
|
|
this.B = context;
|
|
j();
|
|
i();
|
|
}
|
|
}
|