Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,565 @@
package com.ubt.jimu.controller.component;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.data.widget.ActionWidgetData;
import com.ubt.jimu.controller.util.SvgUtils;
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
import com.ubt.jimu.controller.view.control.OnControllerClickListener;
import com.ubt.jimu.controller.view.control.SuperControlView;
import com.ubt.jimu.utils.LocaleUtils;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
import com.ubtrobot.log.ALog;
/* loaded from: classes.dex */
public class ActionView extends SuperControlView<ActionWidgetData> {
private Context B;
private float C;
private float D;
private Paint E;
private Paint F;
private Paint G;
private RectF H;
private RectF I;
private RectF J;
private RectF K;
private Bitmap L;
private Bitmap M;
private String N;
private Bitmap O;
private Bitmap P;
private Bitmap Q;
private Bitmap R;
private float S;
private float T;
private float U;
private float V;
private float W;
private float a0;
private ValueAnimator b0;
private float c0;
private float d0;
private int e0;
private float f0;
private float g0;
private long h0;
private long i0;
public ActionView(Context context, int i, float f, float f2) {
super(context);
this.a0 = -360.0f;
this.B = context;
this.C = f;
this.D = f2;
this.e0 = i;
j();
i();
}
private void b(float f, float f2) {
this.H.offsetTo(f, f2);
this.j.offsetTo(f, f2);
float centerX = this.H.centerX();
float centerY = this.H.centerY();
RectF rectF = this.I;
float f3 = this.f0;
rectF.offsetTo(centerX - (f3 / 2.0f), centerY - (f3 / 2.0f));
this.K.offsetTo(centerX - this.V, centerY - this.W);
}
private void g() {
OnControllerClickListener onControllerClickListener = getOnControllerClickListener();
if (onControllerClickListener == null || b()) {
return;
}
if (this.z == 0) {
long j = this.h0;
if (j - this.t > 500 || j - this.i0 < 500) {
return;
}
}
float centerY = this.H.centerY();
float centerX = this.H.centerX();
float f = this.c0;
float f2 = this.l;
if (f < centerX - (f2 / 2.0f) || f > centerX + (f2 / 2.0f)) {
return;
}
float f3 = this.d0;
float f4 = this.m;
if (f3 < centerY - (f4 / 2.0f) || f3 > centerY + (f4 / 2.0f)) {
return;
}
onControllerClickListener.a(getData(), this);
this.i0 = System.currentTimeMillis();
}
private void h() {
if (this.e0 == 0) {
this.e0 = R.drawable.icon_loudly;
}
SvgUtils a = SvgUtils.a(this.B);
int i = this.e0;
float f = this.f0;
this.L = a.a(i, (int) f, (int) f);
}
private void i() {
this.l = this.B.getResources().getDimension(R.dimen.grid_view_width) * 4.0f;
this.m = this.l;
float f = this.D;
float f2 = this.m;
float f3 = f + (f2 / 2.0f);
int i = this.s;
if (f3 >= i) {
this.D = i - (f2 / 2.0f);
}
float f4 = this.C;
float f5 = this.m;
if (f4 - (f5 / 2.0f) <= 0.0f) {
this.C = f5 / 2.0f;
} else {
float f6 = f4 + (f5 / 2.0f);
int i2 = this.r;
if (f6 >= i2) {
this.C = i2 - (f5 / 2.0f);
}
}
this.U = this.B.getResources().getDimension(R.dimen.control_action_width);
this.f0 = this.B.getResources().getDimension(R.dimen.control_action_width);
this.g0 = this.B.getResources().getDimension(R.dimen.control_action_text_width);
h();
this.O = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.btn_shadow);
this.R = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.text_background_normal);
this.Q = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.text_background_pressed);
this.P = this.R;
this.E = new Paint();
this.E.setFlags(3);
this.F = new Paint();
this.G = new Paint();
this.F.setAntiAlias(true);
this.F.setColor(this.B.getResources().getColor(R.color.bg_C9EBFE));
this.G.setColor(this.B.getResources().getColor(R.color.bg_FFFFFF));
float f7 = this.C;
float f8 = this.l;
float f9 = this.D;
float f10 = this.m;
this.j = new RectF(f7 - (f8 / 2.0f), f9 - (f10 / 2.0f), f7 + (f8 / 2.0f), f9 + (f10 / 2.0f));
float f11 = this.C;
float f12 = this.l;
float f13 = this.D;
float f14 = this.m;
this.H = new RectF(f11 - (f12 / 2.0f), f13 - (f14 / 2.0f), f11 + (f12 / 2.0f), f13 + (f14 / 2.0f));
this.V = this.B.getResources().getDimension(R.dimen.control_action_text_x_offset);
this.W = this.B.getResources().getDimension(R.dimen.control_action_text_y_offset);
float[] viewCenterXY = getViewCenterXY();
this.K = new RectF(viewCenterXY[0] - this.V, viewCenterXY[1] - this.W, this.C + (this.l / 2.0f), this.D + (this.m / 2.0f));
this.J = new RectF();
float f15 = this.C;
float f16 = this.f0;
float f17 = this.D;
this.I = new RectF(f15 - (f16 / 2.0f), f17 - (f16 / 2.0f), f15 + (f16 / 2.0f), f17 + (f16 / 2.0f));
}
private void j() {
}
public void a(int i) {
this.e0 = i;
h();
invalidate();
}
public void f() {
ALog.a("Test").d("Text:" + this.N);
this.N = null;
this.M = null;
invalidate();
}
public String getText() {
return this.N;
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public float[] getViewCenterXY() {
return new float[]{this.H.centerX(), this.H.centerY()};
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (b()) {
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
return;
}
if (getState() == 0) {
a();
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
canvas.drawArc(this.J, 270.0f, this.a0, true, this.F);
a(canvas);
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
return;
}
if (c()) {
e();
}
canvas.drawBitmap(this.O, (Rect) null, this.H, this.E);
a(canvas);
canvas.drawBitmap(this.L, (Rect) null, this.I, this.E);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int actionMasked = motionEvent.getActionMasked();
if (actionMasked == 0) {
this.t = System.currentTimeMillis();
this.c0 = motionEvent.getX();
this.d0 = motionEvent.getY();
d();
float centerX = this.H.centerX();
float centerY = this.H.centerY();
float f = this.c0;
float f2 = this.l;
if (f >= centerX - (f2 / 2.0f) && f <= (f2 / 2.0f) + centerX) {
float f3 = this.d0;
float f4 = this.m;
if (f3 >= centerY - (f4 / 2.0f) && f3 <= (f4 / 2.0f) + centerY) {
this.f = false;
setPressed(true);
if (b()) {
float centerX2 = this.j.centerX();
float centerY2 = this.j.centerY();
this.S = centerX2 - this.c0;
this.T = centerY2 - this.d0;
bringToFront();
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.a((View) this);
}
} else if (getState() == 0) {
ValueAnimator valueAnimator = this.b0;
if (valueAnimator != null) {
valueAnimator.cancel();
}
this.a0 = -360.0f;
RectF rectF = this.J;
float f5 = this.U;
rectF.set(centerX - (f5 / 2.0f), centerY - (f5 / 2.0f), centerX + (f5 / 2.0f), centerY + (f5 / 2.0f));
this.P = this.Q;
this.H.set(0.0f, 0.0f, 0.0f, 0.0f);
ControlTouchEvent controlTouchEvent2 = this.i;
if (controlTouchEvent2 != null) {
controlTouchEvent2.a((SuperControlView) this);
this.i.a(getData());
}
invalidate();
}
return true;
}
}
return super.onTouchEvent(motionEvent);
}
if (actionMasked == 1) {
setPressed(false);
if (!this.f) {
LogUtils.c("MotionEvent: 抬起");
this.f = true;
a(SuperControlView.MotionEventState.STATE_UP);
}
invalidate();
return true;
}
if (actionMasked != 2) {
if (actionMasked != 3) {
return super.onTouchEvent(motionEvent);
}
if (!this.f) {
LogUtils.c("MotionEvent取消");
this.f = true;
a(SuperControlView.MotionEventState.STATE_CANCEL);
}
return true;
}
if (b()) {
float x = motionEvent.getX();
float y = motionEvent.getY();
b(super.a(motionEvent, this.S), super.b(motionEvent, this.T));
boolean a = a(this.j);
if (this.i != null) {
if (Math.abs(this.c0 - x) <= 20.0f && Math.abs(this.d0 - y) <= 20.0f) {
return true;
}
this.i.b((View) this);
if (a) {
if (this.e != null && getData() != null) {
this.e.setOverlapState(true);
this.e.a(String.format(getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.B)));
}
b(false);
this.b.setColor(this.B.getResources().getColor(R.color.color_FF4979));
if (!this.n) {
SystemUtils.b(this.B);
this.n = true;
}
} else {
if (this.e != null && getData() != null) {
this.e.setOverlapState(false);
this.e.a(String.format(getResources().getString(R.string.control_remove_widget_here), getData().getShowName(LocaleUtils.b())));
}
RectF rectF2 = this.H;
PointF a2 = a(rectF2.left, rectF2.top);
this.k.offsetTo(a2.x, a2.y);
if (this.i.c((SuperControlView) this)) {
b(false);
this.b.setColor(this.B.getResources().getColor(R.color.bg_99B8BEC1));
} else {
b(true);
this.b.setColor(this.B.getResources().getColor(this.a));
}
this.n = false;
}
}
invalidate();
}
return true;
}
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
public Bitmap a(String str) {
char c;
switch (str.hashCode()) {
case -1721778389:
if (str.equals("DPAD_UP")) {
c = '\b';
break;
}
c = 65535;
break;
case -1067127502:
if (str.equals("DPAD_DOWN")) {
c = '\t';
break;
}
c = 65535;
break;
case -1066899305:
if (str.equals("DPAD_LEFT")) {
c = '\n';
break;
}
c = 65535;
break;
case 65:
if (str.equals("A")) {
c = 0;
break;
}
c = 65535;
break;
case 66:
if (str.equals("B")) {
c = 1;
break;
}
c = 65535;
break;
case 88:
if (str.equals("X")) {
c = 2;
break;
}
c = 65535;
break;
case 89:
if (str.equals("Y")) {
c = 3;
break;
}
c = 65535;
break;
case 2405:
if (str.equals("L1")) {
c = 4;
break;
}
c = 65535;
break;
case 2406:
if (str.equals("L2")) {
c = 5;
break;
}
c = 65535;
break;
case 2591:
if (str.equals("R1")) {
c = 6;
break;
}
c = 65535;
break;
case 2592:
if (str.equals("R2")) {
c = 7;
break;
}
c = 65535;
break;
case 1291520876:
if (str.equals("DPAD_RIGHT")) {
c = 11;
break;
}
c = 65535;
break;
default:
c = 65535;
break;
}
int i = R.drawable.ic_text_x;
switch (c) {
case 0:
i = R.drawable.ic_text_a;
break;
case 1:
i = R.drawable.ic_text_b;
break;
case 2:
break;
case 3:
i = R.drawable.ic_text_y;
break;
case 4:
i = R.drawable.ic_text_l1;
break;
case 5:
i = R.drawable.ic_text_l2;
break;
case 6:
i = R.drawable.ic_text_r1;
break;
case 7:
i = R.drawable.ic_text_r2;
break;
case '\b':
i = R.drawable.ic_text_direction_up;
break;
case '\t':
i = R.drawable.ic_text_direction_down;
break;
case '\n':
i = R.drawable.ic_text_direction_left;
break;
case 11:
i = R.drawable.ic_text_direction_right;
break;
default:
Log.e("ActionView", "Invalid text, use defaut text X");
break;
}
if (i == 0) {
return null;
}
SvgUtils a = SvgUtils.a(this.B);
float f = this.g0;
return a.a(i, (int) f, (int) f);
}
private void a(Canvas canvas) {
if (this.M != null) {
canvas.drawBitmap(this.P, (Rect) null, this.K, this.E);
canvas.drawBitmap(this.M, (Rect) null, new RectF(this.K.centerX() - (this.g0 / 2.0f), this.K.centerY() - (this.g0 / 2.0f), this.K.centerX() + (this.g0 / 2.0f), this.K.centerY() + (this.g0 / 2.0f)), this.E);
}
}
public void b(String str) {
ALog.a("Test").d("Text:" + str);
this.N = str;
if (TextUtils.isEmpty(str)) {
f();
}
this.M = a(str);
invalidate();
}
private void a(SuperControlView.MotionEventState motionEventState) {
ActionWidgetData data;
this.h0 = System.currentTimeMillis();
if (b()) {
this.S = 0.0f;
this.T = 0.0f;
if (a(this.j)) {
if (this.i != null && (data = getData()) != null) {
this.i.a(this, data.getActionID());
this.i.c((View) this);
}
invalidate();
return;
}
if (this.i != null) {
RectF rectF = this.H;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
b(this.o, this.p);
this.b.setColor(this.B.getResources().getColor(this.a));
} else {
b(a.x, a.y);
this.i.a(this, this.j.centerX(), this.j.centerY());
}
this.i.c((View) this);
if (System.currentTimeMillis() - this.t < 300) {
this.i.a(this, getData());
}
}
b(false);
return;
}
float centerX = this.I.centerX();
float centerY = this.I.centerY();
RectF rectF2 = this.H;
float f = this.l;
float f2 = this.m;
rectF2.set(centerX - (f / 2.0f), centerY - (f2 / 2.0f), centerX + (f / 2.0f), centerY + (f2 / 2.0f));
this.J.set(0.0f, 0.0f, 0.0f, 0.0f);
this.P = this.R;
int i = this.z;
if (i != 0) {
if (i != 2) {
return;
}
setSelect(true);
g();
return;
}
g();
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.b((SuperControlView) this);
this.i.a(getData(), motionEventState);
}
}
public boolean a(RectF rectF) {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, rectF);
}
}

View File

@@ -0,0 +1,785 @@
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.LinearGradient;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.utils.LogUtils;
/* loaded from: classes.dex */
public class AngleSetView extends View {
private Bitmap A;
private Bitmap B;
private Bitmap C;
private float D;
private float E;
private float F;
private boolean G;
private Paint H;
private Paint I;
private Paint J;
private Paint K;
private Paint L;
private double M;
private double N;
private float O;
private float P;
private String Q;
private String R;
private float S;
private float T;
private float U;
private float V;
private String W;
private float a;
private String a0;
private float b;
private float b0;
private float c;
private AngleUpdateListener c0;
private float d;
private boolean d0;
private float e;
private float f;
private float g;
private float h;
private float i;
private float j;
private Paint k;
private Paint l;
private Paint m;
private Paint n;
private Paint o;
private RectF p;
private RectF q;
private RectF r;
private RectF s;
private RectF t;
private RectF u;
private RectF v;
private RectF x;
private Context y;
private Bitmap z;
public interface AngleUpdateListener {
void a(double d);
void c(double d);
}
enum DataType {
MIN,
MAX
}
public AngleSetView(Context context) {
super(context);
this.h = 150.0f;
this.i = 0.0f;
this.j = 0.0f;
this.S = -118.0f;
this.T = 118.0f;
this.U = -118.0f;
this.V = 118.0f;
this.d0 = false;
this.y = context;
a();
}
private void b(float f, float f2) {
if (f == this.U) {
this.J.setAlpha(60);
} else {
this.J.setAlpha(255);
}
if (f2 == this.V) {
this.K.setAlpha(60);
} else {
this.K.setAlpha(255);
}
}
private void c() {
double d = this.N;
double d2 = this.M;
if (d < 90.0d) {
d += 360.0d;
}
if (d2 < 90.0d) {
d2 = this.M + 360.0d;
}
if (d - d2 > 0.0d) {
this.I.setAlpha(255);
return;
}
this.M = this.N;
float centerX = this.s.centerX();
float centerY = this.s.centerY();
RectF rectF = this.r;
float f = this.h;
rectF.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
this.I.setAlpha(66);
}
private void d(float f, float f2) {
this.J.setAlpha(255);
double d = this.M;
if (d > 152.0d || d < Math.abs(-28.0f)) {
return;
}
if (this.M >= Math.abs(-28.0f) && this.M < 90.0d) {
float sin = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
float cos = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
RectF rectF = this.r;
float f3 = this.F;
rectF.offsetTo((f + cos) - (f3 / 2.0f), (f2 + sin) - (f3 / 2.0f));
this.M = 28.0d;
return;
}
float sin2 = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
float cos2 = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
RectF rectF2 = this.r;
float f4 = this.F;
rectF2.offsetTo((f - cos2) - (f4 / 2.0f), (f2 + sin2) - (f4 / 2.0f));
this.M = 152.0d;
this.J.setAlpha(60);
}
public void a(float f, float f2) {
this.S = f;
this.T = f2;
this.W = ((int) f) + "°";
this.a0 = ((int) f2) + "°";
b(f, f2);
float[] a = a(f, DataType.MIN);
float[] a2 = a(f2, DataType.MAX);
RectF rectF = this.r;
if (rectF != null) {
float f3 = a[0];
float f4 = this.h;
rectF.set(f3 - (f4 / 2.0f), a[1] - (f4 / 2.0f), a[0] + (f4 / 2.0f), a[1] + (f4 / 2.0f));
}
RectF rectF2 = this.s;
if (rectF2 != null) {
float f5 = a2[0];
float f6 = this.h;
rectF2.set(f5 - (f6 / 2.0f), a2[1] - (f6 / 2.0f), a2[0] + (f6 / 2.0f), a2[1] + (f6 / 2.0f));
}
invalidate();
}
public float getCurrentMax() {
return this.E;
}
public float getCurrentMin() {
return this.D;
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
double d;
canvas.drawArc(this.p, 152.0f, 236.0f, false, this.k);
LogUtils.c("progressStartAngle:" + this.M + " progressEndAngle:" + this.N);
double d2 = this.N;
if (d2 == this.M) {
d = 0.11d;
LogUtils.c("progressEndAngle == progressStartAngle1111");
} else {
if (d2 <= 152.0d || d2 > 360.0d) {
double d3 = this.M;
if (d3 < 0.0d || d3 >= 152.0d || d3 >= this.N) {
double d4 = this.N;
if (d4 >= 0.0d && d4 < 152.0d) {
double d5 = this.M;
if (d4 != d5) {
d = d4 + (360.0d - d5);
LogUtils.c("3333");
}
}
d = 0.0d;
}
}
d = this.N - this.M;
LogUtils.c("2222222");
}
double d6 = this.M;
if (d < 0.0d) {
d = d + 360.0d + 152.0d;
LogUtils.c("44444");
}
LogUtils.c("startAngle:" + d6 + " sweepAngle:" + d);
canvas.drawArc(this.q, (float) d6, (float) d, false, this.l);
if (this.G) {
canvas.drawBitmap(this.A, (Rect) null, this.r, this.m);
canvas.drawBitmap(this.z, (Rect) null, this.s, this.m);
} else {
canvas.drawBitmap(this.z, (Rect) null, this.s, this.m);
canvas.drawBitmap(this.A, (Rect) null, this.r, this.m);
}
canvas.drawBitmap(this.B, (Rect) null, this.t, this.K);
canvas.drawBitmap(this.B, (Rect) null, this.u, this.I);
canvas.drawBitmap(this.C, (Rect) null, this.v, this.L);
canvas.drawBitmap(this.C, (Rect) null, this.x, this.J);
canvas.drawText(this.W, this.u.centerX(), this.O - this.f, this.n);
canvas.drawText(this.a0, this.t.centerX(), this.O - this.f, this.n);
canvas.drawText(this.Q, this.t.centerX(), this.O + this.f, this.o);
canvas.drawText(this.R, this.u.centerX(), this.O + this.f, this.o);
super.onDraw(canvas);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int i;
int action = motionEvent.getAction();
if (action != 0) {
if (action == 2) {
float x = motionEvent.getX();
float y = motionEvent.getY();
float centerX = this.p.centerX();
float centerY = this.p.centerY();
double sqrt = Math.sqrt((r0 * r0) + (r2 * r2));
float f = this.g;
double d = (((f / 2.0f) / sqrt) * (x - centerX)) + (f / 2.0f);
double d2 = (((f / 2.0f) / sqrt) * (y - centerY)) + (f / 2.0f);
if (this.G) {
if (this.d0) {
return super.onTouchEvent(motionEvent);
}
this.N = a(centerX, centerY, d, d2);
b();
if (Math.round(this.N) == 28.0f) {
this.K.setAlpha(66);
} else {
this.K.setAlpha(255);
}
c(centerX, centerY);
double a = a(this.N);
this.a0 = ((int) a) + "°";
AngleUpdateListener angleUpdateListener = this.c0;
if (angleUpdateListener != null) {
angleUpdateListener.a(a);
}
} else {
if (this.d0) {
return super.onTouchEvent(motionEvent);
}
this.M = b(centerX, centerY, d, d2);
c();
d(centerX, centerY);
double a2 = a(this.M);
this.W = ((int) a2) + "°";
AngleUpdateListener angleUpdateListener2 = this.c0;
if (angleUpdateListener2 != null) {
angleUpdateListener2.c(a2);
}
}
invalidate();
}
return super.onTouchEvent(motionEvent);
}
float x2 = motionEvent.getX();
float y2 = motionEvent.getY();
float centerX2 = this.r.centerX();
float centerY2 = this.r.centerY();
float centerX3 = this.s.centerX();
float centerY3 = this.s.centerY();
this.d0 = false;
if (this.G) {
float f2 = this.h;
if (x2 >= centerX3 - (f2 / 2.0f) && x2 <= centerX3 + (f2 / 2.0f) && y2 >= centerY3 - (f2 / 2.0f) && y2 <= centerY3 + (f2 / 2.0f)) {
this.G = true;
return true;
}
float f3 = this.h;
if (x2 >= centerX2 - (f3 / 2.0f) && x2 <= centerX2 + (f3 / 2.0f) && y2 >= centerY2 - (f3 / 2.0f) && y2 <= centerY2 + (f3 / 2.0f)) {
this.G = false;
return true;
}
} else {
float f4 = this.h;
if (x2 >= centerX2 - (f4 / 2.0f) && x2 <= centerX2 + (f4 / 2.0f) && y2 >= centerY2 - (f4 / 2.0f) && y2 <= centerY2 + (f4 / 2.0f)) {
this.G = false;
return true;
}
float f5 = this.h;
if (x2 >= centerX3 - (f5 / 2.0f) && x2 <= centerX3 + (f5 / 2.0f) && y2 >= centerY3 - (f5 / 2.0f) && y2 <= centerY3 + (f5 / 2.0f)) {
this.G = true;
return true;
}
}
float centerX4 = this.u.centerX();
float centerY4 = this.u.centerY();
float f6 = this.a;
float f7 = this.b0;
if (x2 >= (centerX4 - (f6 / 2.0f)) - f7 && x2 <= centerX4 + (f6 / 2.0f) + f7) {
float f8 = this.b;
if (y2 >= (centerY4 - (f8 / 2.0f)) - f7 && y2 <= centerY4 + (f8 / 2.0f) + f7) {
this.d0 = true;
this.G = false;
this.M += 1.0d;
double d3 = this.M;
if (d3 < 28.0d || d3 >= 152.0d) {
double d4 = this.M;
double d5 = this.N;
if (d4 == d5) {
this.M = d5;
} else if (d4 < 0.0d) {
this.M = 360.0d;
} else if (d4 > 360.0d) {
this.M = d4 - 360.0d;
}
} else {
this.M = 28.0d;
}
c();
this.J.setAlpha(255);
double a3 = a(this.M);
this.W = ((int) a3) + "°";
float[] a4 = a((float) this.M);
RectF rectF = this.r;
float f9 = a4[0];
float f10 = this.h;
rectF.set(f9 - (f10 / 2.0f), a4[1] - (f10 / 2.0f), a4[0] + (f10 / 2.0f), a4[1] + (f10 / 2.0f));
invalidate();
AngleUpdateListener angleUpdateListener3 = this.c0;
if (angleUpdateListener3 != null) {
angleUpdateListener3.c(a3);
}
return true;
}
}
float centerX5 = this.x.centerX();
float centerY5 = this.x.centerY();
float f11 = this.a;
float f12 = this.b0;
if (x2 >= (centerX5 - (f11 / 2.0f)) - f12 && x2 <= centerX5 + (f11 / 2.0f) + f12) {
float f13 = this.b;
if (y2 >= (centerY5 - (f13 / 2.0f)) - f12 && y2 <= centerY5 + (f13 / 2.0f) + f12) {
this.d0 = true;
this.G = false;
this.M -= 1.0d;
double d6 = this.M;
if (d6 <= 28.0d || d6 >= 152.0d) {
double d7 = this.M;
double d8 = this.N;
if (d7 == d8) {
this.M = d8;
} else if (d7 < 0.0d) {
this.M = 360.0d;
}
} else {
this.M = 152.0d;
}
this.I.setAlpha(255);
if (Math.round(this.M) == 152.0f) {
this.J.setAlpha(60);
} else {
this.J.setAlpha(255);
}
double a5 = a(this.M);
this.W = ((int) a5) + "°";
float[] a6 = a((float) this.M);
RectF rectF2 = this.r;
float f14 = a6[0];
float f15 = this.h;
rectF2.set(f14 - (f15 / 2.0f), a6[1] - (f15 / 2.0f), a6[0] + (f15 / 2.0f), a6[1] + (f15 / 2.0f));
invalidate();
AngleUpdateListener angleUpdateListener4 = this.c0;
if (angleUpdateListener4 != null) {
angleUpdateListener4.c(a5);
}
return true;
}
}
float centerX6 = this.v.centerX();
float centerY6 = this.v.centerY();
float f16 = this.a;
float f17 = this.b0;
if (x2 >= (centerX6 - (f16 / 2.0f)) - f17 && x2 <= centerX6 + (f16 / 2.0f) + f17) {
float f18 = this.b;
if (y2 >= (centerY6 - (f18 / 2.0f)) - f17 && y2 <= centerY6 + (f18 / 2.0f) + f17) {
this.d0 = true;
this.G = true;
this.N -= 1.0d;
double d9 = this.N;
double d10 = this.M;
if (d9 == d10) {
this.N = d10;
} else if (d9 > 28.0d && d9 <= 152.0d) {
this.N = 152.0d;
} else if (this.N < 0.0d) {
this.N = 360.0d;
}
b();
if (this.N == 28.0d) {
this.K.setAlpha(60);
} else {
this.K.setAlpha(255);
}
double a7 = a(this.N);
this.a0 = ((int) a7) + "°";
float[] a8 = a((float) this.N);
RectF rectF3 = this.s;
float f19 = a8[0];
float f20 = this.h;
rectF3.set(f19 - (f20 / 2.0f), a8[1] - (f20 / 2.0f), a8[0] + (f20 / 2.0f), a8[1] + (f20 / 2.0f));
invalidate();
AngleUpdateListener angleUpdateListener5 = this.c0;
if (angleUpdateListener5 != null) {
angleUpdateListener5.a(a7);
}
return true;
}
}
float centerX7 = this.t.centerX();
float centerY7 = this.t.centerY();
float f21 = this.a;
float f22 = this.b0;
if (x2 >= (centerX7 - (f21 / 2.0f)) - f22 && x2 <= centerX7 + (f21 / 2.0f) + f22) {
float f23 = this.b;
if (y2 >= (centerY7 - (f23 / 2.0f)) - f22 && y2 <= centerY7 + (f23 / 2.0f) + f22) {
this.d0 = true;
this.G = true;
this.N += 1.0d;
double d11 = this.N;
if (d11 > 360.0d) {
this.N = d11 - 360.0d;
}
double d12 = this.N;
if (d12 < 28.0d || d12 >= 152.0d) {
double d13 = this.N;
double d14 = this.M;
if (d13 == d14) {
this.N = d14;
}
} else {
this.N = 28.0d;
}
if (this.N == 28.0d) {
this.K.setAlpha(60);
i = 255;
} else {
i = 255;
this.K.setAlpha(255);
}
this.L.setAlpha(i);
double a9 = a(this.N);
this.a0 = ((int) a9) + "°";
float[] a10 = a((float) this.N);
RectF rectF4 = this.s;
float f24 = a10[0];
float f25 = this.h;
rectF4.set(f24 - (f25 / 2.0f), a10[1] - (f25 / 2.0f), a10[0] + (f25 / 2.0f), a10[1] + (f25 / 2.0f));
invalidate();
AngleUpdateListener angleUpdateListener6 = this.c0;
if (angleUpdateListener6 != null) {
angleUpdateListener6.a(a9);
}
return true;
}
}
return super.onTouchEvent(motionEvent);
}
public void setAngleUpdateListener(AngleUpdateListener angleUpdateListener) {
this.c0 = angleUpdateListener;
}
public void setCurrentMax(float f) {
this.E = f;
}
public void setCurrentMin(float f) {
this.D = f;
}
private void b() {
double d = this.N;
double d2 = this.M;
if (d < 90.0d) {
d += 360.0d;
}
if (d2 < 90.0d) {
d2 = this.M + 360.0d;
}
if (d - d2 <= 0.0d) {
this.N = this.M;
float centerX = this.r.centerX();
float centerY = this.r.centerY();
RectF rectF = this.s;
float f = this.h;
rectF.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
this.L.setAlpha(60);
return;
}
this.L.setAlpha(255);
}
private void c(float f, float f2) {
if (this.N >= Math.abs(-28.0f)) {
double d = this.N;
if (d < 152.0d) {
if (d < 152.0d && d > 90.0d) {
float sin = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
float cos = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
RectF rectF = this.s;
float f3 = f - cos;
float f4 = this.F;
rectF.offsetTo(f3 - (f4 / 2.0f), (f2 + sin) - (f4 / 2.0f));
this.N = 152.0d;
return;
}
float sin2 = (float) ((this.g / 2.0f) * Math.sin((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
float cos2 = (float) ((this.g / 2.0f) * Math.cos((Math.abs(-28.0f) * 3.141592653589793d) / 180.0d));
RectF rectF2 = this.s;
float f5 = f + cos2;
float f6 = this.F;
rectF2.offsetTo(f5 - (f6 / 2.0f), (f2 + sin2) - (f6 / 2.0f));
this.N = 28.0d;
}
}
}
public AngleSetView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.h = 150.0f;
this.i = 0.0f;
this.j = 0.0f;
this.S = -118.0f;
this.T = 118.0f;
this.U = -118.0f;
this.V = 118.0f;
this.d0 = false;
this.y = context;
a();
}
public void a() {
this.W = ((int) this.S) + "°";
this.a0 = ((int) this.T) + "°";
this.b0 = this.y.getResources().getDimension(R.dimen.arrow_down_offset);
this.a = this.y.getResources().getDimension(R.dimen.arrow_width);
this.b = this.y.getResources().getDimension(R.dimen.arrow_height);
this.c = this.y.getResources().getDimension(R.dimen.arrow_sides_x);
this.d = this.y.getResources().getDimension(R.dimen.arrow_sides_y);
this.e = this.y.getResources().getDimension(R.dimen.arrow_sides_down_y);
this.f = this.y.getResources().getDimension(R.dimen.angle_text_margin_top);
this.F = this.y.getResources().getDimension(R.dimen.angle_set_progress_width);
float dimension = this.y.getResources().getDimension(R.dimen.angle_set_width);
float f = this.F;
this.g = dimension - f;
this.h = f;
Math.toDegrees(Math.asin(this.h / this.g));
this.Q = this.y.getResources().getString(R.string.angle_max_txt);
this.R = this.y.getResources().getString(R.string.angle_min_txt);
LogUtils.c("angleMaxHintText:" + this.Q.length());
LogUtils.c("angleMinHintText:" + this.R.length());
this.n = new Paint();
this.n.setAntiAlias(true);
this.n.setColor(this.y.getResources().getColor(R.color.txt_596F80));
this.n.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_size));
this.n.setTextAlign(Paint.Align.CENTER);
this.o = new Paint();
this.o.setAntiAlias(true);
this.o.setColor(this.y.getResources().getColor(R.color.txt_596F80));
int length = this.Q.length();
int length2 = this.R.length();
if (length <= 11 && length2 <= 11) {
this.o.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_hint_size));
} else {
this.o.setTextSize(this.y.getResources().getDimension(R.dimen.angle_text_hint_size_2));
}
this.o.setTextAlign(Paint.Align.CENTER);
this.I = new Paint();
this.I.setFlags(3);
this.J = new Paint();
this.J.setFlags(3);
this.K = new Paint();
this.K.setFlags(3);
this.L = new Paint();
this.L.setFlags(3);
this.m = new Paint();
this.m.setFlags(3);
this.H = new Paint();
this.H.setColor(-16776961);
this.k = new Paint();
this.k.setColor(this.y.getResources().getColor(R.color.bg_3396A6B4));
this.k.setFlags(3);
this.k.setStrokeWidth(this.F);
this.k.setStyle(Paint.Style.STROKE);
this.k.setStrokeCap(Paint.Cap.ROUND);
this.l = new Paint();
this.l.setShader(new LinearGradient(0.0f, 0.0f, 500.0f + this.g, 0.0f, new int[]{this.y.getResources().getColor(R.color.bg_0AEEFE), this.y.getResources().getColor(R.color.bg_4AACF5)}, (float[]) null, Shader.TileMode.CLAMP));
this.l.setAntiAlias(true);
this.l.setStrokeWidth(this.F);
this.l.setStyle(Paint.Style.STROKE);
this.l.setStrokeCap(Paint.Cap.ROUND);
float f2 = this.i;
float f3 = this.F;
float f4 = this.j;
float f5 = this.g;
this.p = new RectF((f3 / 2.0f) + f2, (f3 / 2.0f) + f4, f2 + f5 + (f3 / 2.0f), f4 + f5 + (f3 / 2.0f));
float f6 = this.i;
float f7 = this.F;
float f8 = this.j;
float f9 = this.g;
this.q = new RectF((f7 / 2.0f) + f6, (f7 / 2.0f) + f8, f6 + f9 + (f7 / 2.0f), f8 + f9 + (f7 / 2.0f));
this.P = this.p.centerX();
this.O = this.p.centerY();
float[] a = a(this.S, DataType.MIN);
float f10 = a[0];
float f11 = a[1];
float[] a2 = a(this.T, DataType.MAX);
float f12 = a2[0];
float f13 = a2[1];
float f14 = this.h;
this.r = new RectF(f10 - (f14 / 2.0f), f11 - (f14 / 2.0f), f10 + (f14 / 2.0f), f11 + (f14 / 2.0f));
float f15 = this.h;
this.s = new RectF(f12 - (f15 / 2.0f), f13 - (f15 / 2.0f), f12 + (f15 / 2.0f), f13 + (f15 / 2.0f));
float f16 = this.P;
float f17 = this.c;
float f18 = this.a;
float f19 = this.O;
float f20 = this.d;
float f21 = this.b;
this.t = new RectF((f16 + f17) - (f18 / 2.0f), (f19 - f20) - (f21 / 2.0f), f16 + f17 + (f18 / 2.0f), (f19 - f20) + (f21 / 2.0f));
float f22 = this.P;
float f23 = this.c;
float f24 = this.a;
float f25 = this.O;
float f26 = this.d;
float f27 = this.b;
this.u = new RectF((f22 - f23) - (f24 / 2.0f), (f25 - f26) - (f27 / 2.0f), (f22 - f23) + (f24 / 2.0f), (f25 - f26) + (f27 / 2.0f));
float f28 = this.P;
float f29 = this.c;
float f30 = this.a;
float f31 = this.O;
float f32 = this.e;
float f33 = this.b;
this.v = new RectF((f28 + f29) - (f30 / 2.0f), (f31 + f32) - (f33 / 2.0f), f28 + f29 + (f30 / 2.0f), f31 + f32 + (f33 / 2.0f));
float f34 = this.P;
float f35 = this.c;
float f36 = this.a;
float f37 = this.O;
float f38 = this.e;
float f39 = this.b;
this.x = new RectF((f34 - f35) - (f36 / 2.0f), (f37 + f38) - (f39 / 2.0f), (f34 - f35) + (f36 / 2.0f), f37 + f38 + (f39 / 2.0f));
this.z = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.angle_max);
this.A = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.angle_min);
this.B = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.arrow_up);
this.C = BitmapFactory.decodeResource(this.y.getResources(), R.mipmap.arrow_down);
b(this.S, this.T);
}
private double b(float f, float f2, double d, double d2) {
RectF rectF = this.r;
float f3 = this.h;
float f4 = this.F;
rectF.offsetTo((float) ((d - (f3 / 2.0f)) + (f4 / 2.0f)), (float) ((d2 - (f3 / 2.0f)) + (f4 / 2.0f)));
float centerX = this.r.centerX();
double atan2 = ((Math.atan2(f2 - this.r.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
if (centerX < f && atan2 < 152.0d) {
return 152.0d;
}
if (centerX <= f || atan2 < 28.0d || atan2 >= 152.0d) {
return atan2;
}
return 28.0d;
}
private float[] a(float f, DataType dataType) {
float abs = (((Math.abs(this.U) + Math.abs(this.V)) / 236.0f) * (f - this.U)) + 152.0f;
if (dataType == DataType.MIN) {
this.M = abs;
double d = this.M;
if (d > 360.0d) {
this.M = d - 360.0d;
}
} else {
this.N = abs;
double d2 = this.N;
if (d2 > 360.0d) {
this.N = d2 - 360.0d;
}
}
if (abs >= 90.0f && abs <= 180.0f) {
double radians = Math.toRadians(180.0f - abs);
return new float[]{(float) (this.P - (Math.cos(radians) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians) * (this.g / 2.0f)))};
}
if (abs > 180.0f && abs <= 270.0f) {
double radians2 = Math.toRadians(abs - 180.0f);
return new float[]{(float) (this.P - (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.O - (Math.sin(radians2) * (this.g / 2.0f)))};
}
if (abs > 270.0f && abs <= 360.0f) {
double radians3 = Math.toRadians(abs - 270.0f);
return new float[]{(float) (this.P + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.O - (Math.cos(radians3) * (this.g / 2.0f)))};
}
if (abs >= 360.0f) {
double radians4 = Math.toRadians(abs - 360.0f);
return new float[]{(float) (this.P + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians4) * (this.g / 2.0f)))};
}
double radians5 = Math.toRadians(28.0f);
double sin = Math.sin(radians5) * (this.g / 2.0f);
float cos = (float) (this.P - (Math.cos(radians5) * (this.g / 2.0f)));
float f2 = (float) (sin + this.O);
this.M = 152.0d;
this.N = 28.0d;
return new float[]{cos, f2};
}
private float[] a(float f) {
if (f >= 90.0f && f <= 180.0f) {
double radians = Math.toRadians(180.0f - f);
return new float[]{(float) (this.P - (Math.cos(radians) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians) * (this.g / 2.0f)))};
}
if (f > 180.0f && f <= 270.0f) {
double radians2 = Math.toRadians(f - 180.0f);
return new float[]{(float) (this.P - (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.O - (Math.sin(radians2) * (this.g / 2.0f)))};
}
if (f > 270.0f && f <= 360.0f) {
double radians3 = Math.toRadians(f - 270.0f);
return new float[]{(float) (this.P + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.O - (Math.cos(radians3) * (this.g / 2.0f)))};
}
if (f >= 0.0f && f < 90.0f) {
double radians4 = Math.toRadians(f);
return new float[]{(float) (this.P + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.O + (Math.sin(radians4) * (this.g / 2.0f)))};
}
double radians5 = Math.toRadians(28.0f);
double sin = Math.sin(radians5) * (this.g / 2.0f);
float cos = (float) (this.P - (Math.cos(radians5) * (this.g / 2.0f)));
float f2 = (float) (sin + this.O);
this.M = 152.0d;
this.N = 28.0d;
return new float[]{cos, f2};
}
private double a(double d) {
if (Math.round(d) < 152.0f) {
d += 360.0d;
}
return Math.round(((d - 152.0d) * 1.0d) + this.U);
}
private double a(float f, float f2, double d, double d2) {
RectF rectF = this.s;
float f3 = this.h;
float f4 = this.F;
rectF.offsetTo((float) ((d - (f3 / 2.0f)) + (f4 / 2.0f)), (float) ((d2 - (f3 / 2.0f)) + (f4 / 2.0f)));
float centerX = this.s.centerX();
double atan2 = ((Math.atan2(f2 - this.s.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
if (atan2 < 28.0d || atan2 >= 152.0d || centerX <= f) {
return atan2;
}
return 28.0d;
}
}

View File

@@ -0,0 +1,166 @@
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();
}
}

View File

@@ -0,0 +1,350 @@
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.util.AttributeSet;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.component.MenuItemView;
import com.ubt.jimu.controller.data.widget.ItemBaseData;
import com.ubt.jimu.controller.util.SvgUtils;
import com.ubt.jimu.utils.ScreenUtil;
import com.ubtrobot.log.ALog;
/* loaded from: classes.dex */
public class DragShadowView extends View {
private RectF a;
private RectF b;
private RectF c;
private Context d;
private Bitmap e;
private Bitmap f;
private float g;
private float h;
private float i;
private float j;
private Paint k;
private Paint l;
private Paint m;
private RectF n;
private DeleteView o;
private MenuItemView.MenuItemType p;
private float q;
public int r;
public int s;
private boolean t;
private Bitmap u;
private float v;
private ItemBaseData x;
private DragShadowState y;
/* renamed from: com.ubt.jimu.controller.component.DragShadowView$1, reason: invalid class name */
static /* synthetic */ class AnonymousClass1 {
static final /* synthetic */ int[] a = new int[DragShadowState.values().length];
static {
try {
a[DragShadowState.DRAG_STATE.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[DragShadowState.OVERLAP_STATE.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[DragShadowState.DELETE_STATE.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
public enum DragShadowState {
NONE_STATE,
DRAG_STATE,
OVERLAP_STATE,
DELETE_STATE
}
public DragShadowView(Context context) {
super(context);
this.g = 0.0f;
this.h = 0.0f;
this.i = 0.0f;
this.j = 0.0f;
this.t = false;
this.y = DragShadowState.NONE_STATE;
this.d = context;
c();
}
private void a(Canvas canvas) {
if (!this.t || this.c.width() <= 0.0f) {
return;
}
Bitmap bitmap = this.u;
RectF rectF = this.c;
float f = rectF.left;
float f2 = rectF.bottom;
float f3 = this.v;
canvas.drawBitmap(bitmap, (Rect) null, new RectF(f, f2 - f3, f3 + f, f2), this.m);
canvas.save();
RectF rectF2 = this.c;
float f4 = rectF2.left;
float f5 = this.v;
canvas.rotate(90.0f, f4 + (f5 / 2.0f), rectF2.top + (f5 / 2.0f));
Bitmap bitmap2 = this.u;
RectF rectF3 = this.c;
float f6 = rectF3.left;
float f7 = rectF3.top;
float f8 = this.v;
canvas.drawBitmap(bitmap2, (Rect) null, new RectF(f6, f7, f6 + f8, f8 + f7), this.m);
canvas.restore();
canvas.save();
RectF rectF4 = this.c;
float f9 = rectF4.right;
float f10 = this.v;
canvas.rotate(180.0f, f9 - (f10 / 2.0f), rectF4.top + (f10 / 2.0f));
Bitmap bitmap3 = this.u;
RectF rectF5 = this.c;
float f11 = rectF5.right;
float f12 = this.v;
float f13 = rectF5.top;
canvas.drawBitmap(bitmap3, (Rect) null, new RectF(f11 - f12, f13, f11, f12 + f13), this.m);
canvas.restore();
canvas.save();
RectF rectF6 = this.c;
float f14 = rectF6.right;
float f15 = this.v;
canvas.rotate(270.0f, f14 - (f15 / 2.0f), rectF6.bottom - (f15 / 2.0f));
Bitmap bitmap4 = this.u;
RectF rectF7 = this.c;
float f16 = rectF7.right;
float f17 = this.v;
float f18 = rectF7.bottom;
canvas.drawBitmap(bitmap4, (Rect) null, new RectF(f16 - f17, f18 - f17, f16, f18), this.m);
canvas.restore();
}
private void c() {
this.k = new Paint();
this.k.setFlags(3);
this.l = new Paint();
this.l.setFlags(3);
this.l.setColor(this.d.getResources().getColor(R.color.color_00C4C9));
this.m = new Paint();
this.m.setFlags(3);
this.u = BitmapFactory.decodeResource(getResources(), R.drawable.ic_adsorb_corner);
this.a = new RectF();
this.b = new RectF();
this.c = new RectF();
this.q = this.d.getResources().getDimension(R.dimen.shadow_radian);
this.r = ScreenUtil.b(this.d);
this.s = ScreenUtil.a(this.d);
this.v = getContext().getResources().getDimension(R.dimen.grid_view_width);
}
private RectF getDeleteViewRectF() {
return this.n;
}
public DragShadowView b(float f, float f2) {
this.i = f;
this.j = f2;
return this;
}
public DragShadowView d(float f, float f2) {
this.g = f;
this.h = f2;
if (this.p == MenuItemView.MenuItemType.WIDGET_ITEM) {
this.i = f;
this.j = f2;
}
return this;
}
public float getBgHeight() {
return this.j;
}
public float getBgWidth() {
return this.i;
}
public MenuItemView.MenuItemType getMenuItemType() {
return this.p;
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
if (this.e == null) {
super.onDraw(canvas);
return;
}
if (this.p == null) {
super.onDraw(canvas);
return;
}
super.onDraw(canvas);
RectF rectF = this.b;
float f = this.q;
canvas.drawRoundRect(rectF, f, f, this.l);
a(canvas);
if (this.p == MenuItemView.MenuItemType.ACTION_ITEM) {
canvas.drawBitmap(this.f, (Rect) null, this.b, this.k);
}
canvas.drawBitmap(this.e, (Rect) null, this.a, this.k);
}
public void setDragShadowState(DragShadowState dragShadowState) {
int color;
if (dragShadowState.equals(this.y)) {
invalidate();
return;
}
int i = AnonymousClass1.a[dragShadowState.ordinal()];
if (i == 1) {
color = this.d.getResources().getColor(R.color.bg_9900C4C9);
this.t = true;
if (this.o != null && this.x != null) {
String format = String.format(this.d.getResources().getString(R.string.control_remove_widget_here), b(this.x));
this.o.setOverlapState(false);
this.o.a(format);
}
} else if (i == 2) {
color = this.d.getResources().getColor(R.color.bg_99B8BEC1);
this.t = false;
if (this.o != null && this.x != null) {
String format2 = String.format(this.d.getResources().getString(R.string.control_remove_widget_here), b(this.x));
this.o.setOverlapState(false);
this.o.a(format2);
}
} else if (i != 3) {
ALog.a("Not Support set this state", new Object[0]);
color = 0;
} else {
this.t = false;
color = this.d.getResources().getColor(R.color.color_FF4979);
if (this.o != null && this.x != null) {
String format3 = String.format(this.d.getResources().getString(R.string.control_remove_widget), b(this.x));
this.o.setOverlapState(true);
this.o.a(format3);
}
}
this.l.setColor(color);
invalidate();
}
private String b(ItemBaseData itemBaseData) {
return itemBaseData != null ? itemBaseData.getWidgetInfo(this.d) : "";
}
public void b() {
this.a.set(0.0f, 0.0f, 0.0f, 0.0f);
this.b.set(0.0f, 0.0f, 0.0f, 0.0f);
this.c.set(0.0f, 0.0f, 0.0f, 0.0f);
DeleteView deleteView = this.o;
if (deleteView != null) {
deleteView.f();
}
invalidate();
}
public DragShadowView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.g = 0.0f;
this.h = 0.0f;
this.i = 0.0f;
this.j = 0.0f;
this.t = false;
this.y = DragShadowState.NONE_STATE;
this.d = context;
c();
}
public float b(float f) {
float f2 = this.j;
if (f - (f2 / 2.0f) <= 0.0f) {
return f2 / 2.0f;
}
float f3 = (f2 / 2.0f) + f;
int i = this.s;
return f3 >= ((float) i) ? i - (f2 / 2.0f) : f;
}
public DragShadowView a(MenuItemView.MenuItemType menuItemType) {
this.p = menuItemType;
return this;
}
public DragShadowView a(ItemBaseData itemBaseData) {
this.x = itemBaseData;
return this;
}
public void c(float f, float f2) {
float a = a(f);
float b = b(f2);
RectF rectF = this.a;
float f3 = this.g;
float f4 = this.h;
rectF.set(a - (f3 / 2.0f), b - (f4 / 2.0f), (f3 / 2.0f) + a, (f4 / 2.0f) + b);
RectF rectF2 = this.b;
float f5 = this.i;
float f6 = this.j;
rectF2.set(a - (f5 / 2.0f), b - (f6 / 2.0f), a + (f5 / 2.0f), b + (f6 / 2.0f));
}
public DragShadowView a(int i) {
MenuItemView.MenuItemType menuItemType = this.p;
if (menuItemType != null) {
if (menuItemType == MenuItemView.MenuItemType.WIDGET_ITEM) {
this.e = BitmapFactory.decodeResource(this.d.getResources(), i);
return this;
}
this.e = SvgUtils.a(this.d).a(i, (int) this.g, (int) this.h);
if (this.p == MenuItemView.MenuItemType.ACTION_ITEM) {
this.f = BitmapFactory.decodeResource(this.d.getResources(), R.mipmap.btn_shadow);
}
return this;
}
throw new RuntimeException("必须先调用 setMenuItemType() 函数设置item类型");
}
public void a(float f, float f2) {
RectF rectF = this.c;
float f3 = this.i;
float f4 = this.j;
rectF.set(f - (f3 / 2.0f), f2 - (f4 / 2.0f), f + (f3 / 2.0f), f2 + (f4 / 2.0f));
}
public boolean a() {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, this.b);
}
public void a(DeleteView deleteView) {
this.o = deleteView;
if (this.o != null) {
this.n = deleteView.getDeleteViewRectF();
}
}
public float a(float f) {
float f2 = this.i;
if (f - (f2 / 2.0f) <= 0.0f) {
return f2 / 2.0f;
}
float f3 = (f2 / 2.0f) + f;
int i = this.r;
return f3 >= ((float) i) ? i - (f2 / 2.0f) : f;
}
}

View File

@@ -0,0 +1,79 @@
package com.ubt.jimu.controller.component;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.util.ScreenUtil;
/* loaded from: classes.dex */
public class GridView extends View {
private float a;
private Context b;
private int c;
private int d;
private float e;
private int f;
private int g;
private Paint h;
public GridView(Context context) {
super(context);
this.a = 5.0f;
this.b = context;
b();
a();
}
private void a() {
this.c = ScreenUtil.a(this.b);
this.d = ScreenUtil.b(this.b);
this.e = this.b.getResources().getDimension(R.dimen.grid_view_width);
float f = this.d;
float f2 = this.e;
this.f = (int) (f / f2);
this.g = (int) (this.c / f2);
Log.e("Test", "mScreenWidth:" + this.c + " mScreenHeight:" + this.d + " rowNum:" + this.f + " lengthwaysNum:" + this.g);
this.h = new Paint();
this.h.setAntiAlias(true);
this.h.setColor(this.b.getResources().getColor(R.color.bg_BCEAFF));
this.h.setStrokeWidth(this.a);
}
private void b() {
}
public int getColumnNum() {
return this.g;
}
public int getRowNum() {
return this.f;
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
float f = this.e;
float f2 = f;
for (int i = 0; i < this.f; i++) {
canvas.drawLine(0.0f, f2, this.c, f2, this.h);
f2 += this.e;
}
for (int i2 = 0; i2 < this.g; i2++) {
canvas.drawLine(f, 0.0f, f, this.d, this.h);
f += this.e;
}
super.onDraw(canvas);
}
public GridView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.a = 5.0f;
this.b = context;
b();
a();
}
}

View File

@@ -0,0 +1,338 @@
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.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.data.config.HSliderConfig;
import com.ubt.jimu.controller.data.widget.HSliderWidgetData;
import com.ubt.jimu.controller.manager.CommandSendManager;
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
import com.ubt.jimu.controller.view.control.SuperControlView;
import com.ubt.jimu.utils.SystemUtils;
/* loaded from: classes.dex */
public class HSliderView extends SuperControlView<HSliderWidgetData> {
private Context B;
private float C;
private float D;
private float E;
private float F;
private float G;
private float H;
private RectF I;
private RectF J;
private Paint K;
private Bitmap L;
private Bitmap M;
private float N;
private CommandSendManager O;
private float P;
private float Q;
private float R;
private float S;
public HSliderView(Context context, float f, float f2) {
super(context);
this.C = 0.0f;
this.D = 0.0f;
System.currentTimeMillis();
this.B = context;
this.C = f;
this.D = f2;
g();
f();
}
private void a(float f, float f2, float f3) {
this.O.a(((this.J.centerX() - f3) / (f2 - f)) * 100.0f * 2.0f);
this.O.a((CommandSendManager) getData());
}
private void b(float f, float f2) {
this.I.offsetTo(f, f2);
this.j.offsetTo(f, f2);
this.J.offsetTo(this.I.centerX() - (this.G / 2.0f), this.I.centerY() - (this.G / 2.0f));
}
private void f() {
this.L = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.rectangle_hslider);
this.M = BitmapFactory.decodeResource(this.B.getResources(), R.mipmap.slider_ball);
this.H = this.L.getWidth() / this.L.getHeight();
this.l = this.B.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
this.m = this.l / this.H;
float f = this.D;
float f2 = this.m;
float f3 = f + (f2 / 2.0f);
int i = this.s;
if (f3 >= i) {
this.D = i - (f2 / 2.0f);
}
float f4 = this.C;
float f5 = this.l;
if (f4 - (f5 / 2.0f) <= 0.0f) {
this.C = f5 / 2.0f;
} else {
float f6 = f4 + (f5 / 2.0f);
int i2 = this.r;
if (f6 >= i2) {
this.C = i2 - (f5 / 2.0f);
}
}
float f7 = this.m;
this.G = f7 / 1.8f;
this.E = this.l / 2.0f;
this.F = f7 / 2.0f;
this.K = new Paint();
this.K.setFlags(3);
float f8 = this.C;
float f9 = this.l;
float f10 = this.D;
float f11 = this.m;
this.I = new RectF(f8 - (f9 / 2.0f), f10 - (f11 / 2.0f), f8 + (f9 / 2.0f), f10 + (f11 / 2.0f));
float centerX = this.I.centerX();
float centerY = this.I.centerY();
float f12 = this.G;
this.J = new RectF(centerX - (f12 / 2.0f), centerY - (f12 / 2.0f), centerX + (f12 / 2.0f), centerY + (f12 / 2.0f));
this.O = new CommandSendManager();
}
private void g() {
}
private void h() {
HSliderWidgetData data;
HSliderConfig config;
if (!b()) {
this.O.b();
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.b((SuperControlView) this);
}
} else {
if (a(this.j)) {
if (this.i != null && (data = getData()) != null && (config = data.getConfig()) != null) {
this.i.a(this, config.getConfigID());
this.i.c((View) this);
}
invalidate();
return;
}
if (this.i != null) {
RectF rectF = this.I;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
this.J.offsetTo(this.o + this.N, this.p);
this.I.offsetTo(this.o, this.p);
this.j.offsetTo(this.o, this.p);
this.b.setColor(this.B.getResources().getColor(this.a));
} else {
b(a.x, a.y);
this.i.a(this, this.I.centerX(), this.I.centerY());
}
this.i.c((View) this);
if (System.currentTimeMillis() - this.t < 350) {
this.i.a(this, getData());
}
}
b(false);
}
float centerX = this.I.centerX();
float centerY = this.I.centerY();
RectF rectF2 = this.J;
float f = centerX + this.N;
float f2 = this.G;
rectF2.offsetTo(f - (f2 / 2.0f), centerY - (f2 / 2.0f));
invalidate();
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public float[] getViewCenterXY() {
return new float[]{this.I.centerX(), this.I.centerY()};
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawBitmap(this.L, (Rect) null, this.I, this.K);
canvas.drawBitmap(this.M, (Rect) null, this.J, this.K);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == 0) {
this.t = System.currentTimeMillis();
this.R = motionEvent.getX();
this.S = motionEvent.getY();
super.d();
this.f = false;
if (!b()) {
float centerX = this.J.centerX();
float centerY = this.J.centerY();
float f = this.G;
float f2 = centerX - (f / 2.0f);
float f3 = centerX + (f / 2.0f);
float f4 = centerY - (f / 2.0f);
float f5 = centerY + (f / 2.0f);
float f6 = this.R;
if (f6 >= f2 && f6 <= f3) {
float f7 = this.S;
if (f7 >= f4 && f7 <= f5) {
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.a((SuperControlView) this);
}
this.O.a();
}
}
return super.onTouchEvent(motionEvent);
}
float centerX2 = this.I.centerX();
float centerY2 = this.I.centerY();
float f8 = this.E;
float f9 = centerX2 - f8;
float f10 = centerX2 + f8;
float f11 = this.F;
float f12 = centerY2 - f11;
float f13 = centerY2 + f11;
float f14 = this.R;
if (f14 >= f9 && f14 <= f10) {
float f15 = this.S;
if (f15 >= f12 && f15 <= f13) {
this.P = super.a(f14);
this.Q = super.b(this.S);
bringToFront();
ControlTouchEvent controlTouchEvent2 = this.i;
if (controlTouchEvent2 != null) {
controlTouchEvent2.a((View) this);
}
}
}
return super.onTouchEvent(motionEvent);
return true;
}
if (action == 1) {
if (!this.f) {
this.f = true;
h();
}
return false;
}
if (action != 2) {
if (action != 3) {
return super.onTouchEvent(motionEvent);
}
if (!this.f) {
this.f = true;
h();
}
return true;
}
if (b()) {
b(super.a(motionEvent, this.P), super.b(motionEvent, this.Q));
if (this.i != null) {
float abs = Math.abs(motionEvent.getX() - this.R);
float abs2 = Math.abs(motionEvent.getY() - this.S);
if (abs <= 10.0f && abs2 <= 10.0f) {
return true;
}
this.i.b((View) this);
if (a(this.j)) {
this.b.setColor(this.B.getResources().getColor(R.color.color_FF4979));
if (!this.n) {
SystemUtils.b(this.B);
this.n = true;
}
b(false);
if (this.e != null && getData() != null) {
String format = String.format(this.B.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.B));
this.e.setOverlapState(true);
this.e.a(format);
}
} else {
if (this.e != null && getData() != null) {
String format2 = String.format(this.B.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.B));
this.e.setOverlapState(false);
this.e.a(format2);
}
RectF rectF = this.I;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
b(false);
this.b.setColor(this.B.getResources().getColor(R.color.bg_99B8BEC1));
} else {
b(true);
this.b.setColor(this.B.getResources().getColor(this.a));
}
this.n = false;
}
}
} else {
float x = motionEvent.getX();
float centerX3 = this.I.centerX();
float centerY3 = this.I.centerY();
float f16 = this.E;
float f17 = this.G;
float f18 = (centerX3 - f16) + (f17 / 2.0f);
float f19 = (centerX3 + f16) - (f17 / 2.0f);
if (x < f18) {
x = f18;
}
if (x > f19) {
x = f19;
}
RectF rectF2 = this.J;
float f20 = this.G;
rectF2.offsetTo(x - (f20 / 2.0f), centerY3 - (f20 / 2.0f));
float centerX4 = this.I.centerX();
this.N = this.J.centerX() - centerX4;
a(f18, f19, centerX4);
}
invalidate();
return true;
}
public void setHSliderViewCommandSendListener(CommandSendManager.HSliderViewCommandSendListener hSliderViewCommandSendListener) {
this.O.a(hSliderViewCommandSendListener);
}
public void setStartX(float f) {
this.C = f;
}
public void setStartY(float f) {
this.D = f;
}
public void setViewHeight(float f) {
this.m = f;
this.l = f * this.H;
this.E = this.l / 2.0f;
this.F = this.m / 2.0f;
}
public void setViewWidth(float f) {
this.l = f;
this.m = f / this.H;
this.E = f / 2.0f;
this.F = this.m / 2.0f;
}
public boolean a(RectF rectF) {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, rectF);
}
}

View File

@@ -0,0 +1,108 @@
package com.ubt.jimu.controller.component;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.controller.view.ItemBaseView;
import com.ubtrobot.log.ALog;
/* loaded from: classes.dex */
public class MenuItemView extends ItemBaseView {
private boolean d;
private MenuItemOnTouchListener e;
private float f;
private MenuItemType g;
public interface MenuItemOnTouchListener<T> {
void a(T t, MenuItemView menuItemView);
void b(T t, MenuItemView menuItemView);
}
public enum MenuItemType {
ACTION_ADD_ITEM,
ACTION_ITEM,
WIDGET_ITEM,
WIDGET_ADD_ITEM
}
public class MyDragShadowBuilder extends View.DragShadowBuilder {
public MyDragShadowBuilder(MenuItemView menuItemView) {
}
@Override // android.view.View.DragShadowBuilder
public void onProvideShadowMetrics(Point point, Point point2) {
point.set(1, 1);
point2.set(0, 0);
}
}
public MenuItemView(Context context) {
super(context);
a();
}
private void a() {
}
public MenuItemType getMenuItemType() {
return this.g;
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == 0) {
this.f = motionEvent.getX();
return true;
}
if (action == 1) {
this.f = 0.0f;
this.d = false;
MenuItemOnTouchListener menuItemOnTouchListener = this.e;
if (menuItemOnTouchListener != null) {
menuItemOnTouchListener.b(super.getData(), this);
}
return super.onTouchEvent(motionEvent);
}
if (action == 2) {
float abs = Math.abs(this.f - motionEvent.getX());
if (!this.d) {
this.d = true;
if (abs > 20.0f) {
MenuItemOnTouchListener menuItemOnTouchListener2 = this.e;
if (menuItemOnTouchListener2 != null) {
menuItemOnTouchListener2.a(super.getData(), this);
}
ALog.a("DRAG").d("start drag");
if (Build.VERSION.SDK_INT >= 24) {
startDragAndDrop(null, new MyDragShadowBuilder(this), null, 0);
} else {
startDrag(null, new MyDragShadowBuilder(this), null, 0);
}
}
return true;
}
} else if (action != 3) {
return super.onTouchEvent(motionEvent);
}
this.d = false;
return super.onTouchEvent(motionEvent);
}
public void setMenuItemOnTouchListener(MenuItemOnTouchListener menuItemOnTouchListener) {
this.e = menuItemOnTouchListener;
}
public void setMenuItemType(MenuItemType menuItemType) {
this.g = menuItemType;
}
public MenuItemView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
a();
}
}

View File

@@ -0,0 +1,388 @@
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.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.data.config.JockstickConfig;
import com.ubt.jimu.controller.data.widget.JockstickData;
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
import com.ubt.jimu.controller.view.control.OnControllerClickListener;
import com.ubt.jimu.controller.view.control.SuperControlView;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
/* loaded from: classes.dex */
public class SteeringWheelView extends SuperControlView<JockstickData> {
private OnSlideListener B;
private float C;
private float D;
private Context E;
private int F;
private float G;
private float H;
private float I;
private Paint J;
private RectF K;
private RectF L;
private Paint M;
private Bitmap N;
private Bitmap O;
private float P;
private long Q;
private float R;
private float S;
private float T;
private float U;
public interface OnSlideListener {
void a(float f, float f2, float f3, JockstickData jockstickData);
void a(JockstickData jockstickData);
void a(JockstickData jockstickData, SuperControlView.MotionEventState motionEventState);
}
public SteeringWheelView(Context context, float f, float f2) {
super(context);
this.F = R.color.color_4D00C4C9;
this.H = 0.0f;
this.I = 0.0f;
this.Q = System.currentTimeMillis();
this.E = context;
this.H = f;
this.I = f2;
h();
g();
}
private void a(SuperControlView.MotionEventState motionEventState) {
JockstickConfig config;
if (b()) {
this.R = 0.0f;
this.S = 0.0f;
if (a(this.j) && this.i != null && (config = getData().getConfig()) != null) {
this.i.a(this, config.getConfigID());
}
if (this.i != null) {
RectF rectF = this.K;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
boolean c = this.i.c((SuperControlView) this);
Log.e("Test", "isOverlap:" + c);
if (c) {
b(this.o, this.p);
this.b.setColor(this.E.getResources().getColor(this.F));
} else {
b(a.x, a.y);
this.i.a(this, this.K.centerX(), this.K.centerY());
}
this.i.c((View) this);
if (System.currentTimeMillis() - this.t < 350) {
this.i.a(this, getData());
}
}
b(false);
} else {
float centerX = this.K.centerX();
float centerY = this.K.centerY();
float f = this.G;
this.L.offsetTo(centerX - (f / 2.0f), centerY - (f / 2.0f));
int state = getState();
if (state == 0) {
b(motionEventState);
} else if (state == 2) {
setSelect(true);
this.b.setColor(this.E.getResources().getColor(this.F));
f();
}
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.b((SuperControlView) this);
}
}
invalidate();
}
private void b(SuperControlView.MotionEventState motionEventState) {
OnSlideListener onSlideListener = this.B;
if (onSlideListener != null) {
onSlideListener.a(getData(), motionEventState);
}
}
private void c(float f, float f2) {
double d;
double d2;
OnSlideListener onSlideListener;
float centerX = this.K.centerX();
float centerY = this.K.centerY();
double d3 = f - centerX;
double d4 = centerY - f2;
double sqrt = Math.sqrt((d3 * d3) + (d4 * d4));
float f3 = this.P;
if (sqrt > f3) {
double d5 = ((f3 / sqrt) * d3) + centerX;
float f4 = this.G;
d = d5 - (f4 / 2.0f);
d2 = (((f3 / sqrt) * (f2 - centerY)) + centerY) - (f4 / 2.0f);
} else {
float f5 = this.G;
d = f - (f5 / 2.0f);
d2 = f2 - (f5 / 2.0f);
}
this.L.offsetTo((float) d, (float) d2);
if (getState() == 0) {
boolean z = Math.abs(d3 - ((double) this.T)) < ((double) getMinXOffset()) || Math.abs(d4 - ((double) this.U)) < ((double) getMinYOffset());
if ((System.currentTimeMillis() - this.Q > 200 || z) && (onSlideListener = this.B) != null) {
onSlideListener.a((float) d3, (float) d4, this.P, getData());
this.Q = System.currentTimeMillis();
}
}
}
private void f() {
OnControllerClickListener onControllerClickListener = getOnControllerClickListener();
if (onControllerClickListener == null) {
return;
}
onControllerClickListener.a(null, this);
}
private void g() {
this.l = this.E.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
this.m = this.l;
float f = this.I;
float f2 = this.m;
float f3 = f + (f2 / 2.0f);
int i = this.s;
if (f3 >= i) {
this.I = i - (f2 / 2.0f);
}
float f4 = this.H;
float f5 = this.m;
if (f4 - (f5 / 2.0f) <= 0.0f) {
this.H = f5 / 2.0f;
} else {
float f6 = f4 + (f5 / 2.0f);
int i2 = this.r;
if (f6 >= i2) {
this.H = i2 - (f5 / 2.0f);
}
}
this.G = this.E.getResources().getDimension(R.dimen.wheel_control_ball);
this.J = new Paint();
this.J.setFlags(3);
float f7 = this.H;
float f8 = this.l;
float f9 = this.I;
float f10 = this.m;
this.K = new RectF(f7 - (f8 / 2.0f), f9 - (f10 / 2.0f), f7 + (f8 / 2.0f), f9 + (f10 / 2.0f));
this.M = new Paint();
this.M.setAntiAlias(true);
this.M.setFilterBitmap(true);
this.N = BitmapFactory.decodeResource(this.E.getResources(), R.mipmap.jockstick);
this.O = BitmapFactory.decodeResource(this.E.getResources(), R.mipmap.steering_wheel_thumb);
float centerX = this.K.centerX();
float centerY = this.K.centerY();
float f11 = this.G;
this.L = new RectF(centerX - (f11 / 2.0f), centerY - (f11 / 2.0f), centerX + (f11 / 2.0f), centerY + (f11 / 2.0f));
this.P = this.l / 2.0f;
}
private float getMinXOffset() {
return this.l / 20.0f;
}
private float getMinYOffset() {
return this.l / 20.0f;
}
private void h() {
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public float[] getViewCenterXY() {
return new float[]{this.K.centerX(), this.K.centerY()};
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
protected void onDraw(Canvas canvas) {
if (getState() == 2) {
if (c()) {
e();
} else {
a();
}
}
super.onDraw(canvas);
canvas.drawBitmap(this.N, (Rect) null, this.K, this.M);
canvas.drawBitmap(this.O, (Rect) null, this.L, this.M);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
OnSlideListener onSlideListener;
int action = motionEvent.getAction();
if (action == 0) {
LogUtils.c("MotionEvent.ACTION_DOWN:");
this.t = System.currentTimeMillis();
this.C = motionEvent.getX();
this.D = motionEvent.getY();
super.d();
this.f = false;
setPressed(true);
if (!b()) {
float centerX = this.K.centerX();
float centerY = this.K.centerY();
float f = this.C;
float f2 = this.l;
if (f >= centerX - (f2 / 2.0f)) {
float f3 = this.D;
if (f3 >= centerY - (f2 / 2.0f) && f <= centerX + (f2 / 2.0f) && f3 <= centerY + (f2 / 2.0f)) {
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.a((SuperControlView) this);
}
if (getState() == 0 && (onSlideListener = this.B) != null) {
onSlideListener.a(getData());
}
}
}
return super.onTouchEvent(motionEvent);
}
float centerX2 = this.K.centerX();
float centerY2 = this.K.centerY();
float f4 = this.l;
float f5 = centerX2 - (f4 / 2.0f);
float f6 = this.m;
float f7 = centerY2 - (f6 / 2.0f);
float f8 = centerX2 + (f4 / 2.0f);
float f9 = centerY2 + (f6 / 2.0f);
float f10 = this.C;
if (f10 >= f5 && f10 <= f8) {
float f11 = this.D;
if (f11 >= f7 && f11 <= f9) {
this.R = super.a(f10);
this.S = super.b(this.D);
bringToFront();
ControlTouchEvent controlTouchEvent2 = this.i;
if (controlTouchEvent2 != null) {
controlTouchEvent2.a((View) this);
}
invalidate();
}
}
return super.onTouchEvent(motionEvent);
}
if (action == 1) {
setPressed(false);
if (!this.f) {
this.f = true;
a(SuperControlView.MotionEventState.STATE_UP);
LogUtils.c("方向盘ACTION_UP");
}
return true;
}
if (action != 2) {
if (action != 3) {
return super.onTouchEvent(motionEvent);
}
if (!this.f) {
LogUtils.c("方向盘ACTION_CANCEL");
this.f = true;
a(SuperControlView.MotionEventState.STATE_CANCEL);
}
return true;
}
setPressed(true);
this.f = false;
LogUtils.c("MotionEvent.ACTION_MOVE:");
if (b()) {
a(motionEvent);
if (this.i != null) {
float abs = Math.abs(motionEvent.getX() - this.C);
float abs2 = Math.abs(motionEvent.getY() - this.D);
if (abs <= 10.0f && abs2 <= 10.0f) {
return true;
}
this.i.b((View) this);
if (a(this.j)) {
b(false);
this.b.setColor(this.E.getResources().getColor(R.color.color_FF4979));
if (this.e != null && getData() != null) {
this.e.setOverlapState(true);
this.e.a(String.format(this.E.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.E)));
}
if (!this.n) {
SystemUtils.b(this.E);
this.n = true;
}
} else {
if (this.e != null && getData() != null) {
this.e.setOverlapState(false);
this.e.a(String.format(this.E.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.E)));
}
RectF rectF = this.K;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
b(false);
this.b.setColor(this.E.getResources().getColor(R.color.bg_99B8BEC1));
} else {
b(true);
this.b.setColor(this.E.getResources().getColor(this.F));
}
this.n = false;
}
}
} else {
c(motionEvent.getX(), motionEvent.getY());
}
invalidate();
return true;
}
public void setOnSlideListener(OnSlideListener onSlideListener) {
this.B = onSlideListener;
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public void setSelect(boolean z) {
super.setSelect(z);
}
public void setSteeringWheelBackgroundStartX(float f) {
this.H = f;
}
public void setSteeringWheelBackgroundStartY(float f) {
this.I = f;
}
private void b(float f, float f2) {
this.K.offsetTo(f, f2);
this.j.offsetTo(f, f2);
this.L.offsetTo(this.K.centerX() - (this.G / 2.0f), this.K.centerY() - (this.G / 2.0f));
}
private void a(MotionEvent motionEvent) {
b(super.a(motionEvent, this.R), super.b(motionEvent, this.S));
}
public boolean a(RectF rectF) {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, rectF);
}
}

View File

@@ -0,0 +1,818 @@
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.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.utils.BitmapUtils;
import com.ubt.jimu.utils.LogUtils;
/* loaded from: classes.dex */
public class TensionAngleSetView extends View {
private RectF A;
private RectF B;
private RectF C;
private Context D;
private Bitmap E;
private Bitmap F;
private Bitmap G;
private Bitmap H;
private float I;
private float J;
private float K;
private boolean L;
private Paint M;
private double N;
private double O;
private float P;
private float Q;
private String R;
private String S;
private float T;
private float U;
private String V;
private String W;
private float a;
private float a0;
private float b;
private Matrix b0;
private float c;
private float c0;
private float d;
private boolean d0;
private float e;
private AngleUpdateListener e0;
private float f;
private float g;
private float h;
private float i;
private float j;
private float k;
private Paint l;
private Paint m;
private Paint n;
private Paint o;
private Paint p;
private Paint q;
private Paint r;
private Paint s;
private Paint t;
private RectF u;
private RectF v;
private RectF x;
private RectF y;
private RectF z;
public interface AngleUpdateListener {
void b(double d);
void d(double d);
}
enum DataType {
START,
LAUNCH
}
public TensionAngleSetView(Context context) {
super(context);
this.j = 0.0f;
this.k = 0.0f;
this.T = -118.0f;
this.U = 118.0f;
this.D = context;
a();
}
private float[] b(float f) {
this.O = 388.0f - (((Math.abs(118.0f) + Math.abs(-118.0f)) / 236.0f) * (118.0f - f));
double d = this.O;
if (d >= 360.0d) {
double radians = Math.toRadians((float) (d - 360.0d));
return new float[]{(float) (this.Q + (Math.cos(radians) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians) * (this.g / 2.0f)))};
}
if (d >= 270.0d && d < 360.0d) {
float f2 = (float) (360.0d - d);
LogUtils.c("cosAnglecosAngle:" + f2);
double radians2 = Math.toRadians((double) f2);
return new float[]{(float) (this.Q + (Math.cos(radians2) * (this.g / 2.0f))), (float) (this.P - (Math.sin(radians2) * ((double) (this.g / 2.0f))))};
}
double d2 = this.O;
if (d2 < 270.0d && d2 >= 180.0d) {
double radians3 = Math.toRadians((float) (d2 - 180.0d));
return new float[]{(float) (this.Q - (Math.cos(radians3) * (this.g / 2.0f))), (float) (this.P - (Math.sin(radians3) * (this.g / 2.0f)))};
}
double d3 = this.O;
if (d3 >= 180.0d || d3 <= 90.0d) {
return null;
}
double radians4 = Math.toRadians((float) (180.0d - d3));
return new float[]{(float) (this.Q - (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians4) * (this.g / 2.0f)))};
}
private float[] c(float f, float f2) {
float b = b(f, f2);
if (b < -28.0f) {
b = -28.0f;
} else if (b >= 208.0f) {
b = 208.0f;
}
double radians = Math.toRadians(b);
double sin = Math.sin(radians);
double cos = Math.cos(radians);
float f3 = this.g;
return new float[]{(float) (this.u.centerX() + ((f3 / 2.0f) * cos)), (float) (this.u.centerY() - ((f3 / 2.0f) * sin))};
}
private double d(float f, float f2) {
float centerX = this.y.centerX();
double atan2 = ((Math.atan2(f2 - this.y.centerY(), f - centerX) * 180.0d) / 3.141592653589793d) + 180.0d;
if (atan2 < 28.0d || atan2 >= 152.0d || centerX <= f) {
return atan2;
}
return 28.0d;
}
private void setAngle(float f) {
this.b0.reset();
float centerX = this.x.centerX();
float centerY = this.x.centerY();
this.b0.setTranslate(centerX - (this.F.getWidth() / 2.0f), centerY - (this.F.getHeight() / 2.0f));
this.b0.postRotate(-f, centerX, centerY);
}
public void a(float f, float f2) {
if (this.T == f) {
this.r.setAlpha(60);
} else {
this.r.setAlpha(255);
}
if (this.U == f2) {
this.s.setAlpha(60);
} else {
this.s.setAlpha(255);
}
this.T = f;
this.U = f2;
this.V = ((int) f) + "°";
this.W = ((int) f2) + "°";
float[] a = a(f, DataType.START);
float[] b = b(f2);
RectF rectF = this.x;
if (rectF != null && b != null) {
float f3 = b[0];
float f4 = this.i;
rectF.set(f3 - (f4 / 2.0f), b[1] - (f4 / 2.0f), b[0] + (f4 / 2.0f), b[1] + (f4 / 2.0f));
}
RectF rectF2 = this.y;
if (rectF2 != null) {
float f5 = a[0];
float f6 = this.h;
rectF2.set(f5 - (f6 / 2.0f), a[1] - (f6 / 2.0f), a[0] + (f6 / 2.0f), a[1] + (f6 / 2.0f));
}
invalidate();
}
public float getCurrentMax() {
return this.J;
}
public float getCurrentMin() {
return this.I;
}
@Override // android.view.View
protected void onDraw(Canvas canvas) {
canvas.drawArc(this.u, 152.0f, 236.0f, false, this.l);
double d = this.O;
double d2 = this.N;
double d3 = 0.0d;
if (d == d2) {
d3 = 0.11d;
setAngle(a(false));
} else if (d2 >= 90.0d || d < 360.0d || d - 360.0d < d2) {
double d4 = this.N;
if (d4 < 90.0d) {
double d5 = this.O;
if (d5 <= 360.0d) {
d3 = (360.0d - d5) + d4;
setAngle(a(true));
d2 = d5;
}
}
double d6 = this.O;
if (d6 >= 360.0d) {
double d7 = this.N;
if (d7 < 90.0d && d6 - 360.0d <= d7) {
setAngle(a(true));
d2 = d6 - 360.0d;
d3 = d7 - (d6 - 360.0d);
}
}
double d8 = this.N;
if (d8 > 90.0d && d8 <= 360.0d) {
double d9 = this.O;
if (d9 > 90.0d && d8 < d9) {
d3 = d9 - d8;
setAngle(a(false));
d2 = d8;
}
}
double d10 = this.N;
double d11 = this.O;
if (d10 <= d11 || d10 <= 90.0d || d11 <= 90.0d) {
d2 = 0.0d;
} else {
d3 = d10 - d11;
setAngle(a(true));
d2 = d11;
}
} else {
d3 = (d - 360.0d) - d2;
setAngle(a(false));
}
canvas.drawArc(this.v, (float) d2, (float) d3, false, this.m);
LogUtils.c("isOnClickStartIcon:" + this.L);
if (this.L) {
canvas.drawBitmap(this.F, this.b0, this.n);
canvas.drawBitmap(this.E, (Rect) null, this.y, this.n);
} else {
canvas.drawBitmap(this.E, (Rect) null, this.y, this.n);
canvas.drawBitmap(this.F, this.b0, this.n);
}
canvas.drawBitmap(this.G, (Rect) null, this.z, this.s);
canvas.drawBitmap(this.G, (Rect) null, this.A, this.q);
canvas.drawBitmap(this.H, (Rect) null, this.B, this.t);
canvas.drawBitmap(this.H, (Rect) null, this.C, this.r);
canvas.drawText(this.V, this.A.centerX(), this.P - this.f, this.o);
canvas.drawText(this.W, this.z.centerX(), this.P - this.f, this.o);
canvas.drawText(this.R, this.z.centerX(), this.P + this.f, this.p);
canvas.drawText(this.S, this.A.centerX(), this.P + this.f, this.p);
super.onDraw(canvas);
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec((int) this.c0, 1073741824);
super.onMeasure(makeMeasureSpec, makeMeasureSpec);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action != 0) {
if (action == 2) {
float x = motionEvent.getX();
float y = motionEvent.getY();
float centerX = this.u.centerX();
float centerY = this.u.centerY();
if (!this.L) {
this.x.centerX();
this.x.centerY();
if (this.d0) {
LogUtils.c("按下微调箭头,不响应滑动计算事件");
return super.onTouchEvent(motionEvent);
}
float[] c = c(x, y);
RectF rectF = this.x;
float f = c[0];
float f2 = this.i;
rectF.offsetTo(f - (f2 / 2.0f), c[1] - (f2 / 2.0f));
this.O = 360.0f - b(x, y);
if (Math.round(this.O) == 152.0f) {
this.t.setAlpha(60);
} else {
this.t.setAlpha(255);
}
if (Math.round(this.O) == 388.0f) {
this.s.setAlpha(60);
} else {
this.s.setAlpha(255);
}
double a = a(this.O);
this.W = ((int) a) + "°";
AngleUpdateListener angleUpdateListener = this.e0;
if (angleUpdateListener != null) {
angleUpdateListener.d(a);
}
} else {
if (this.d0) {
LogUtils.c("按下微调箭头,不响应滑动计算事件");
return super.onTouchEvent(motionEvent);
}
float[] c2 = c(x, y);
RectF rectF2 = this.y;
float f3 = c2[0];
float f4 = this.h;
rectF2.offsetTo(f3 - (f4 / 2.0f), c2[1] - (f4 / 2.0f));
this.N = d(centerX, centerY);
double a2 = a(this.N);
if (Math.round(this.N) == 28.0f) {
this.q.setAlpha(60);
} else {
this.q.setAlpha(255);
}
if (Math.round(this.N) == 152.0f) {
this.r.setAlpha(60);
} else {
this.r.setAlpha(255);
}
this.V = ((int) a2) + "°";
AngleUpdateListener angleUpdateListener2 = this.e0;
if (angleUpdateListener2 != null) {
angleUpdateListener2.b(a2);
}
}
invalidate();
}
return super.onTouchEvent(motionEvent);
}
float x2 = motionEvent.getX();
float y2 = motionEvent.getY();
float centerX2 = this.x.centerX();
float centerY2 = this.x.centerY();
float centerX3 = this.y.centerX();
float centerY3 = this.y.centerY();
this.d0 = false;
if (this.L) {
float f5 = this.h;
if (x2 >= centerX3 - (f5 / 2.0f) && x2 <= centerX3 + (f5 / 2.0f) && y2 >= centerY3 - (f5 / 2.0f) && y2 <= centerY3 + (f5 / 2.0f)) {
this.L = true;
return true;
}
float f6 = this.i;
if (x2 >= centerX2 - (f6 / 2.0f) && x2 <= centerX2 + (f6 / 2.0f) && y2 >= centerY2 - (f6 / 2.0f) && y2 <= centerY2 + (f6 / 2.0f)) {
this.L = false;
return true;
}
} else {
float f7 = this.i;
if (x2 >= centerX2 - (f7 / 2.0f) && x2 <= centerX2 + (f7 / 2.0f) && y2 >= centerY2 - (f7 / 2.0f) && y2 <= centerY2 + (f7 / 2.0f)) {
this.L = false;
return true;
}
float f8 = this.h;
if (x2 >= centerX3 - (f8 / 2.0f) && x2 <= centerX3 + (f8 / 2.0f) && y2 >= centerY3 - (f8 / 2.0f) && y2 <= centerY3 + (f8 / 2.0f)) {
this.L = true;
return true;
}
}
float centerX4 = this.A.centerX();
float centerY4 = this.A.centerY();
float f9 = this.a;
float f10 = this.a0;
if (x2 >= (centerX4 - (f9 / 2.0f)) - f10 && x2 <= centerX4 + (f9 / 2.0f) + f10) {
float f11 = this.b;
if (y2 >= (centerY4 - (f11 / 2.0f)) - f10 && y2 <= centerY4 + (f11 / 2.0f) + f10) {
this.L = false;
this.d0 = true;
this.N += 1.0d;
double d = this.N;
if (d < 28.0d || d >= 152.0d) {
double d2 = this.N;
double d3 = this.O;
if (d2 == d3) {
this.N = d3;
} else if (d2 < 0.0d) {
this.N = 360.0d;
} else if (d2 > 360.0d) {
this.N = d2 - 360.0d;
}
} else {
this.N = 28.0d;
}
double a3 = a(this.N);
this.V = ((int) a3) + "°";
float[] a4 = a((float) this.N);
RectF rectF3 = this.y;
float f12 = a4[0];
float f13 = this.h;
rectF3.set(f12 - (f13 / 2.0f), a4[1] - (f13 / 2.0f), a4[0] + (f13 / 2.0f), a4[1] + (f13 / 2.0f));
if (a3 >= 118.0d) {
this.q.setAlpha(60);
} else {
this.q.setAlpha(255);
}
this.r.setAlpha(225);
invalidate();
AngleUpdateListener angleUpdateListener3 = this.e0;
if (angleUpdateListener3 != null) {
angleUpdateListener3.b(a3);
}
return true;
}
}
float centerX5 = this.C.centerX();
float centerY5 = this.C.centerY();
float f14 = this.a;
float f15 = this.a0;
if (x2 >= (centerX5 - (f14 / 2.0f)) - f15 && x2 <= centerX5 + (f14 / 2.0f) + f15) {
float f16 = this.b;
if (y2 >= (centerY5 - (f16 / 2.0f)) - f15 && y2 <= centerY5 + (f16 / 2.0f) + f15) {
this.L = false;
this.d0 = true;
this.N -= 1.0d;
double d4 = this.N;
if (d4 <= 28.0d || d4 >= 152.0d) {
double d5 = this.N;
double d6 = this.O;
if (d5 == d6) {
this.N = d6;
} else if (d5 < 0.0d) {
this.N = 360.0d;
}
} else {
this.N = 152.0d;
}
double a5 = a(this.N);
this.V = ((int) a5) + "°";
float[] a6 = a((float) this.N);
RectF rectF4 = this.y;
float f17 = a6[0];
float f18 = this.h;
rectF4.set(f17 - (f18 / 2.0f), a6[1] - (f18 / 2.0f), a6[0] + (f18 / 2.0f), a6[1] + (f18 / 2.0f));
if (a5 <= this.T) {
this.r.setAlpha(60);
} else {
this.r.setAlpha(225);
}
this.q.setAlpha(255);
invalidate();
AngleUpdateListener angleUpdateListener4 = this.e0;
if (angleUpdateListener4 != null) {
angleUpdateListener4.b(a5);
}
return true;
}
}
float centerX6 = this.B.centerX();
float centerY6 = this.B.centerY();
float f19 = this.a;
float f20 = this.a0;
if (x2 >= (centerX6 - (f19 / 2.0f)) - f20 && x2 <= centerX6 + (f19 / 2.0f) + f20) {
float f21 = this.b;
if (y2 >= (centerY6 - (f21 / 2.0f)) - f20 && y2 <= centerY6 + (f21 / 2.0f) + f20) {
this.L = true;
this.d0 = true;
this.O -= 1.0d;
double d7 = this.O;
double d8 = this.N;
if (d7 == d8) {
this.O = d8;
} else if (d7 > 28.0d && d7 <= 152.0d) {
this.O = 152.0d;
} else if (this.O < 0.0d) {
this.O = 360.0d;
}
Log.e("Test", "最小值角度+1 progressEndAngle-Down" + this.O + " 28.0 152.0");
double a7 = a(this.O);
if (a7 <= this.T) {
this.t.setAlpha(60);
} else {
this.t.setAlpha(255);
}
this.s.setAlpha(225);
float[] b = b((float) a7);
this.W = ((int) a7) + "°";
if (b != null) {
RectF rectF5 = this.x;
float f22 = b[0];
float f23 = this.i;
rectF5.set(f22 - (f23 / 2.0f), b[1] - (f23 / 2.0f), b[0] + (f23 / 2.0f), b[1] + (f23 / 2.0f));
}
invalidate();
AngleUpdateListener angleUpdateListener5 = this.e0;
if (angleUpdateListener5 != null) {
angleUpdateListener5.d(a7);
}
return true;
}
}
float centerX7 = this.z.centerX();
float centerY7 = this.z.centerY();
float f24 = this.a;
float f25 = this.a0;
if (x2 >= (centerX7 - (f24 / 2.0f)) - f25 && x2 <= centerX7 + (f24 / 2.0f) + f25) {
float f26 = this.b;
if (y2 >= (centerY7 - (f26 / 2.0f)) - f25 && y2 <= centerY7 + (f26 / 2.0f) + f25) {
this.L = true;
this.d0 = true;
this.O += 1.0d;
double d9 = this.O;
if (d9 > 360.0d) {
this.O = d9 - 360.0d;
}
double d10 = this.O;
if (d10 < 28.0d || d10 >= 152.0d) {
double d11 = this.O;
double d12 = this.N;
if (d11 == d12) {
this.O = d12;
}
} else {
this.O = 28.0d;
}
double a8 = a(this.O);
if (a8 >= 118.0d) {
this.s.setAlpha(60);
} else {
this.s.setAlpha(255);
}
this.t.setAlpha(225);
float[] b2 = b((float) a8);
this.W = ((int) a8) + "°";
if (b2 != null) {
RectF rectF6 = this.x;
float f27 = b2[0];
float f28 = this.i;
rectF6.set(f27 - (f28 / 2.0f), b2[1] - (f28 / 2.0f), b2[0] + (f28 / 2.0f), b2[1] + (f28 / 2.0f));
}
invalidate();
AngleUpdateListener angleUpdateListener6 = this.e0;
if (angleUpdateListener6 != null) {
angleUpdateListener6.d(a8);
}
return true;
}
}
return super.onTouchEvent(motionEvent);
}
public void setAngleUpdateListener(AngleUpdateListener angleUpdateListener) {
this.e0 = angleUpdateListener;
}
public void setCurrentMax(float f) {
this.J = f;
}
public void setCurrentMin(float f) {
this.I = f;
}
public TensionAngleSetView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.j = 0.0f;
this.k = 0.0f;
this.T = -118.0f;
this.U = 118.0f;
this.D = context;
a();
}
public void a() {
float f;
this.V = ((int) this.T) + "°";
this.W = ((int) this.U) + "°";
this.a0 = this.D.getResources().getDimension(R.dimen.arrow_down_offset);
this.a = this.D.getResources().getDimension(R.dimen.arrow_width);
this.b = this.D.getResources().getDimension(R.dimen.arrow_height);
this.c = this.D.getResources().getDimension(R.dimen.arrow_sides_x);
this.d = this.D.getResources().getDimension(R.dimen.arrow_sides_y);
this.e = this.D.getResources().getDimension(R.dimen.arrow_sides_down_y);
this.f = this.D.getResources().getDimension(R.dimen.angle_text_margin_top);
this.K = this.D.getResources().getDimension(R.dimen.angle_set_progress_width);
this.g = this.D.getResources().getDimension(R.dimen.angle_set_view_width);
this.c0 = this.D.getResources().getDimension(R.dimen.angle_set_view_width) + getResources().getDimension(R.dimen.angle_set_match);
this.j = getResources().getDimension(R.dimen.top_match);
this.k = getResources().getDimension(R.dimen.top_match);
this.h = this.K;
this.i = this.D.getResources().getDimension(R.dimen.start_arrows_wh);
this.R = this.D.getResources().getString(R.string.ejector_value);
this.S = this.D.getResources().getString(R.string.default_value);
this.o = new Paint();
this.o.setAntiAlias(true);
this.o.setColor(this.D.getResources().getColor(R.color.txt_596F80));
this.o.setTextSize(this.D.getResources().getDimension(R.dimen.angle_text_size));
this.o.setTextAlign(Paint.Align.CENTER);
this.p = new Paint();
this.p.setAntiAlias(true);
this.p.setColor(this.D.getResources().getColor(R.color.txt_596F80));
this.p.setTextSize(this.D.getResources().getDimension(R.dimen.angle_text_hint_size));
this.p.setTextAlign(Paint.Align.CENTER);
this.n = new Paint();
this.n.setFlags(3);
this.q = new Paint();
this.q.setFlags(3);
this.r = new Paint();
this.r.setFlags(3);
this.r.setAlpha(60);
this.s = new Paint();
this.s.setFlags(3);
this.s.setAlpha(60);
this.t = new Paint();
this.t.setFlags(3);
this.M = new Paint();
this.M.setColor(-16776961);
this.l = new Paint();
this.l.setColor(this.D.getResources().getColor(R.color.bg_3396A6B4));
this.l.setFlags(3);
this.l.setStrokeWidth(this.K);
this.l.setStyle(Paint.Style.STROKE);
this.l.setStrokeCap(Paint.Cap.ROUND);
this.m = new Paint();
this.m.setShader(new LinearGradient(0.0f, 0.0f, this.g + 500.0f, 0.0f, new int[]{this.D.getResources().getColor(R.color.color_FF4979), this.D.getResources().getColor(R.color.bg_F0553E)}, (float[]) null, Shader.TileMode.CLAMP));
this.m.setFlags(3);
this.m.setStrokeWidth(this.K);
this.m.setStyle(Paint.Style.STROKE);
this.m.setStrokeCap(Paint.Cap.BUTT);
float f2 = this.j;
float f3 = this.k;
float f4 = this.K;
float f5 = this.g;
this.u = new RectF(f2, f3 + f4, f2 + f5, f3 + f5 + f4);
float f6 = this.j;
float f7 = this.k;
float f8 = this.K;
float f9 = this.g;
this.v = new RectF(f6, f7 + f8, f6 + f9, f7 + f9 + f8);
this.b0 = new Matrix();
this.Q = this.u.centerX();
this.P = this.u.centerY();
float[] a = a(this.T, DataType.START);
float f10 = a[0];
float f11 = a[1];
float[] b = b(this.U);
float f12 = 0.0f;
if (b != null) {
f12 = b[0];
f = b[1];
} else {
f = 0.0f;
}
float f13 = this.h;
this.y = new RectF(f10 - (f13 / 2.0f), f11 - (f13 / 2.0f), f10 + (f13 / 2.0f), f11 + (f13 / 2.0f));
float f14 = this.Q;
float f15 = this.c;
float f16 = this.a;
float f17 = this.P;
float f18 = this.d;
float f19 = this.b;
this.z = new RectF((f14 + f15) - (f16 / 2.0f), (f17 - f18) - (f19 / 2.0f), f14 + f15 + (f16 / 2.0f), (f17 - f18) + (f19 / 2.0f));
float f20 = this.Q;
float f21 = this.c;
float f22 = this.a;
float f23 = this.P;
float f24 = this.d;
float f25 = this.b;
this.A = new RectF((f20 - f21) - (f22 / 2.0f), (f23 - f24) - (f25 / 2.0f), (f20 - f21) + (f22 / 2.0f), (f23 - f24) + (f25 / 2.0f));
float f26 = this.Q;
float f27 = this.c;
float f28 = this.a;
float f29 = this.P;
float f30 = this.e;
float f31 = this.b;
this.B = new RectF((f26 + f27) - (f28 / 2.0f), (f29 + f30) - (f31 / 2.0f), f26 + f27 + (f28 / 2.0f), f29 + f30 + (f31 / 2.0f));
float f32 = this.Q;
float f33 = this.c;
float f34 = this.a;
float f35 = this.P;
float f36 = this.e;
float f37 = this.b;
this.C = new RectF((f32 - f33) - (f34 / 2.0f), (f35 + f36) - (f37 / 2.0f), (f32 - f33) + (f34 / 2.0f), f35 + f36 + (f37 / 2.0f));
this.E = BitmapFactory.decodeResource(this.D.getResources(), R.drawable.tension_start);
Context context = this.D;
float f38 = this.i;
this.F = BitmapUtils.a(context, R.drawable.tension_end, (int) f38, (int) f38);
float f39 = this.i;
this.x = new RectF(f12 - (f39 / 2.0f), f - (f39 / 2.0f), f12 + (f39 / 2.0f), f + (f39 / 2.0f));
this.G = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.arrow_up);
this.H = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.arrow_down);
}
private float b(float f, float f2) {
float centerX = this.u.centerX();
double degrees = Math.toDegrees(Math.atan((this.u.centerY() - f2) / (f - centerX)));
if (f <= centerX) {
degrees += 180.0d;
}
double d = -28.0f;
if (degrees >= d) {
d = degrees >= 208.0d ? 208.0d : degrees;
}
return (float) d;
}
private float[] a(float f, DataType dataType) {
float f2;
float f3;
float abs = (Math.abs(118.0f) + Math.abs(-118.0f)) / 236.0f;
if (dataType == DataType.START) {
f2 = (abs * (f - (-118.0f))) + 152.0f;
this.N = f2;
double d = this.N;
if (d > 360.0d) {
this.N = d - 360.0d;
}
f3 = f2;
} else {
f2 = (abs * (118.0f - f)) + 236.0f;
this.O = f2 + this.N;
double d2 = this.O;
f3 = d2 > 360.0d ? (float) (d2 - 360.0d) : 0.0f;
LogUtils.c("launchLimitAngleangleDeviation" + f2 + " progressEndAngle:" + this.O);
}
if (f3 >= 90.0f && f3 <= 180.0f) {
float f4 = 180.0f - f3;
double radians = Math.toRadians(f4);
double sin = Math.sin(radians) * (this.g / 2.0f);
float f5 = (float) (this.P + sin);
float cos = (float) (this.Q - (Math.cos(radians) * (this.g / 2.0f)));
Log.e("Test", "minBallX:" + cos + " minBallY:" + f5 + " radiansA" + f4);
return new float[]{cos, f5};
}
if (f3 > 180.0f && f3 <= 270.0f) {
float f6 = f2 - 180.0f;
double radians2 = Math.toRadians(f6);
double sin2 = Math.sin(radians2) * (this.g / 2.0f);
float f7 = (float) (this.P - sin2);
float cos2 = (float) (this.Q - (Math.cos(radians2) * (this.g / 2.0f)));
Log.e("Test", "minBallX:" + cos2 + " minBallY:" + f7 + " radiansA" + f6);
return new float[]{cos2, f7};
}
if (f3 > 270.0f && f3 <= 360.0f) {
float f8 = f2 - 270.0f;
double radians3 = Math.toRadians(f8);
double sin3 = Math.sin(radians3) * (this.g / 2.0f);
float cos3 = (float) (this.P - (Math.cos(radians3) * (this.g / 2.0f)));
float f9 = (float) (this.Q + sin3);
Log.e("Test", "minBallX:" + f9 + " minBallY:" + cos3 + " radiansA" + f8);
return new float[]{f9, cos3};
}
if (f3 >= 360.0f) {
float f10 = f2 - 360.0f;
double radians4 = Math.toRadians(f10);
double sin4 = Math.sin(radians4) * (this.g / 2.0f);
float f11 = (float) (this.P + sin4);
float cos4 = (float) (this.Q + (Math.cos(radians4) * (this.g / 2.0f)));
Log.e("Test", "minBallX:" + cos4 + " minBallY:" + f11 + " radiansA" + f10);
return new float[]{cos4, f11};
}
double radians5 = Math.toRadians(28.0f);
double sin5 = Math.sin(radians5) * (this.g / 2.0f);
float cos5 = (float) (this.Q - (Math.cos(radians5) * (this.g / 2.0f)));
float f12 = (float) (sin5 + this.P);
this.N = 152.0d;
this.O = 28.0d;
return new float[]{cos5, f12};
}
private float[] a(float f) {
if (f >= 90.0f && f <= 180.0f) {
float f2 = 180.0f - f;
double radians = Math.toRadians(f2);
double sin = Math.sin(radians) * (this.g / 2.0f);
float f3 = (float) (this.P + sin);
float cos = (float) (this.Q - (Math.cos(radians) * (this.g / 2.0f)));
Log.e("Test", "minBallX:" + cos + " minBallY:" + f3 + " radiansA" + f2);
return new float[]{cos, f3};
}
if (f > 180.0f && f <= 270.0f) {
float f4 = f - 180.0f;
double radians2 = Math.toRadians(f4);
double sin2 = Math.sin(radians2) * (this.g / 2.0f);
float f5 = (float) (this.P - sin2);
float cos2 = (float) (this.Q - (Math.cos(radians2) * (this.g / 2.0f)));
Log.e("Test", "minBallX:" + cos2 + " minBallY:" + f5 + " radiansA" + f4);
return new float[]{cos2, f5};
}
if (f > 270.0f && f <= 360.0f) {
double radians3 = Math.toRadians(f - 270.0f);
return new float[]{(float) (this.Q + (Math.sin(radians3) * (this.g / 2.0f))), (float) (this.P - (Math.cos(radians3) * (this.g / 2.0f)))};
}
if (f >= 0.0f && f < 90.0f) {
double radians4 = Math.toRadians(f);
return new float[]{(float) (this.Q + (Math.cos(radians4) * (this.g / 2.0f))), (float) (this.P + (Math.sin(radians4) * (this.g / 2.0f)))};
}
double radians5 = Math.toRadians(28.0f);
double sin3 = Math.sin(radians5) * (this.g / 2.0f);
float cos3 = (float) (this.Q - (Math.cos(radians5) * (this.g / 2.0f)));
float f6 = (float) (sin3 + this.P);
this.N = 152.0d;
this.O = 28.0d;
return new float[]{cos3, f6};
}
private double a(double d) {
if (Math.round(d) < 152.0f) {
d += 360.0d;
}
return Math.round((d - 152.0d) * 1.0d) - 118.0d;
}
public float a(boolean z) {
float degrees = (float) Math.toDegrees(Math.atan2(this.u.centerX() - this.x.centerX(), this.u.centerY() - this.x.centerY()));
return !z ? degrees + 180.0f : degrees;
}
}

View File

@@ -0,0 +1,335 @@
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.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.View;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.data.config.SliderConfig;
import com.ubt.jimu.controller.data.widget.SliderWidgetData;
import com.ubt.jimu.controller.manager.CommandSendManager;
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
import com.ubt.jimu.controller.view.control.SuperControlView;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
/* loaded from: classes.dex */
public class VSliderView extends SuperControlView<SliderWidgetData> {
private Paint B;
private Context C;
private Bitmap D;
private Bitmap E;
private RectF F;
private float G;
private float H;
private float I;
private RectF J;
private float K;
private float L;
private float M;
private long N;
private CommandSendManager O;
private float P;
private float Q;
private float R;
private float S;
public VSliderView(Context context, float f, float f2) {
super(context);
this.N = System.currentTimeMillis();
this.C = context;
this.G = f;
this.H = f2;
f();
h();
g();
this.O = new CommandSendManager();
}
private void b(float f, float f2) {
this.F.offsetTo(f, f2);
this.j.offsetTo(f, f2);
this.J.offsetTo(this.F.centerX() - (this.I / 2.0f), this.F.centerY() - (this.I / 2.0f));
}
private void f() {
this.B = new Paint();
this.B.setFlags(3);
}
private void g() {
this.m = this.C.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
this.D.getWidth();
this.D.getHeight();
float f = this.m;
this.l = f / 2.0f;
this.K = this.l / 2.0f;
this.L = f / 2.0f;
this.I = this.C.getResources().getDimension(R.dimen.controlBallWidthOrHeight);
float f2 = this.H;
float f3 = this.m;
float f4 = f2 + (f3 / 2.0f);
int i = this.s;
if (f4 >= i) {
this.H = i - (f3 / 2.0f);
}
float f5 = this.G;
float f6 = this.l;
if (f5 - (f6 / 2.0f) <= 0.0f) {
this.G = f6 / 2.0f;
} else {
float f7 = f5 + (f6 / 2.0f);
int i2 = this.r;
if (f7 >= i2) {
this.G = i2 - (f6 / 2.0f);
}
}
float f8 = this.G;
float f9 = this.l;
float f10 = this.H;
float f11 = this.m;
this.F = new RectF(f8 - (f9 / 2.0f), f10 - (f11 / 2.0f), (f9 / 2.0f) + f8, (f11 / 2.0f) + f10);
float centerX = this.F.centerX();
float centerY = this.F.centerY();
float f12 = this.I;
this.J = new RectF(centerX - (f12 / 2.0f), centerY - (f12 / 2.0f), centerX + (f12 / 2.0f), centerY + (f12 / 2.0f));
}
private void h() {
this.D = BitmapFactory.decodeResource(this.C.getResources(), R.mipmap.bg_v_slider);
this.E = BitmapFactory.decodeResource(this.C.getResources(), R.mipmap.slider_ball);
}
public boolean a(RectF rectF) {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, rectF);
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public float[] getViewCenterXY() {
return new float[]{this.F.centerX(), this.F.centerY()};
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawBitmap(this.D, (Rect) null, this.F, this.B);
canvas.drawBitmap(this.E, (Rect) null, this.J, this.B);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == 0) {
this.t = System.currentTimeMillis();
this.R = motionEvent.getX();
this.S = motionEvent.getY();
super.d();
this.f = false;
if (!b()) {
float centerX = this.J.centerX();
float centerY = this.J.centerY();
float f = this.I;
float f2 = centerX - (f / 2.0f);
float f3 = centerX + (f / 2.0f);
float f4 = centerY - (f / 2.0f);
float f5 = centerY + (f / 2.0f);
float f6 = this.R;
if (f6 >= f2 && f6 <= f3) {
float f7 = this.S;
if (f7 >= f4 && f7 <= f5) {
this.O.a((CommandSendManager) getData());
this.O.a();
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.a((SuperControlView) this);
}
}
}
return super.onTouchEvent(motionEvent);
}
float centerX2 = this.F.centerX();
float centerY2 = this.F.centerY();
float f8 = this.K;
float f9 = centerX2 - f8;
float f10 = centerX2 + f8;
float f11 = this.L;
float f12 = centerY2 - f11;
float f13 = centerY2 + f11;
float f14 = this.R;
if (f14 >= f9 && f14 <= f10) {
float f15 = this.S;
if (f15 >= f12 && f15 <= f13) {
this.P = super.a(f14);
this.Q = super.b(this.S);
bringToFront();
ControlTouchEvent controlTouchEvent2 = this.i;
if (controlTouchEvent2 != null) {
controlTouchEvent2.a((View) this);
}
}
}
return super.onTouchEvent(motionEvent);
return true;
}
if (action == 1) {
if (!this.f) {
this.f = true;
b(motionEvent);
}
return true;
}
if (action != 2) {
if (action == 3 && !this.f) {
this.f = true;
b(motionEvent);
}
return true;
}
if (b()) {
b(super.a(motionEvent, this.P), super.b(motionEvent, this.Q));
if (this.i != null) {
float abs = Math.abs(motionEvent.getX() - this.R);
float abs2 = Math.abs(motionEvent.getY() - this.S);
if (abs <= 10.0f && abs2 <= 10.0f) {
return true;
}
this.i.b((View) this);
if (a(this.j)) {
b(false);
if (this.e != null && getData() != null) {
this.e.setOverlapState(true);
this.e.a(String.format(this.C.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.C)));
}
this.b.setColor(this.C.getResources().getColor(R.color.color_FF4979));
if (!this.n) {
SystemUtils.b(this.C);
this.n = true;
}
} else {
if (this.e != null && getData() != null) {
this.e.setOverlapState(false);
this.e.a(String.format(this.C.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.C)));
}
RectF rectF = this.F;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
b(false);
this.b.setColor(this.C.getResources().getColor(R.color.bg_99B8BEC1));
} else {
b(true);
this.b.setColor(this.C.getResources().getColor(this.a));
}
this.n = false;
}
}
} else {
float y = motionEvent.getY();
float centerX3 = this.F.centerX();
float centerY3 = this.F.centerY();
float f16 = this.L;
float f17 = this.I;
float f18 = (centerY3 - f16) + (f17 / 2.0f);
float f19 = (centerY3 + f16) - (f17 / 2.0f);
if (y < f18) {
y = f18;
}
if (y > f19) {
y = f19;
}
RectF rectF2 = this.J;
float f20 = this.I;
rectF2.offsetTo(centerX3 - (f20 / 2.0f), y - (f20 / 2.0f));
this.M = this.J.centerX() - this.F.centerX();
if (System.currentTimeMillis() - this.N > 200) {
this.N = System.currentTimeMillis();
}
a(motionEvent);
}
invalidate();
return true;
}
public void setUpdateCommandParameterListener(CommandSendManager.VSliderViewCommandSendListener vSliderViewCommandSendListener) {
this.O.a(vSliderViewCommandSendListener);
}
public void a(MotionEvent motionEvent) {
float[] viewCenterXY = getViewCenterXY();
if (viewCenterXY == null || viewCenterXY.length < 2) {
return;
}
float y = motionEvent.getY() - viewCenterXY[1];
float f = viewCenterXY[1];
float f2 = this.L;
float f3 = this.I;
float f4 = (((viewCenterXY[1] + f2) - (f3 / 2.0f)) - ((f - f2) + (f3 / 2.0f))) / 2.0f;
float f5 = -f4;
if (y <= f5) {
y = f5;
} else if (y >= f4) {
y = f4;
}
this.O.a(-((y / f4) * 100.0f));
if (motionEvent.getAction() == 1 || motionEvent.getAction() == 3) {
this.O.b();
}
}
private void b(MotionEvent motionEvent) {
SliderWidgetData data;
SliderConfig config;
if (b()) {
boolean a = a(this.j);
LogUtils.c("isDelete:");
if (a) {
if (this.i != null && (data = getData()) != null && (config = data.getConfig()) != null) {
this.i.a(this, config.getConfigID());
this.i.c((View) this);
}
invalidate();
return;
}
if (this.i != null) {
RectF rectF = this.F;
PointF a2 = a(rectF.left, rectF.top);
this.k.offsetTo(a2.x, a2.y);
if (this.i.c((SuperControlView) this)) {
b(this.o, this.p);
this.b.setColor(this.C.getResources().getColor(this.a));
} else {
b(a2.x, a2.y);
this.i.a(this, this.F.centerX(), this.F.centerY());
}
this.i.c((View) this);
if (System.currentTimeMillis() - this.t < 350) {
this.i.a(this, getData());
}
}
b(false);
} else {
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.b((SuperControlView) this);
}
float centerX = this.F.centerX();
float centerY = this.F.centerY();
RectF rectF2 = this.J;
float f = centerX + this.M;
float f2 = this.I;
rectF2.offsetTo(f - (f2 / 2.0f), centerY - (f2 / 2.0f));
a(motionEvent);
}
invalidate();
}
}

View File

@@ -0,0 +1,550 @@
package com.ubt.jimu.controller.component;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.BounceInterpolator;
import android.view.animation.LinearInterpolator;
import androidx.core.content.ContextCompat;
import com.ubt.jimu.R;
import com.ubt.jimu.controller.data.config.AccumulatorConfig;
import com.ubt.jimu.controller.data.widget.AccumulatorData;
import com.ubt.jimu.controller.view.control.ControlTouchEvent;
import com.ubt.jimu.controller.view.control.SuperControlView;
import com.ubt.jimu.utils.BitmapUtils;
import com.ubt.jimu.utils.LogUtils;
import com.ubt.jimu.utils.SystemUtils;
/* loaded from: classes.dex */
public class WallPulleyView extends SuperControlView<AccumulatorData> {
private Bitmap B;
private Bitmap C;
private Context D;
private Paint E;
private Paint F;
private Paint G;
private RectF H;
private RectF I;
private RectF J;
private RectF K;
private RectF L;
private RectF M;
private float N;
private float O;
private float P;
private float Q;
private float R;
private float S;
private float T;
private float U;
private float V;
private float W;
private float a0;
private float b0;
private float c0;
private float d0;
private float e0;
private float f0;
private float g0;
private float h0;
private WallPulleyViewCommandParameterListener i0;
public interface WallPulleyViewCommandParameterListener {
void a(float f, AccumulatorData accumulatorData);
void b(float f, AccumulatorData accumulatorData);
}
public WallPulleyView(Context context, float f, float f2) {
super(context);
this.R = 900.0f;
this.S = 400.0f;
this.e0 = 90.0f;
this.f0 = 0.0f;
this.g0 = 90.0f;
this.h0 = 0.0f;
this.D = context;
this.R = f;
this.S = f2;
h();
}
private void c(float f, float f2) {
float centerY = this.M.centerY() - (f2 - (this.Q / 2.0f));
if (centerY < 5.0f) {
centerY = 0.0f;
}
float f3 = this.T * centerY;
double d = (f3 * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
if (d >= 90.0d) {
d = 90.0d;
}
this.e0 = (float) (90.0d - d);
this.f0 = ((float) d) * 2.0f;
float arcLength = getArcLength();
float f4 = this.T;
float f5 = arcLength / f4;
float f6 = (this.Q - f5) * f4;
float centerY2 = this.J.centerY();
float centerY3 = this.K.centerY();
if (f3 >= arcLength && f6 >= f3) {
float f7 = centerY2 - ((centerY - f5) * this.T);
RectF rectF = this.L;
float f8 = this.N;
rectF.set(f - (f8 / 2.0f), f7, f + (f8 / 2.0f), centerY2);
this.g0 = 90.0f;
this.h0 = 0.0f;
} else if (f6 < f3) {
double d2 = ((f3 - f6) * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
this.g0 = (float) (360.0d - d2);
this.h0 = (float) ((d2 * 2.0d) + 180.0d);
RectF rectF2 = this.L;
float f9 = this.N;
rectF2.set(f - (f9 / 2.0f), centerY3, f + (f9 / 2.0f), centerY2);
} else {
RectF rectF3 = this.L;
float f10 = this.N;
rectF3.set(f - (f10 / 2.0f), 0.0f, f + (f10 / 2.0f), 0.0f);
}
this.W = centerY / this.Q;
}
/* JADX INFO: Access modifiers changed from: private */
public void d(float f, float f2) {
float f3 = this.T * f;
double d = (f3 * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
if (d >= 90.0d) {
d = 90.0d;
}
this.e0 = (float) (90.0d - d);
this.f0 = ((float) d) * 2.0f;
float arcLength = getArcLength();
float f4 = this.T;
float f5 = arcLength / f4;
float f6 = (this.Q - f5) * f4;
float centerY = this.J.centerY();
float centerY2 = this.K.centerY();
if (f3 >= arcLength && f6 >= f3) {
float f7 = centerY - ((f - f5) * this.T);
RectF rectF = this.L;
float f8 = this.N;
rectF.set(f2 - (f8 / 2.0f), f7, f2 + (f8 / 2.0f), centerY);
this.g0 = 90.0f;
this.h0 = 0.0f;
} else if (f6 < f3) {
double d2 = ((f3 - f6) * 180.0f) / ((this.P * 3.141592653589793d) / 2.0d);
this.g0 = (float) (360.0d - d2);
this.h0 = (float) ((d2 * 2.0d) + 180.0d);
RectF rectF2 = this.L;
float f9 = this.N;
rectF2.set(f2 - (f9 / 2.0f), centerY2, f2 + (f9 / 2.0f), centerY);
} else {
RectF rectF3 = this.L;
float f10 = this.N;
rectF3.set(f2 - (f10 / 2.0f), 0.0f, f2 + (f10 / 2.0f), 0.0f);
}
this.W = f / this.Q;
}
private void g() {
this.B = BitmapUtils.a(ContextCompat.c(this.D, R.mipmap.wall_pulley));
this.C = BitmapFactory.decodeResource(this.D.getResources(), R.mipmap.wall_pulley_ball);
}
private float getArcLength() {
return ((float) (this.N * 3.141592653589793d)) / 4.0f;
}
private float getProgressLength() {
float arcLength = getArcLength() * 2.0f;
float f = this.Q + arcLength;
LogUtils.c("progressLength:" + f + " arcLength:" + arcLength);
return f;
}
private float getProgressRatio() {
return getProgressLength() / this.Q;
}
private void h() {
i();
g();
j();
k();
}
private void i() {
this.E = new Paint();
this.F = new Paint();
this.G = new Paint();
this.E.setFlags(3);
this.F.setFlags(3);
this.G.setFlags(3);
this.F.setColor(this.D.getResources().getColor(R.color.bg_D3EEFF));
this.G.setColor(this.D.getResources().getColor(R.color.color_00C4C9));
}
private void j() {
this.m = this.D.getResources().getDimension(R.dimen.grid_view_width) * 8.0f;
float f = this.m;
this.l = f / 2.0f;
float f2 = this.S + (f / 2.0f);
int i = this.s;
if (f2 >= i) {
this.S = i - (f / 2.0f);
}
float f3 = this.R;
float f4 = this.l;
if (f3 - (f4 / 2.0f) <= 0.0f) {
this.R = f4 / 2.0f;
} else {
float f5 = f3 + (f4 / 2.0f);
int i2 = this.r;
if (f5 >= i2) {
this.R = i2 - (f4 / 2.0f);
}
}
float f6 = this.l;
this.U = f6 / 2.0f;
float f7 = this.m;
this.V = f7 / 2.0f;
this.N = f6 * 0.79f;
this.O = f7 * 0.87f;
this.P = this.D.getResources().getDimension(R.dimen.ball_width_height);
this.Q = this.m * 0.47f;
this.T = getProgressRatio();
}
private void k() {
float f = this.R;
float f2 = this.l;
float f3 = this.S;
float f4 = this.m;
this.H = new RectF(f - (f2 / 2.0f), f3 - (f4 / 2.0f), f + (f2 / 2.0f), f3 + (f4 / 2.0f));
float centerX = this.H.centerX();
float centerY = this.H.centerY();
float f5 = this.N;
float f6 = this.O;
this.I = new RectF(centerX - (f5 / 2.0f), centerY - (f6 / 2.0f), (f5 / 2.0f) + centerX, (f6 / 2.0f) + centerY);
float f7 = this.O;
float f8 = (f7 / 2.0f) + centerY;
float f9 = centerY - (f7 / 2.0f);
float f10 = this.N;
this.J = new RectF(centerX - (f10 / 2.0f), f8 - f10, (f10 / 2.0f) + centerX, f8);
float f11 = this.N;
this.L = new RectF(centerX - (f11 / 2.0f), 0.0f, (f11 / 2.0f) + centerX, 0.0f);
float f12 = this.N;
this.K = new RectF(centerX - (f12 / 2.0f), f9, (f12 / 2.0f) + centerX, f12 + f9);
float f13 = centerY - (this.Q / 2.0f);
float f14 = this.P;
this.M = new RectF(centerX - (f14 / 2.0f), f13 - (f14 / 2.0f), centerX + (f14 / 2.0f), f13 + (f14 / 2.0f));
}
public void f() {
float centerY = this.M.centerY();
float centerY2 = this.H.centerY();
final float centerX = this.H.centerX();
ValueAnimator ofFloat = ValueAnimator.ofFloat(centerY, centerY2 - (this.Q / 2.0f));
ofFloat.setInterpolator(new BounceInterpolator());
ofFloat.setDuration(300L);
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.1
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
WallPulleyView.this.M.offsetTo(centerX - (WallPulleyView.this.P / 2.0f), ((Float) valueAnimator.getAnimatedValue()).floatValue() - (WallPulleyView.this.P / 2.0f));
WallPulleyView.this.invalidate();
}
});
ofFloat.start();
ValueAnimator ofFloat2 = ValueAnimator.ofFloat(this.Q, 0.0f);
ofFloat2.setInterpolator(new LinearInterpolator());
ofFloat2.setDuration(400L);
ofFloat2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.2
@Override // android.animation.ValueAnimator.AnimatorUpdateListener
public void onAnimationUpdate(ValueAnimator valueAnimator) {
WallPulleyView.this.d(((Float) valueAnimator.getAnimatedValue()).floatValue(), centerX);
WallPulleyView.this.invalidate();
}
});
ofFloat2.addListener(new Animator.AnimatorListener() { // from class: com.ubt.jimu.controller.component.WallPulleyView.3
@Override // android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
LogUtils.c("onAnimationCancel");
WallPulleyView.this.g0 = 0.0f;
WallPulleyView.this.h0 = 0.0f;
WallPulleyView.this.invalidate();
}
@Override // android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
LogUtils.c("onAnimationEnd");
WallPulleyView.this.g0 = 0.0f;
WallPulleyView.this.h0 = 0.0f;
WallPulleyView.this.invalidate();
}
@Override // android.animation.Animator.AnimatorListener
public void onAnimationRepeat(Animator animator) {
LogUtils.c("onAnimationRepeat");
}
@Override // android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
LogUtils.c("动画开始");
}
});
ofFloat2.start();
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView
public float[] getViewCenterXY() {
return new float[]{this.H.centerX(), this.H.centerY()};
}
@Override // com.ubt.jimu.controller.view.control.SuperControlView, android.view.View
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
RectF rectF = this.I;
float f = this.N;
canvas.drawRoundRect(rectF, f / 2.0f, f / 2.0f, this.F);
canvas.drawArc(this.J, this.e0, this.f0, true, this.G);
canvas.drawArc(this.K, this.g0, this.h0, true, this.G);
canvas.drawRect(this.L, this.G);
canvas.drawBitmap(this.B, (Rect) null, this.H, this.E);
canvas.drawBitmap(this.C, (Rect) null, this.M, this.E);
}
@Override // android.view.View
public boolean onTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action == 0) {
this.t = System.currentTimeMillis();
this.c0 = motionEvent.getX();
this.d0 = motionEvent.getY();
float centerX = this.M.centerX();
float centerY = this.M.centerY();
super.d();
this.f = false;
if (!b()) {
float f = this.c0;
float f2 = this.P;
if (f >= centerX - (f2 / 2.0f) && f <= centerX + (f2 / 2.0f)) {
float f3 = this.d0;
if (f3 >= centerY - (f2 / 2.0f) && f3 <= centerY + (f2 / 2.0f)) {
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.a((SuperControlView) this);
}
}
}
LogUtils.c("不可移动");
return super.onTouchEvent(motionEvent);
}
float centerX2 = this.H.centerX();
float centerY2 = this.H.centerY();
float f4 = this.U;
float f5 = centerX2 - f4;
float f6 = centerX2 + f4;
float f7 = this.V;
float f8 = centerY2 - f7;
float f9 = centerY2 + f7;
float f10 = this.c0;
if (f10 >= f5 && f10 <= f6) {
float f11 = this.d0;
if (f11 >= f8 && f11 <= f9) {
this.a0 = super.a(f10);
this.b0 = super.b(this.d0);
bringToFront();
ControlTouchEvent controlTouchEvent2 = this.i;
if (controlTouchEvent2 != null) {
controlTouchEvent2.a((View) this);
}
}
}
return super.onTouchEvent(motionEvent);
return true;
}
if (action == 1) {
if (!this.f) {
LogUtils.c("蓄力器ACTION_UP");
this.f = true;
b(motionEvent);
}
invalidate();
return true;
}
if (action != 2) {
if (action != 3) {
return true;
}
if (!this.f) {
LogUtils.c("蓄力器ACTION_CANCEL");
this.f = true;
b(motionEvent);
}
invalidate();
return true;
}
if (b()) {
b(super.a(motionEvent, this.a0), super.b(motionEvent, this.b0));
if (this.i != null) {
float abs = Math.abs(motionEvent.getX() - this.c0);
float abs2 = Math.abs(motionEvent.getY() - this.d0);
if (abs <= 10.0f && abs2 <= 10.0f) {
return true;
}
this.i.b((View) this);
if (a(this.j)) {
if (this.e != null && getData() != null) {
String format = String.format(this.D.getResources().getString(R.string.control_remove_widget), getData().getWidgetInfo(this.D));
this.e.setOverlapState(true);
this.e.a(format);
}
b(false);
this.b.setColor(this.D.getResources().getColor(R.color.color_FF4979));
if (!this.n) {
SystemUtils.b(this.D);
this.n = true;
}
} else {
if (this.e != null && getData() != null) {
String format2 = String.format(this.D.getResources().getString(R.string.control_remove_widget_here), getData().getWidgetInfo(this.D));
this.e.setOverlapState(false);
this.e.a(format2);
}
RectF rectF = this.H;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
if (this.i.c((SuperControlView) this)) {
b(false);
this.b.setColor(this.D.getResources().getColor(R.color.bg_99B8BEC1));
} else {
b(true);
this.b.setColor(this.D.getResources().getColor(this.a));
}
this.n = false;
}
}
} else {
float y = motionEvent.getY();
motionEvent.getX();
float centerX3 = this.H.centerX();
float centerY3 = this.H.centerY();
float f12 = this.Q;
if (y < centerY3 - (f12 / 2.0f)) {
y = centerY3 - (f12 / 2.0f);
} else if (y > (f12 / 2.0f) + centerY3) {
y = centerY3 + (f12 / 2.0f);
}
RectF rectF2 = this.M;
float f13 = this.P;
rectF2.offsetTo(centerX3 - (f13 / 2.0f), y - (f13 / 2.0f));
c(centerX3, centerY3);
a(motionEvent);
}
invalidate();
return true;
}
public void setWallPulleyViewCommandParameterListener(WallPulleyViewCommandParameterListener wallPulleyViewCommandParameterListener) {
this.i0 = wallPulleyViewCommandParameterListener;
}
private void b(float f, float f2) {
this.H.offsetTo(f, f2);
this.j.offsetTo(f, f2);
b(this.H);
}
public boolean a(RectF rectF) {
RectF deleteViewRectF = getDeleteViewRectF();
if (deleteViewRectF == null) {
return false;
}
return RectF.intersects(deleteViewRectF, rectF);
}
private void b(MotionEvent motionEvent) {
AccumulatorConfig config;
if (b()) {
if (a(this.j) && this.i != null && (config = getData().getConfig()) != null) {
this.i.a(this, config.getConfigID());
}
if (this.i != null) {
RectF rectF = this.H;
PointF a = a(rectF.left, rectF.top);
this.k.offsetTo(a.x, a.y);
boolean c = this.i.c((SuperControlView) this);
LogUtils.c("isOverlap:" + c);
if (c) {
b(this.o, this.p);
this.b.setColor(this.D.getResources().getColor(this.a));
} else {
b(a.x, a.y);
this.i.a(this, this.H.centerX(), this.H.centerY());
}
this.i.c((View) this);
if (System.currentTimeMillis() - this.t < 350) {
this.i.a(this, getData());
}
}
b(false);
return;
}
a(motionEvent);
if (this.W > 0.0f) {
f();
}
ControlTouchEvent controlTouchEvent = this.i;
if (controlTouchEvent != null) {
controlTouchEvent.b((SuperControlView) this);
}
}
public void a(MotionEvent motionEvent) {
if (this.i0 == null) {
return;
}
if (motionEvent.getAction() != 1 && motionEvent.getAction() != 3) {
if (motionEvent.getAction() == 2) {
this.i0.b(this.W * 100.0f, getData());
return;
}
return;
}
this.i0.a(this.W * 100.0f, getData());
}
private void b(RectF rectF) {
float centerX = rectF.centerX();
float centerY = rectF.centerY();
RectF rectF2 = this.I;
float f = this.N;
float f2 = this.O;
rectF2.set(centerX - (f / 2.0f), centerY - (f2 / 2.0f), (f / 2.0f) + centerX, (f2 / 2.0f) + centerY);
float f3 = this.O;
float f4 = (f3 / 2.0f) + centerY;
float f5 = centerY - (f3 / 2.0f);
RectF rectF3 = this.J;
float f6 = this.N;
rectF3.set(centerX - (f6 / 2.0f), f4 - f6, (f6 / 2.0f) + centerX, f4);
RectF rectF4 = this.L;
float f7 = this.N;
rectF4.set(centerX - (f7 / 2.0f), 0.0f, (f7 / 2.0f) + centerY, 0.0f);
RectF rectF5 = this.K;
float f8 = this.N;
rectF5.set(centerX - (f8 / 2.0f), f5, (f8 / 2.0f) + centerX, f8 + f5);
float f9 = centerY - (this.Q / 2.0f);
RectF rectF6 = this.M;
float f10 = this.P;
rectF6.set(centerX - (f10 / 2.0f), f9 - (f10 / 2.0f), centerX + (f10 / 2.0f), f9 + (f10 / 2.0f));
}
}