alexandroid/decompiled/jadx/sources/androidx/transition/PatternPathMotion.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

99 lines
3.5 KiB
Java

package androidx.transition;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.core.content.res.TypedArrayUtils;
import androidx.core.graphics.PathParser;
import org.xmlpull.v1.XmlPullParser;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes14.dex */
public class PatternPathMotion extends PathMotion {
private Path mOriginalPatternPath;
@NonNull
private final Path mPatternPath;
private final Matrix mTempMatrix;
public PatternPathMotion(@NonNull Context context, @NonNull AttributeSet attributeSet) {
this.mPatternPath = new Path();
this.mTempMatrix = new Matrix();
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Styleable.PATTERN_PATH_MOTION);
try {
String namedString = TypedArrayUtils.getNamedString(obtainStyledAttributes, (XmlPullParser) attributeSet, "patternPathData", 0);
if (namedString == null) {
throw new RuntimeException("pathData must be supplied for patternPathMotion");
}
setPatternPath(PathParser.createPathFromPathData(namedString));
} finally {
obtainStyledAttributes.recycle();
}
}
private static float distance(float f, float f2) {
return (float) Math.sqrt((f2 * f2) + (f * f));
}
@Override // androidx.transition.PathMotion
@NonNull
public Path getPath(float f, float f2, float f3, float f4) {
float f5 = f3 - f;
float f6 = f4 - f2;
float distance = distance(f5, f6);
double atan2 = Math.atan2(f6, f5);
this.mTempMatrix.setScale(distance, distance);
this.mTempMatrix.postRotate((float) Math.toDegrees(atan2));
this.mTempMatrix.postTranslate(f, f2);
Path path = new Path();
this.mPatternPath.transform(this.mTempMatrix, path);
return path;
}
@NonNull
public Path getPatternPath() {
return this.mOriginalPatternPath;
}
public void setPatternPath(@NonNull Path path) {
PathMeasure pathMeasure = new PathMeasure(path, false);
float[] fArr = new float[2];
pathMeasure.getPosTan(pathMeasure.getLength(), fArr, null);
float f = fArr[0];
float f2 = fArr[1];
pathMeasure.getPosTan(0.0f, fArr, null);
float f3 = fArr[0];
float f4 = fArr[1];
if (f3 == f && f4 == f2) {
Single$$ExternalSyntheticBUOutline0.m$3("pattern must not end at the starting point");
return;
}
this.mTempMatrix.setTranslate(-f3, -f4);
float f5 = f - f3;
float f6 = f2 - f4;
float distance = 1.0f / distance(f5, f6);
this.mTempMatrix.postScale(distance, distance);
this.mTempMatrix.postRotate((float) Math.toDegrees(-Math.atan2(f6, f5)));
path.transform(this.mTempMatrix, this.mPatternPath);
this.mOriginalPatternPath = path;
}
public PatternPathMotion() {
Path path = new Path();
this.mPatternPath = path;
this.mTempMatrix = new Matrix();
path.lineTo(1.0f, 0.0f);
this.mOriginalPatternPath = path;
}
public PatternPathMotion(@NonNull Path path) {
this.mPatternPath = new Path();
this.mTempMatrix = new Matrix();
setPatternPath(path);
}
}