discord-jadx/app/src/main/java/androidx/transition/ChangeTransform.java

438 lines
20 KiB
Java

package androidx.transition;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.content.res.TypedArrayUtils;
import androidx.core.view.ViewCompat;
import org.xmlpull.v1.XmlPullParser;
public class ChangeTransform extends Transition {
private static final Property<PathAnimatorMatrix, float[]> NON_TRANSLATIONS_PROPERTY = new AnonymousClass1(float[].class, "nonTranslations");
private static final String PROPNAME_INTERMEDIATE_MATRIX = "android:changeTransform:intermediateMatrix";
private static final String PROPNAME_INTERMEDIATE_PARENT_MATRIX = "android:changeTransform:intermediateParentMatrix";
private static final String PROPNAME_MATRIX = "android:changeTransform:matrix";
private static final String PROPNAME_PARENT = "android:changeTransform:parent";
private static final String PROPNAME_PARENT_MATRIX = "android:changeTransform:parentMatrix";
private static final String PROPNAME_TRANSFORMS = "android:changeTransform:transforms";
private static final boolean SUPPORTS_VIEW_REMOVAL_SUPPRESSION = true;
private static final Property<PathAnimatorMatrix, PointF> TRANSLATIONS_PROPERTY = new AnonymousClass2(PointF.class, "translations");
private static final String[] sTransitionProperties = {"android:changeTransform:matrix", "android:changeTransform:transforms", "android:changeTransform:parentMatrix"};
private boolean mReparent = true;
private Matrix mTempMatrix = new Matrix();
public boolean mUseOverlay = true;
/* renamed from: androidx.transition.ChangeTransform$1 reason: invalid class name */
public static class AnonymousClass1 extends Property<PathAnimatorMatrix, float[]> {
public AnonymousClass1(Class cls, String str) {
super(cls, str);
}
public float[] get(PathAnimatorMatrix pathAnimatorMatrix) {
return null;
}
public void set(PathAnimatorMatrix pathAnimatorMatrix, float[] fArr) {
pathAnimatorMatrix.setValues(fArr);
}
}
/* renamed from: androidx.transition.ChangeTransform$2 reason: invalid class name */
public static class AnonymousClass2 extends Property<PathAnimatorMatrix, PointF> {
public AnonymousClass2(Class cls, String str) {
super(cls, str);
}
public PointF get(PathAnimatorMatrix pathAnimatorMatrix) {
return null;
}
public void set(PathAnimatorMatrix pathAnimatorMatrix, PointF pointF) {
pathAnimatorMatrix.setTranslation(pointF);
}
}
/* renamed from: androidx.transition.ChangeTransform$3 reason: invalid class name */
public class AnonymousClass3 extends AnimatorListenerAdapter {
private boolean mIsCanceled;
private Matrix mTempMatrix = new Matrix();
public final /* synthetic */ Matrix val$finalEndMatrix;
public final /* synthetic */ boolean val$handleParentChange;
public final /* synthetic */ PathAnimatorMatrix val$pathAnimatorMatrix;
public final /* synthetic */ Transforms val$transforms;
public final /* synthetic */ View val$view;
public AnonymousClass3(boolean z2, Matrix matrix, View view, Transforms transforms, PathAnimatorMatrix pathAnimatorMatrix) {
this.val$handleParentChange = z2;
this.val$finalEndMatrix = matrix;
this.val$view = view;
this.val$transforms = transforms;
this.val$pathAnimatorMatrix = pathAnimatorMatrix;
}
private void setCurrentMatrix(Matrix matrix) {
this.mTempMatrix.set(matrix);
this.val$view.setTag(R.id.transition_transform, this.mTempMatrix);
this.val$transforms.restore(this.val$view);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
this.mIsCanceled = true;
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
if (!this.mIsCanceled) {
if (!this.val$handleParentChange || !ChangeTransform.this.mUseOverlay) {
this.val$view.setTag(R.id.transition_transform, null);
this.val$view.setTag(R.id.parent_matrix, null);
} else {
setCurrentMatrix(this.val$finalEndMatrix);
}
}
ViewUtils.setAnimationMatrix(this.val$view, null);
this.val$transforms.restore(this.val$view);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener
public void onAnimationPause(Animator animator) {
setCurrentMatrix(this.val$pathAnimatorMatrix.getMatrix());
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener
public void onAnimationResume(Animator animator) {
ChangeTransform.setIdentityTransforms(this.val$view);
}
}
public static class GhostListener extends TransitionListenerAdapter {
private GhostView mGhostView;
private View mView;
public GhostListener(View view, GhostView ghostView) {
this.mView = view;
this.mGhostView = ghostView;
}
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
public void onTransitionEnd(@NonNull Transition transition) {
transition.removeListener(this);
GhostViewUtils.removeGhost(this.mView);
this.mView.setTag(R.id.transition_transform, null);
this.mView.setTag(R.id.parent_matrix, null);
}
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
public void onTransitionPause(@NonNull Transition transition) {
this.mGhostView.setVisibility(4);
}
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
public void onTransitionResume(@NonNull Transition transition) {
this.mGhostView.setVisibility(0);
}
}
public static class PathAnimatorMatrix {
private final Matrix mMatrix = new Matrix();
private float mTranslationX;
private float mTranslationY;
private final float[] mValues;
private final View mView;
public PathAnimatorMatrix(View view, float[] fArr) {
this.mView = view;
float[] fArr2 = (float[]) fArr.clone();
this.mValues = fArr2;
this.mTranslationX = fArr2[2];
this.mTranslationY = fArr2[5];
setAnimationMatrix();
}
private void setAnimationMatrix() {
float[] fArr = this.mValues;
fArr[2] = this.mTranslationX;
fArr[5] = this.mTranslationY;
this.mMatrix.setValues(fArr);
ViewUtils.setAnimationMatrix(this.mView, this.mMatrix);
}
public Matrix getMatrix() {
return this.mMatrix;
}
public void setTranslation(PointF pointF) {
this.mTranslationX = pointF.x;
this.mTranslationY = pointF.y;
setAnimationMatrix();
}
public void setValues(float[] fArr) {
System.arraycopy(fArr, 0, this.mValues, 0, fArr.length);
setAnimationMatrix();
}
}
public static class Transforms {
public final float mRotationX;
public final float mRotationY;
public final float mRotationZ;
public final float mScaleX;
public final float mScaleY;
public final float mTranslationX;
public final float mTranslationY;
public final float mTranslationZ;
public Transforms(View view) {
this.mTranslationX = view.getTranslationX();
this.mTranslationY = view.getTranslationY();
this.mTranslationZ = ViewCompat.getTranslationZ(view);
this.mScaleX = view.getScaleX();
this.mScaleY = view.getScaleY();
this.mRotationX = view.getRotationX();
this.mRotationY = view.getRotationY();
this.mRotationZ = view.getRotation();
}
public boolean equals(Object obj) {
if (!(obj instanceof Transforms)) {
return false;
}
Transforms transforms = (Transforms) obj;
return transforms.mTranslationX == this.mTranslationX && transforms.mTranslationY == this.mTranslationY && transforms.mTranslationZ == this.mTranslationZ && transforms.mScaleX == this.mScaleX && transforms.mScaleY == this.mScaleY && transforms.mRotationX == this.mRotationX && transforms.mRotationY == this.mRotationY && transforms.mRotationZ == this.mRotationZ;
}
public int hashCode() {
float f = this.mTranslationX;
int i = 0;
int floatToIntBits = (f != 0.0f ? Float.floatToIntBits(f) : 0) * 31;
float f2 = this.mTranslationY;
int floatToIntBits2 = (floatToIntBits + (f2 != 0.0f ? Float.floatToIntBits(f2) : 0)) * 31;
float f3 = this.mTranslationZ;
int floatToIntBits3 = (floatToIntBits2 + (f3 != 0.0f ? Float.floatToIntBits(f3) : 0)) * 31;
float f4 = this.mScaleX;
int floatToIntBits4 = (floatToIntBits3 + (f4 != 0.0f ? Float.floatToIntBits(f4) : 0)) * 31;
float f5 = this.mScaleY;
int floatToIntBits5 = (floatToIntBits4 + (f5 != 0.0f ? Float.floatToIntBits(f5) : 0)) * 31;
float f6 = this.mRotationX;
int floatToIntBits6 = (floatToIntBits5 + (f6 != 0.0f ? Float.floatToIntBits(f6) : 0)) * 31;
float f7 = this.mRotationY;
int floatToIntBits7 = (floatToIntBits6 + (f7 != 0.0f ? Float.floatToIntBits(f7) : 0)) * 31;
float f8 = this.mRotationZ;
if (f8 != 0.0f) {
i = Float.floatToIntBits(f8);
}
return floatToIntBits7 + i;
}
public void restore(View view) {
ChangeTransform.setTransforms(view, this.mTranslationX, this.mTranslationY, this.mTranslationZ, this.mScaleX, this.mScaleY, this.mRotationX, this.mRotationY, this.mRotationZ);
}
}
public ChangeTransform() {
}
@SuppressLint({"RestrictedApi"})
public ChangeTransform(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Styleable.CHANGE_TRANSFORM);
XmlPullParser xmlPullParser = (XmlPullParser) attributeSet;
this.mUseOverlay = TypedArrayUtils.getNamedBoolean(obtainStyledAttributes, xmlPullParser, "reparentWithOverlay", 1, true);
this.mReparent = TypedArrayUtils.getNamedBoolean(obtainStyledAttributes, xmlPullParser, "reparent", 0, true);
obtainStyledAttributes.recycle();
}
private void captureValues(TransitionValues transitionValues) {
View view = transitionValues.view;
if (view.getVisibility() != 8) {
transitionValues.values.put("android:changeTransform:parent", view.getParent());
transitionValues.values.put("android:changeTransform:transforms", new Transforms(view));
Matrix matrix = view.getMatrix();
transitionValues.values.put("android:changeTransform:matrix", (matrix == null || matrix.isIdentity()) ? null : new Matrix(matrix));
if (this.mReparent) {
Matrix matrix2 = new Matrix();
ViewGroup viewGroup = (ViewGroup) view.getParent();
ViewUtils.transformMatrixToGlobal(viewGroup, matrix2);
matrix2.preTranslate((float) (-viewGroup.getScrollX()), (float) (-viewGroup.getScrollY()));
transitionValues.values.put("android:changeTransform:parentMatrix", matrix2);
transitionValues.values.put("android:changeTransform:intermediateMatrix", view.getTag(R.id.transition_transform));
transitionValues.values.put("android:changeTransform:intermediateParentMatrix", view.getTag(R.id.parent_matrix));
}
}
}
private void createGhostView(ViewGroup viewGroup, TransitionValues transitionValues, TransitionValues transitionValues2) {
View view = transitionValues2.view;
Matrix matrix = new Matrix((Matrix) transitionValues2.values.get("android:changeTransform:parentMatrix"));
ViewUtils.transformMatrixToLocal(viewGroup, matrix);
GhostView addGhost = GhostViewUtils.addGhost(view, viewGroup, matrix);
if (addGhost != null) {
addGhost.reserveEndViewTransition((ViewGroup) transitionValues.values.get("android:changeTransform:parent"), transitionValues.view);
Transition transition = this;
while (true) {
Transition transition2 = transition.mParent;
if (transition2 == null) {
break;
}
transition = transition2;
}
transition.addListener(new GhostListener(view, addGhost));
if (SUPPORTS_VIEW_REMOVAL_SUPPRESSION) {
View view2 = transitionValues.view;
if (view2 != transitionValues2.view) {
ViewUtils.setTransitionAlpha(view2, 0.0f);
}
ViewUtils.setTransitionAlpha(view, 1.0f);
}
}
}
private ObjectAnimator createTransformAnimator(TransitionValues transitionValues, TransitionValues transitionValues2, boolean z2) {
Matrix matrix = (Matrix) transitionValues.values.get("android:changeTransform:matrix");
Matrix matrix2 = (Matrix) transitionValues2.values.get("android:changeTransform:matrix");
if (matrix == null) {
matrix = MatrixUtils.IDENTITY_MATRIX;
}
if (matrix2 == null) {
matrix2 = MatrixUtils.IDENTITY_MATRIX;
}
if (matrix.equals(matrix2)) {
return null;
}
Transforms transforms = (Transforms) transitionValues2.values.get("android:changeTransform:transforms");
View view = transitionValues2.view;
setIdentityTransforms(view);
float[] fArr = new float[9];
matrix.getValues(fArr);
float[] fArr2 = new float[9];
matrix2.getValues(fArr2);
PathAnimatorMatrix pathAnimatorMatrix = new PathAnimatorMatrix(view, fArr);
ObjectAnimator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(pathAnimatorMatrix, PropertyValuesHolder.ofObject(NON_TRANSLATIONS_PROPERTY, new FloatArrayEvaluator(new float[9]), fArr, fArr2), PropertyValuesHolderUtils.ofPointF(TRANSLATIONS_PROPERTY, getPathMotion().getPath(fArr[2], fArr[5], fArr2[2], fArr2[5])));
AnonymousClass3 r14 = new AnonymousClass3(z2, matrix2, view, transforms, pathAnimatorMatrix);
ofPropertyValuesHolder.addListener(r14);
AnimatorUtils.addPauseListener(ofPropertyValuesHolder, r14);
return ofPropertyValuesHolder;
}
/* JADX WARNING: Code restructure failed: missing block: B:7:0x0017, code lost:
if (r5 == r4.view) goto L_0x001e;
*/
/* JADX WARNING: Code restructure failed: missing block: B:8:0x001a, code lost:
if (r4 == r5) goto L_0x001e;
*/
private boolean parentsMatch(ViewGroup viewGroup, ViewGroup viewGroup2) {
boolean z2 = true;
if (isValidTarget(viewGroup) && isValidTarget(viewGroup2)) {
TransitionValues matchedTransitionValues = getMatchedTransitionValues(viewGroup, true);
if (matchedTransitionValues == null) {
return false;
}
}
z2 = false;
return z2;
}
public static void setIdentityTransforms(View view) {
setTransforms(view, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
}
private void setMatricesForParent(TransitionValues transitionValues, TransitionValues transitionValues2) {
Matrix matrix = (Matrix) transitionValues2.values.get("android:changeTransform:parentMatrix");
transitionValues2.view.setTag(R.id.parent_matrix, matrix);
Matrix matrix2 = this.mTempMatrix;
matrix2.reset();
matrix.invert(matrix2);
Matrix matrix3 = (Matrix) transitionValues.values.get("android:changeTransform:matrix");
if (matrix3 == null) {
matrix3 = new Matrix();
transitionValues.values.put("android:changeTransform:matrix", matrix3);
}
matrix3.postConcat((Matrix) transitionValues.values.get("android:changeTransform:parentMatrix"));
matrix3.postConcat(matrix2);
}
public static void setTransforms(View view, float f, float f2, float f3, float f4, float f5, float f6, float f7, float f8) {
view.setTranslationX(f);
view.setTranslationY(f2);
ViewCompat.setTranslationZ(view, f3);
view.setScaleX(f4);
view.setScaleY(f5);
view.setRotationX(f6);
view.setRotationY(f7);
view.setRotation(f8);
}
@Override // androidx.transition.Transition
public void captureEndValues(@NonNull TransitionValues transitionValues) {
captureValues(transitionValues);
}
@Override // androidx.transition.Transition
public void captureStartValues(@NonNull TransitionValues transitionValues) {
captureValues(transitionValues);
if (!SUPPORTS_VIEW_REMOVAL_SUPPRESSION) {
((ViewGroup) transitionValues.view.getParent()).startViewTransition(transitionValues.view);
}
}
@Override // androidx.transition.Transition
public Animator createAnimator(@NonNull ViewGroup viewGroup, TransitionValues transitionValues, TransitionValues transitionValues2) {
if (transitionValues == null || transitionValues2 == null || !transitionValues.values.containsKey("android:changeTransform:parent") || !transitionValues2.values.containsKey("android:changeTransform:parent")) {
return null;
}
ViewGroup viewGroup2 = (ViewGroup) transitionValues.values.get("android:changeTransform:parent");
boolean z2 = this.mReparent && !parentsMatch(viewGroup2, (ViewGroup) transitionValues2.values.get("android:changeTransform:parent"));
Matrix matrix = (Matrix) transitionValues.values.get("android:changeTransform:intermediateMatrix");
if (matrix != null) {
transitionValues.values.put("android:changeTransform:matrix", matrix);
}
Matrix matrix2 = (Matrix) transitionValues.values.get("android:changeTransform:intermediateParentMatrix");
if (matrix2 != null) {
transitionValues.values.put("android:changeTransform:parentMatrix", matrix2);
}
if (z2) {
setMatricesForParent(transitionValues, transitionValues2);
}
ObjectAnimator createTransformAnimator = createTransformAnimator(transitionValues, transitionValues2, z2);
if (z2 && createTransformAnimator != null && this.mUseOverlay) {
createGhostView(viewGroup, transitionValues, transitionValues2);
} else if (!SUPPORTS_VIEW_REMOVAL_SUPPRESSION) {
viewGroup2.endViewTransition(transitionValues.view);
}
return createTransformAnimator;
}
public boolean getReparent() {
return this.mReparent;
}
public boolean getReparentWithOverlay() {
return this.mUseOverlay;
}
@Override // androidx.transition.Transition
public String[] getTransitionProperties() {
return sTransitionProperties;
}
public void setReparent(boolean z2) {
this.mReparent = z2;
}
public void setReparentWithOverlay(boolean z2) {
this.mUseOverlay = z2;
}
}