444 lines
19 KiB
Java
444 lines
19 KiB
Java
package androidx.transition;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.content.res.XmlResourceParser;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.content.res.TypedArrayUtils;
|
|
import androidx.transition.AnimatorUtils;
|
|
import androidx.transition.Transition;
|
|
import java.lang.annotation.Retention;
|
|
import java.lang.annotation.RetentionPolicy;
|
|
/* loaded from: classes.dex */
|
|
public abstract class Visibility extends Transition {
|
|
public static final int MODE_IN = 1;
|
|
public static final int MODE_OUT = 2;
|
|
private static final String PROPNAME_SCREEN_LOCATION = "android:visibility:screenLocation";
|
|
private int mMode = 3;
|
|
public static final String PROPNAME_VISIBILITY = "android:visibility:visibility";
|
|
private static final String PROPNAME_PARENT = "android:visibility:parent";
|
|
private static final String[] sTransitionProperties = {PROPNAME_VISIBILITY, PROPNAME_PARENT};
|
|
|
|
/* renamed from: androidx.transition.Visibility$1 reason: invalid class name */
|
|
/* loaded from: classes.dex */
|
|
public class AnonymousClass1 extends TransitionListenerAdapter {
|
|
public final /* synthetic */ View val$finalOverlayView;
|
|
public final /* synthetic */ ViewGroup val$overlayHost;
|
|
public final /* synthetic */ View val$startView;
|
|
|
|
public AnonymousClass1(ViewGroup viewGroup, View view, View view2) {
|
|
this.val$overlayHost = viewGroup;
|
|
this.val$finalOverlayView = view;
|
|
this.val$startView = view2;
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionEnd(@NonNull Transition transition) {
|
|
this.val$startView.setTag(R.id.save_overlay_view, null);
|
|
ViewGroupUtils.getOverlay(this.val$overlayHost).remove(this.val$finalOverlayView);
|
|
transition.removeListener(this);
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionPause(@NonNull Transition transition) {
|
|
ViewGroupUtils.getOverlay(this.val$overlayHost).remove(this.val$finalOverlayView);
|
|
}
|
|
|
|
@Override // androidx.transition.TransitionListenerAdapter, androidx.transition.Transition.TransitionListener
|
|
public void onTransitionResume(@NonNull Transition transition) {
|
|
if (this.val$finalOverlayView.getParent() == null) {
|
|
ViewGroupUtils.getOverlay(this.val$overlayHost).add(this.val$finalOverlayView);
|
|
} else {
|
|
Visibility.this.cancel();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class DisappearListener extends AnimatorListenerAdapter implements Transition.TransitionListener, AnimatorUtils.AnimatorPauseListenerCompat {
|
|
public boolean mCanceled = false;
|
|
private final int mFinalVisibility;
|
|
private boolean mLayoutSuppressed;
|
|
private final ViewGroup mParent;
|
|
private final boolean mSuppressLayout;
|
|
private final View mView;
|
|
|
|
public DisappearListener(View view, int i, boolean z2) {
|
|
this.mView = view;
|
|
this.mFinalVisibility = i;
|
|
this.mParent = (ViewGroup) view.getParent();
|
|
this.mSuppressLayout = z2;
|
|
suppressLayout(true);
|
|
}
|
|
|
|
private void hideViewWhenNotCanceled() {
|
|
if (!this.mCanceled) {
|
|
ViewUtils.setTransitionVisibility(this.mView, this.mFinalVisibility);
|
|
ViewGroup viewGroup = this.mParent;
|
|
if (viewGroup != null) {
|
|
viewGroup.invalidate();
|
|
}
|
|
}
|
|
suppressLayout(false);
|
|
}
|
|
|
|
private void suppressLayout(boolean z2) {
|
|
ViewGroup viewGroup;
|
|
if (this.mSuppressLayout && this.mLayoutSuppressed != z2 && (viewGroup = this.mParent) != null) {
|
|
this.mLayoutSuppressed = z2;
|
|
ViewGroupUtils.suppressLayout(viewGroup, z2);
|
|
}
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationCancel(Animator animator) {
|
|
this.mCanceled = true;
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
hideViewWhenNotCanceled();
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener, androidx.transition.AnimatorUtils.AnimatorPauseListenerCompat
|
|
public void onAnimationPause(Animator animator) {
|
|
if (!this.mCanceled) {
|
|
ViewUtils.setTransitionVisibility(this.mView, this.mFinalVisibility);
|
|
}
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationRepeat(Animator animator) {
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener, androidx.transition.AnimatorUtils.AnimatorPauseListenerCompat
|
|
public void onAnimationResume(Animator animator) {
|
|
if (!this.mCanceled) {
|
|
ViewUtils.setTransitionVisibility(this.mView, 0);
|
|
}
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationStart(Animator animator) {
|
|
}
|
|
|
|
@Override // androidx.transition.Transition.TransitionListener
|
|
public void onTransitionCancel(@NonNull Transition transition) {
|
|
}
|
|
|
|
@Override // androidx.transition.Transition.TransitionListener
|
|
public void onTransitionEnd(@NonNull Transition transition) {
|
|
hideViewWhenNotCanceled();
|
|
transition.removeListener(this);
|
|
}
|
|
|
|
@Override // androidx.transition.Transition.TransitionListener
|
|
public void onTransitionPause(@NonNull Transition transition) {
|
|
suppressLayout(false);
|
|
}
|
|
|
|
@Override // androidx.transition.Transition.TransitionListener
|
|
public void onTransitionResume(@NonNull Transition transition) {
|
|
suppressLayout(true);
|
|
}
|
|
|
|
@Override // androidx.transition.Transition.TransitionListener
|
|
public void onTransitionStart(@NonNull Transition transition) {
|
|
}
|
|
}
|
|
|
|
@SuppressLint({"UniqueConstants"})
|
|
@Retention(RetentionPolicy.SOURCE)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
/* loaded from: classes.dex */
|
|
public @interface Mode {
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class VisibilityInfo {
|
|
public ViewGroup mEndParent;
|
|
public int mEndVisibility;
|
|
public boolean mFadeIn;
|
|
public ViewGroup mStartParent;
|
|
public int mStartVisibility;
|
|
public boolean mVisibilityChange;
|
|
}
|
|
|
|
public Visibility() {
|
|
}
|
|
|
|
@SuppressLint({"RestrictedApi"})
|
|
public Visibility(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, Styleable.VISIBILITY_TRANSITION);
|
|
int namedInt = TypedArrayUtils.getNamedInt(obtainStyledAttributes, (XmlResourceParser) attributeSet, "transitionVisibilityMode", 0, 0);
|
|
obtainStyledAttributes.recycle();
|
|
if (namedInt != 0) {
|
|
setMode(namedInt);
|
|
}
|
|
}
|
|
|
|
private void captureValues(TransitionValues transitionValues) {
|
|
transitionValues.values.put(PROPNAME_VISIBILITY, Integer.valueOf(transitionValues.view.getVisibility()));
|
|
transitionValues.values.put(PROPNAME_PARENT, transitionValues.view.getParent());
|
|
int[] iArr = new int[2];
|
|
transitionValues.view.getLocationOnScreen(iArr);
|
|
transitionValues.values.put(PROPNAME_SCREEN_LOCATION, iArr);
|
|
}
|
|
|
|
private VisibilityInfo getVisibilityChangeInfo(TransitionValues transitionValues, TransitionValues transitionValues2) {
|
|
VisibilityInfo visibilityInfo = new VisibilityInfo();
|
|
visibilityInfo.mVisibilityChange = false;
|
|
visibilityInfo.mFadeIn = false;
|
|
if (transitionValues == null || !transitionValues.values.containsKey(PROPNAME_VISIBILITY)) {
|
|
visibilityInfo.mStartVisibility = -1;
|
|
visibilityInfo.mStartParent = null;
|
|
} else {
|
|
visibilityInfo.mStartVisibility = ((Integer) transitionValues.values.get(PROPNAME_VISIBILITY)).intValue();
|
|
visibilityInfo.mStartParent = (ViewGroup) transitionValues.values.get(PROPNAME_PARENT);
|
|
}
|
|
if (transitionValues2 == null || !transitionValues2.values.containsKey(PROPNAME_VISIBILITY)) {
|
|
visibilityInfo.mEndVisibility = -1;
|
|
visibilityInfo.mEndParent = null;
|
|
} else {
|
|
visibilityInfo.mEndVisibility = ((Integer) transitionValues2.values.get(PROPNAME_VISIBILITY)).intValue();
|
|
visibilityInfo.mEndParent = (ViewGroup) transitionValues2.values.get(PROPNAME_PARENT);
|
|
}
|
|
if (transitionValues != null && transitionValues2 != null) {
|
|
int i = visibilityInfo.mStartVisibility;
|
|
int i2 = visibilityInfo.mEndVisibility;
|
|
if (i == i2 && visibilityInfo.mStartParent == visibilityInfo.mEndParent) {
|
|
return visibilityInfo;
|
|
}
|
|
if (i != i2) {
|
|
if (i == 0) {
|
|
visibilityInfo.mFadeIn = false;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
} else if (i2 == 0) {
|
|
visibilityInfo.mFadeIn = true;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
}
|
|
} else if (visibilityInfo.mEndParent == null) {
|
|
visibilityInfo.mFadeIn = false;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
} else if (visibilityInfo.mStartParent == null) {
|
|
visibilityInfo.mFadeIn = true;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
}
|
|
} else if (transitionValues == null && visibilityInfo.mEndVisibility == 0) {
|
|
visibilityInfo.mFadeIn = true;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
} else if (transitionValues2 == null && visibilityInfo.mStartVisibility == 0) {
|
|
visibilityInfo.mFadeIn = false;
|
|
visibilityInfo.mVisibilityChange = true;
|
|
}
|
|
return visibilityInfo;
|
|
}
|
|
|
|
@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) {
|
|
VisibilityInfo visibilityChangeInfo = getVisibilityChangeInfo(transitionValues, transitionValues2);
|
|
if (!visibilityChangeInfo.mVisibilityChange) {
|
|
return null;
|
|
}
|
|
if (visibilityChangeInfo.mStartParent == null && visibilityChangeInfo.mEndParent == null) {
|
|
return null;
|
|
}
|
|
return visibilityChangeInfo.mFadeIn ? onAppear(viewGroup, transitionValues, visibilityChangeInfo.mStartVisibility, transitionValues2, visibilityChangeInfo.mEndVisibility) : onDisappear(viewGroup, transitionValues, visibilityChangeInfo.mStartVisibility, transitionValues2, visibilityChangeInfo.mEndVisibility);
|
|
}
|
|
|
|
public int getMode() {
|
|
return this.mMode;
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
@Nullable
|
|
public String[] getTransitionProperties() {
|
|
return sTransitionProperties;
|
|
}
|
|
|
|
@Override // androidx.transition.Transition
|
|
public boolean isTransitionRequired(TransitionValues transitionValues, TransitionValues transitionValues2) {
|
|
if (transitionValues == null && transitionValues2 == null) {
|
|
return false;
|
|
}
|
|
if (transitionValues != null && transitionValues2 != null && transitionValues2.values.containsKey(PROPNAME_VISIBILITY) != transitionValues.values.containsKey(PROPNAME_VISIBILITY)) {
|
|
return false;
|
|
}
|
|
VisibilityInfo visibilityChangeInfo = getVisibilityChangeInfo(transitionValues, transitionValues2);
|
|
if (visibilityChangeInfo.mVisibilityChange) {
|
|
return visibilityChangeInfo.mStartVisibility == 0 || visibilityChangeInfo.mEndVisibility == 0;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean isVisible(TransitionValues transitionValues) {
|
|
if (transitionValues == null) {
|
|
return false;
|
|
}
|
|
return ((Integer) transitionValues.values.get(PROPNAME_VISIBILITY)).intValue() == 0 && ((View) transitionValues.values.get(PROPNAME_PARENT)) != null;
|
|
}
|
|
|
|
public Animator onAppear(ViewGroup viewGroup, View view, TransitionValues transitionValues, TransitionValues transitionValues2) {
|
|
return null;
|
|
}
|
|
|
|
public Animator onAppear(ViewGroup viewGroup, TransitionValues transitionValues, int i, TransitionValues transitionValues2, int i2) {
|
|
if ((this.mMode & 1) != 1 || transitionValues2 == null) {
|
|
return null;
|
|
}
|
|
if (transitionValues == null) {
|
|
View view = (View) transitionValues2.view.getParent();
|
|
if (getVisibilityChangeInfo(getMatchedTransitionValues(view, false), getTransitionValues(view, false)).mVisibilityChange) {
|
|
return null;
|
|
}
|
|
}
|
|
return onAppear(viewGroup, transitionValues2.view, transitionValues, transitionValues2);
|
|
}
|
|
|
|
public Animator onDisappear(ViewGroup viewGroup, View view, TransitionValues transitionValues, TransitionValues transitionValues2) {
|
|
return null;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:39:0x0089, code lost:
|
|
if (r17.mCanRemoveViews != false) goto L_0x008b;
|
|
*/
|
|
/* JADX WARN: Removed duplicated region for block: B:25:0x004a */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
public Animator onDisappear(ViewGroup viewGroup, TransitionValues transitionValues, int i, TransitionValues transitionValues2, int i2) {
|
|
boolean z2;
|
|
View view;
|
|
boolean z3;
|
|
View view2;
|
|
if ((this.mMode & 2) != 2 || transitionValues == null) {
|
|
return null;
|
|
}
|
|
View view3 = transitionValues.view;
|
|
View view4 = transitionValues2 != null ? transitionValues2.view : null;
|
|
int i3 = R.id.save_overlay_view;
|
|
view4 = (View) view3.getTag(i3);
|
|
if (view4 != null) {
|
|
view = null;
|
|
z2 = true;
|
|
} else if (view4 == null || view4.getParent() == null) {
|
|
if (view4 != null) {
|
|
view2 = null;
|
|
z3 = false;
|
|
if (z3) {
|
|
if (view3.getParent() != null) {
|
|
if (view3.getParent() instanceof View) {
|
|
View view5 = (View) view3.getParent();
|
|
if (!getVisibilityChangeInfo(getTransitionValues(view5, true), getMatchedTransitionValues(view5, true)).mVisibilityChange) {
|
|
view4 = TransitionUtils.copyViewImage(viewGroup, view3, view5);
|
|
} else {
|
|
int id2 = view5.getId();
|
|
if (view5.getParent() == null) {
|
|
if (id2 != -1) {
|
|
if (viewGroup.findViewById(id2) != null) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
view = view2;
|
|
z2 = false;
|
|
view4 = view3;
|
|
}
|
|
z2 = false;
|
|
view = view2;
|
|
}
|
|
view4 = null;
|
|
view2 = null;
|
|
z3 = true;
|
|
if (z3) {
|
|
}
|
|
z2 = false;
|
|
view = view2;
|
|
} else {
|
|
if (i2 == 4 || view3 == view4) {
|
|
view2 = view4;
|
|
z3 = false;
|
|
view4 = null;
|
|
if (z3) {
|
|
}
|
|
z2 = false;
|
|
view = view2;
|
|
}
|
|
view4 = null;
|
|
view2 = null;
|
|
z3 = true;
|
|
if (z3) {
|
|
}
|
|
z2 = false;
|
|
view = view2;
|
|
}
|
|
if (view4 != null) {
|
|
if (!z2) {
|
|
int[] iArr = (int[]) transitionValues.values.get(PROPNAME_SCREEN_LOCATION);
|
|
int i4 = iArr[0];
|
|
int i5 = iArr[1];
|
|
int[] iArr2 = new int[2];
|
|
viewGroup.getLocationOnScreen(iArr2);
|
|
view4.offsetLeftAndRight((i4 - iArr2[0]) - view4.getLeft());
|
|
view4.offsetTopAndBottom((i5 - iArr2[1]) - view4.getTop());
|
|
ViewGroupUtils.getOverlay(viewGroup).add(view4);
|
|
}
|
|
Animator onDisappear = onDisappear(viewGroup, view4, transitionValues, transitionValues2);
|
|
if (!z2) {
|
|
if (onDisappear == null) {
|
|
ViewGroupUtils.getOverlay(viewGroup).remove(view4);
|
|
} else {
|
|
view3.setTag(i3, view4);
|
|
addListener(new AnonymousClass1(viewGroup, view4, view3));
|
|
}
|
|
}
|
|
return onDisappear;
|
|
} else if (view == null) {
|
|
return null;
|
|
} else {
|
|
int visibility = view.getVisibility();
|
|
ViewUtils.setTransitionVisibility(view, 0);
|
|
Animator onDisappear2 = onDisappear(viewGroup, view, transitionValues, transitionValues2);
|
|
if (onDisappear2 != null) {
|
|
DisappearListener disappearListener = new DisappearListener(view, i2, true);
|
|
onDisappear2.addListener(disappearListener);
|
|
AnimatorUtils.addPauseListener(onDisappear2, disappearListener);
|
|
addListener(disappearListener);
|
|
} else {
|
|
ViewUtils.setTransitionVisibility(view, visibility);
|
|
}
|
|
return onDisappear2;
|
|
}
|
|
}
|
|
|
|
public void setMode(int i) {
|
|
if ((i & (-4)) == 0) {
|
|
this.mMode = i;
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Only MODE_IN and MODE_OUT flags are allowed");
|
|
}
|
|
}
|