475 lines
21 KiB
Java
475 lines
21 KiB
Java
package androidx.transition;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.animation.AnimatorSet;
|
|
import android.animation.ObjectAnimator;
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.content.res.XmlResourceParser;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.PointF;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.util.AttributeSet;
|
|
import android.util.Property;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.core.content.res.TypedArrayUtils;
|
|
import androidx.core.view.ViewCompat;
|
|
import java.util.Map;
|
|
public class ChangeBounds extends Transition {
|
|
private static final Property<View, PointF> BOTTOM_RIGHT_ONLY_PROPERTY = new AnonymousClass4(PointF.class, "bottomRight");
|
|
private static final Property<ViewBounds, PointF> BOTTOM_RIGHT_PROPERTY = new AnonymousClass3(PointF.class, "bottomRight");
|
|
private static final Property<Drawable, PointF> DRAWABLE_ORIGIN_PROPERTY = new AnonymousClass1(PointF.class, "boundsOrigin");
|
|
private static final Property<View, PointF> POSITION_PROPERTY = new AnonymousClass6(PointF.class, "position");
|
|
private static final String PROPNAME_BOUNDS = "android:changeBounds:bounds";
|
|
private static final String PROPNAME_CLIP = "android:changeBounds:clip";
|
|
private static final String PROPNAME_PARENT = "android:changeBounds:parent";
|
|
private static final String PROPNAME_WINDOW_X = "android:changeBounds:windowX";
|
|
private static final String PROPNAME_WINDOW_Y = "android:changeBounds:windowY";
|
|
private static final Property<View, PointF> TOP_LEFT_ONLY_PROPERTY = new AnonymousClass5(PointF.class, "topLeft");
|
|
private static final Property<ViewBounds, PointF> TOP_LEFT_PROPERTY = new AnonymousClass2(PointF.class, "topLeft");
|
|
private static RectEvaluator sRectEvaluator = new RectEvaluator();
|
|
private static final String[] sTransitionProperties = {"android:changeBounds:bounds", "android:changeBounds:clip", "android:changeBounds:parent", "android:changeBounds:windowX", "android:changeBounds:windowY"};
|
|
private boolean mReparent;
|
|
private boolean mResizeClip;
|
|
private int[] mTempLocation;
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$1 reason: invalid class name */
|
|
public static class AnonymousClass1 extends Property<Drawable, PointF> {
|
|
private Rect mBounds = new Rect();
|
|
|
|
public AnonymousClass1(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(Drawable drawable) {
|
|
drawable.copyBounds(this.mBounds);
|
|
Rect rect = this.mBounds;
|
|
return new PointF((float) rect.left, (float) rect.top);
|
|
}
|
|
|
|
public void set(Drawable drawable, PointF pointF) {
|
|
drawable.copyBounds(this.mBounds);
|
|
this.mBounds.offsetTo(Math.round(pointF.x), Math.round(pointF.y));
|
|
drawable.setBounds(this.mBounds);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$10 reason: invalid class name */
|
|
public class AnonymousClass10 extends AnimatorListenerAdapter {
|
|
public final /* synthetic */ BitmapDrawable val$drawable;
|
|
public final /* synthetic */ ViewGroup val$sceneRoot;
|
|
public final /* synthetic */ float val$transitionAlpha;
|
|
public final /* synthetic */ View val$view;
|
|
|
|
public AnonymousClass10(ViewGroup viewGroup, BitmapDrawable bitmapDrawable, View view, float f) {
|
|
this.val$sceneRoot = viewGroup;
|
|
this.val$drawable = bitmapDrawable;
|
|
this.val$view = view;
|
|
this.val$transitionAlpha = f;
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
ViewUtils.getOverlay(this.val$sceneRoot).remove(this.val$drawable);
|
|
ViewUtils.setTransitionAlpha(this.val$view, this.val$transitionAlpha);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$2 reason: invalid class name */
|
|
public static class AnonymousClass2 extends Property<ViewBounds, PointF> {
|
|
public AnonymousClass2(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(ViewBounds viewBounds) {
|
|
return null;
|
|
}
|
|
|
|
public void set(ViewBounds viewBounds, PointF pointF) {
|
|
viewBounds.setTopLeft(pointF);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$3 reason: invalid class name */
|
|
public static class AnonymousClass3 extends Property<ViewBounds, PointF> {
|
|
public AnonymousClass3(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(ViewBounds viewBounds) {
|
|
return null;
|
|
}
|
|
|
|
public void set(ViewBounds viewBounds, PointF pointF) {
|
|
viewBounds.setBottomRight(pointF);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$4 reason: invalid class name */
|
|
public static class AnonymousClass4 extends Property<View, PointF> {
|
|
public AnonymousClass4(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(View view) {
|
|
return null;
|
|
}
|
|
|
|
public void set(View view, PointF pointF) {
|
|
ViewUtils.setLeftTopRightBottom(view, view.getLeft(), view.getTop(), Math.round(pointF.x), Math.round(pointF.y));
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$5 reason: invalid class name */
|
|
public static class AnonymousClass5 extends Property<View, PointF> {
|
|
public AnonymousClass5(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(View view) {
|
|
return null;
|
|
}
|
|
|
|
public void set(View view, PointF pointF) {
|
|
ViewUtils.setLeftTopRightBottom(view, Math.round(pointF.x), Math.round(pointF.y), view.getRight(), view.getBottom());
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$6 reason: invalid class name */
|
|
public static class AnonymousClass6 extends Property<View, PointF> {
|
|
public AnonymousClass6(Class cls, String str) {
|
|
super(cls, str);
|
|
}
|
|
|
|
public PointF get(View view) {
|
|
return null;
|
|
}
|
|
|
|
public void set(View view, PointF pointF) {
|
|
int round = Math.round(pointF.x);
|
|
int round2 = Math.round(pointF.y);
|
|
ViewUtils.setLeftTopRightBottom(view, round, round2, view.getWidth() + round, view.getHeight() + round2);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$7 reason: invalid class name */
|
|
public class AnonymousClass7 extends AnimatorListenerAdapter {
|
|
private ViewBounds mViewBounds;
|
|
public final /* synthetic */ ViewBounds val$viewBounds;
|
|
|
|
public AnonymousClass7(ViewBounds viewBounds) {
|
|
this.val$viewBounds = viewBounds;
|
|
this.mViewBounds = viewBounds;
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$8 reason: invalid class name */
|
|
public class AnonymousClass8 extends AnimatorListenerAdapter {
|
|
private boolean mIsCanceled;
|
|
public final /* synthetic */ int val$endBottom;
|
|
public final /* synthetic */ int val$endLeft;
|
|
public final /* synthetic */ int val$endRight;
|
|
public final /* synthetic */ int val$endTop;
|
|
public final /* synthetic */ Rect val$finalClip;
|
|
public final /* synthetic */ View val$view;
|
|
|
|
public AnonymousClass8(View view, Rect rect, int i, int i2, int i3, int i4) {
|
|
this.val$view = view;
|
|
this.val$finalClip = rect;
|
|
this.val$endLeft = i;
|
|
this.val$endTop = i2;
|
|
this.val$endRight = i3;
|
|
this.val$endBottom = i4;
|
|
}
|
|
|
|
@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) {
|
|
ViewCompat.setClipBounds(this.val$view, this.val$finalClip);
|
|
ViewUtils.setLeftTopRightBottom(this.val$view, this.val$endLeft, this.val$endTop, this.val$endRight, this.val$endBottom);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.transition.ChangeBounds$9 reason: invalid class name */
|
|
public class AnonymousClass9 extends TransitionListenerAdapter {
|
|
public boolean mCanceled = false;
|
|
public final /* synthetic */ ViewGroup val$parent;
|
|
|
|
public AnonymousClass9(ViewGroup viewGroup) {
|
|
this.val$parent = viewGroup;
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionCancel(@NonNull Transition transition) {
|
|
ViewGroupUtils.suppressLayout(this.val$parent, false);
|
|
this.mCanceled = true;
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionEnd(@NonNull Transition transition) {
|
|
if (!this.mCanceled) {
|
|
ViewGroupUtils.suppressLayout(this.val$parent, false);
|
|
}
|
|
transition.removeListener(this);
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionPause(@NonNull Transition transition) {
|
|
ViewGroupUtils.suppressLayout(this.val$parent, false);
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionResume(@NonNull Transition transition) {
|
|
ViewGroupUtils.suppressLayout(this.val$parent, true);
|
|
}
|
|
}
|
|
|
|
public static class ViewBounds {
|
|
private int mBottom;
|
|
private int mBottomRightCalls;
|
|
private int mLeft;
|
|
private int mRight;
|
|
private int mTop;
|
|
private int mTopLeftCalls;
|
|
private View mView;
|
|
|
|
public ViewBounds(View view) {
|
|
this.mView = view;
|
|
}
|
|
|
|
private void setLeftTopRightBottom() {
|
|
ViewUtils.setLeftTopRightBottom(this.mView, this.mLeft, this.mTop, this.mRight, this.mBottom);
|
|
this.mTopLeftCalls = 0;
|
|
this.mBottomRightCalls = 0;
|
|
}
|
|
|
|
public void setBottomRight(PointF pointF) {
|
|
this.mRight = Math.round(pointF.x);
|
|
this.mBottom = Math.round(pointF.y);
|
|
int i = this.mBottomRightCalls + 1;
|
|
this.mBottomRightCalls = i;
|
|
if (this.mTopLeftCalls == i) {
|
|
setLeftTopRightBottom();
|
|
}
|
|
}
|
|
|
|
public void setTopLeft(PointF pointF) {
|
|
this.mLeft = Math.round(pointF.x);
|
|
this.mTop = Math.round(pointF.y);
|
|
int i = this.mTopLeftCalls + 1;
|
|
this.mTopLeftCalls = i;
|
|
if (i == this.mBottomRightCalls) {
|
|
setLeftTopRightBottom();
|
|
}
|
|
}
|
|
}
|
|
|
|
public ChangeBounds() {
|
|
this.mTempLocation = new int[2];
|
|
this.mResizeClip = false;
|
|
this.mReparent = false;
|
|
}
|
|
|
|
@SuppressLint({"RestrictedApi"})
|
|
public ChangeBounds(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.mTempLocation = new int[2];
|
|
this.mResizeClip = false;
|
|
this.mReparent = false;
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Styleable.CHANGE_BOUNDS);
|
|
boolean namedBoolean = TypedArrayUtils.getNamedBoolean(obtainStyledAttributes, (XmlResourceParser) attributeSet, "resizeClip", 0, false);
|
|
obtainStyledAttributes.recycle();
|
|
setResizeClip(namedBoolean);
|
|
}
|
|
|
|
private void captureValues(TransitionValues transitionValues) {
|
|
View view = transitionValues.view;
|
|
if (ViewCompat.isLaidOut(view) || view.getWidth() != 0 || view.getHeight() != 0) {
|
|
transitionValues.values.put("android:changeBounds:bounds", new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
|
|
transitionValues.values.put("android:changeBounds:parent", transitionValues.view.getParent());
|
|
if (this.mReparent) {
|
|
transitionValues.view.getLocationInWindow(this.mTempLocation);
|
|
transitionValues.values.put("android:changeBounds:windowX", Integer.valueOf(this.mTempLocation[0]));
|
|
transitionValues.values.put("android:changeBounds:windowY", Integer.valueOf(this.mTempLocation[1]));
|
|
}
|
|
if (this.mResizeClip) {
|
|
transitionValues.values.put("android:changeBounds:clip", ViewCompat.getClipBounds(view));
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean parentMatches(View view, View view2) {
|
|
if (!this.mReparent) {
|
|
return true;
|
|
}
|
|
TransitionValues matchedTransitionValues = getMatchedTransitionValues(view, true);
|
|
if (matchedTransitionValues == null) {
|
|
if (view == view2) {
|
|
return true;
|
|
}
|
|
} else if (view2 == matchedTransitionValues.view) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
public void captureEndValues(@NonNull TransitionValues transitionValues) {
|
|
captureValues(transitionValues);
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
public void captureStartValues(@NonNull TransitionValues transitionValues) {
|
|
captureValues(transitionValues);
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
@Nullable
|
|
public Animator createAnimator(@NonNull ViewGroup viewGroup, @Nullable TransitionValues transitionValues, @Nullable TransitionValues transitionValues2) {
|
|
int i;
|
|
View view;
|
|
Animator animator;
|
|
int i2;
|
|
Rect rect;
|
|
ObjectAnimator objectAnimator;
|
|
if (transitionValues == null || transitionValues2 == null) {
|
|
return null;
|
|
}
|
|
Map<String, Object> map = transitionValues.values;
|
|
Map<String, Object> map2 = transitionValues2.values;
|
|
ViewGroup viewGroup2 = (ViewGroup) map.get("android:changeBounds:parent");
|
|
ViewGroup viewGroup3 = (ViewGroup) map2.get("android:changeBounds:parent");
|
|
if (viewGroup2 == null || viewGroup3 == null) {
|
|
return null;
|
|
}
|
|
View view2 = transitionValues2.view;
|
|
if (parentMatches(viewGroup2, viewGroup3)) {
|
|
Rect rect2 = (Rect) transitionValues.values.get("android:changeBounds:bounds");
|
|
Rect rect3 = (Rect) transitionValues2.values.get("android:changeBounds:bounds");
|
|
int i3 = rect2.left;
|
|
int i4 = rect3.left;
|
|
int i5 = rect2.top;
|
|
int i6 = rect3.top;
|
|
int i7 = rect2.right;
|
|
int i8 = rect3.right;
|
|
int i9 = rect2.bottom;
|
|
int i10 = rect3.bottom;
|
|
int i11 = i7 - i3;
|
|
int i12 = i9 - i5;
|
|
int i13 = i8 - i4;
|
|
int i14 = i10 - i6;
|
|
Rect rect4 = (Rect) transitionValues.values.get("android:changeBounds:clip");
|
|
Rect rect5 = (Rect) transitionValues2.values.get("android:changeBounds:clip");
|
|
if ((i11 == 0 || i12 == 0) && (i13 == 0 || i14 == 0)) {
|
|
i = 0;
|
|
} else {
|
|
i = (i3 == i4 && i5 == i6) ? 0 : 1;
|
|
if (!(i7 == i8 && i9 == i10)) {
|
|
i++;
|
|
}
|
|
}
|
|
if ((rect4 != null && !rect4.equals(rect5)) || (rect4 == null && rect5 != null)) {
|
|
i++;
|
|
}
|
|
if (i <= 0) {
|
|
return null;
|
|
}
|
|
if (!this.mResizeClip) {
|
|
view = view2;
|
|
ViewUtils.setLeftTopRightBottom(view, i3, i5, i7, i9);
|
|
if (i != 2) {
|
|
animator = (i3 == i4 && i5 == i6) ? ObjectAnimatorUtils.ofPointF(view, BOTTOM_RIGHT_ONLY_PROPERTY, getPathMotion().getPath((float) i7, (float) i9, (float) i8, (float) i10)) : ObjectAnimatorUtils.ofPointF(view, TOP_LEFT_ONLY_PROPERTY, getPathMotion().getPath((float) i3, (float) i5, (float) i4, (float) i6));
|
|
} else if (i11 == i13 && i12 == i14) {
|
|
animator = ObjectAnimatorUtils.ofPointF(view, POSITION_PROPERTY, getPathMotion().getPath((float) i3, (float) i5, (float) i4, (float) i6));
|
|
} else {
|
|
ViewBounds viewBounds = new ViewBounds(view);
|
|
ObjectAnimator ofPointF = ObjectAnimatorUtils.ofPointF(viewBounds, TOP_LEFT_PROPERTY, getPathMotion().getPath((float) i3, (float) i5, (float) i4, (float) i6));
|
|
ObjectAnimator ofPointF2 = ObjectAnimatorUtils.ofPointF(viewBounds, BOTTOM_RIGHT_PROPERTY, getPathMotion().getPath((float) i7, (float) i9, (float) i8, (float) i10));
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
animatorSet.playTogether(ofPointF, ofPointF2);
|
|
animatorSet.addListener(new AnonymousClass7(viewBounds));
|
|
animator = animatorSet;
|
|
}
|
|
} else {
|
|
view = view2;
|
|
ViewUtils.setLeftTopRightBottom(view, i3, i5, Math.max(i11, i13) + i3, Math.max(i12, i14) + i5);
|
|
ObjectAnimator ofPointF3 = (i3 == i4 && i5 == i6) ? null : ObjectAnimatorUtils.ofPointF(view, POSITION_PROPERTY, getPathMotion().getPath((float) i3, (float) i5, (float) i4, (float) i6));
|
|
if (rect4 == null) {
|
|
i2 = 0;
|
|
rect = new Rect(0, 0, i11, i12);
|
|
} else {
|
|
i2 = 0;
|
|
rect = rect4;
|
|
}
|
|
Rect rect6 = rect5 == null ? new Rect(i2, i2, i13, i14) : rect5;
|
|
if (!rect.equals(rect6)) {
|
|
ViewCompat.setClipBounds(view, rect);
|
|
RectEvaluator rectEvaluator = sRectEvaluator;
|
|
Object[] objArr = new Object[2];
|
|
objArr[i2] = rect;
|
|
objArr[1] = rect6;
|
|
ObjectAnimator ofObject = ObjectAnimator.ofObject(view, "clipBounds", rectEvaluator, objArr);
|
|
ofObject.addListener(new AnonymousClass8(view, rect5, i4, i6, i8, i10));
|
|
objectAnimator = ofObject;
|
|
} else {
|
|
objectAnimator = null;
|
|
}
|
|
animator = TransitionUtils.mergeAnimators(ofPointF3, objectAnimator);
|
|
}
|
|
if (view.getParent() instanceof ViewGroup) {
|
|
ViewGroup viewGroup4 = (ViewGroup) view.getParent();
|
|
ViewGroupUtils.suppressLayout(viewGroup4, true);
|
|
addListener(new AnonymousClass9(viewGroup4));
|
|
}
|
|
return animator;
|
|
}
|
|
int intValue = ((Integer) transitionValues.values.get("android:changeBounds:windowX")).intValue();
|
|
int intValue2 = ((Integer) transitionValues.values.get("android:changeBounds:windowY")).intValue();
|
|
int intValue3 = ((Integer) transitionValues2.values.get("android:changeBounds:windowX")).intValue();
|
|
int intValue4 = ((Integer) transitionValues2.values.get("android:changeBounds:windowY")).intValue();
|
|
if (intValue == intValue3 && intValue2 == intValue4) {
|
|
return null;
|
|
}
|
|
viewGroup.getLocationInWindow(this.mTempLocation);
|
|
Bitmap createBitmap = Bitmap.createBitmap(view2.getWidth(), view2.getHeight(), Bitmap.Config.ARGB_8888);
|
|
view2.draw(new Canvas(createBitmap));
|
|
BitmapDrawable bitmapDrawable = new BitmapDrawable(createBitmap);
|
|
float transitionAlpha = ViewUtils.getTransitionAlpha(view2);
|
|
ViewUtils.setTransitionAlpha(view2, 0.0f);
|
|
ViewUtils.getOverlay(viewGroup).add(bitmapDrawable);
|
|
PathMotion pathMotion = getPathMotion();
|
|
int[] iArr = this.mTempLocation;
|
|
ObjectAnimator ofPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(bitmapDrawable, PropertyValuesHolderUtils.ofPointF(DRAWABLE_ORIGIN_PROPERTY, pathMotion.getPath((float) (intValue - iArr[0]), (float) (intValue2 - iArr[1]), (float) (intValue3 - iArr[0]), (float) (intValue4 - iArr[1]))));
|
|
ofPropertyValuesHolder.addListener(new AnonymousClass10(viewGroup, bitmapDrawable, view2, transitionAlpha));
|
|
return ofPropertyValuesHolder;
|
|
}
|
|
|
|
public boolean getResizeClip() {
|
|
return this.mResizeClip;
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
@Nullable
|
|
public String[] getTransitionProperties() {
|
|
return sTransitionProperties;
|
|
}
|
|
|
|
public void setResizeClip(boolean z2) {
|
|
this.mResizeClip = z2;
|
|
}
|
|
}
|