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,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));
}
}