Rabbit-R1/android (non root)/java/sources/androidx/constraintlayout/utils/widget/MotionTelltales.java
2024-05-21 17:08:36 -04:00

124 lines
4.6 KiB
Java

package androidx.constraintlayout.utils.widget;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.ViewParent;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.widget.R;
/* loaded from: classes.dex */
public class MotionTelltales extends MockView {
private static final String TAG = "MotionTelltales";
Matrix mInvertMatrix;
MotionLayout mMotionLayout;
private Paint mPaintTelltales;
int mTailColor;
float mTailScale;
int mVelocityMode;
float[] velocity;
public MotionTelltales(Context context) {
super(context);
this.mPaintTelltales = new Paint();
this.velocity = new float[2];
this.mInvertMatrix = new Matrix();
this.mVelocityMode = 0;
this.mTailColor = -65281;
this.mTailScale = 0.25f;
init(context, null);
}
public MotionTelltales(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mPaintTelltales = new Paint();
this.velocity = new float[2];
this.mInvertMatrix = new Matrix();
this.mVelocityMode = 0;
this.mTailColor = -65281;
this.mTailScale = 0.25f;
init(context, attributeSet);
}
public MotionTelltales(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mPaintTelltales = new Paint();
this.velocity = new float[2];
this.mInvertMatrix = new Matrix();
this.mVelocityMode = 0;
this.mTailColor = -65281;
this.mTailScale = 0.25f;
init(context, attributeSet);
}
private void init(Context context, AttributeSet attributeSet) {
if (attributeSet != null) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.styleable.MotionTelltales);
int indexCount = obtainStyledAttributes.getIndexCount();
for (int i = 0; i < indexCount; i++) {
int index = obtainStyledAttributes.getIndex(i);
if (index == R.styleable.MotionTelltales_telltales_tailColor) {
this.mTailColor = obtainStyledAttributes.getColor(index, this.mTailColor);
} else if (index == R.styleable.MotionTelltales_telltales_velocityMode) {
this.mVelocityMode = obtainStyledAttributes.getInt(index, this.mVelocityMode);
} else if (index == R.styleable.MotionTelltales_telltales_tailScale) {
this.mTailScale = obtainStyledAttributes.getFloat(index, this.mTailScale);
}
}
}
this.mPaintTelltales.setColor(this.mTailColor);
this.mPaintTelltales.setStrokeWidth(5.0f);
}
@Override // android.view.View
protected void onAttachedToWindow() {
super.onAttachedToWindow();
}
public void setText(CharSequence charSequence) {
this.mText = charSequence.toString();
requestLayout();
}
@Override // android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
super.onLayout(z, i, i2, i3, i4);
postInvalidate();
}
@Override // androidx.constraintlayout.utils.widget.MockView, android.view.View
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
getMatrix().invert(this.mInvertMatrix);
if (this.mMotionLayout == null) {
ViewParent parent = getParent();
if (parent instanceof MotionLayout) {
this.mMotionLayout = (MotionLayout) parent;
return;
}
return;
}
int width = getWidth();
int height = getHeight();
float[] fArr = {0.1f, 0.25f, 0.5f, 0.75f, 0.9f};
for (int i = 0; i < 5; i++) {
float f = fArr[i];
for (int i2 = 0; i2 < 5; i2++) {
float f2 = fArr[i2];
this.mMotionLayout.getViewVelocity(this, f2, f, this.velocity, this.mVelocityMode);
this.mInvertMatrix.mapVectors(this.velocity);
float f3 = width * f2;
float f4 = height * f;
float[] fArr2 = this.velocity;
float f5 = fArr2[0];
float f6 = this.mTailScale;
float f7 = f4 - (fArr2[1] * f6);
this.mInvertMatrix.mapVectors(fArr2);
canvas.drawLine(f3, f4, f3 - (f5 * f6), f7, this.mPaintTelltales);
}
}
}
}