Rabbit-R1/android (non root)/java/sources/androidx/transition/Visibility.java
2024-05-21 17:08:36 -04:00

313 lines
14 KiB
Java

package androidx.transition;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
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.core.content.res.TypedArrayUtils;
import androidx.transition.AnimatorUtils;
import androidx.transition.Transition;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/* loaded from: classes2.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;
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};
@Retention(RetentionPolicy.SOURCE)
/* loaded from: classes2.dex */
public @interface Mode {
}
public int getMode() {
return this.mMode;
}
@Override // androidx.transition.Transition
public String[] getTransitionProperties() {
return sTransitionProperties;
}
public Animator onAppear(ViewGroup viewGroup, View view, TransitionValues transitionValues, TransitionValues transitionValues2) {
return null;
}
public Animator onDisappear(ViewGroup viewGroup, View view, TransitionValues transitionValues, TransitionValues transitionValues2) {
return null;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class VisibilityInfo {
ViewGroup mEndParent;
int mEndVisibility;
boolean mFadeIn;
ViewGroup mStartParent;
int mStartVisibility;
boolean mVisibilityChange;
VisibilityInfo() {
}
}
public Visibility() {
this.mMode = 3;
}
public Visibility(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.mMode = 3;
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);
}
}
public void setMode(int i) {
if ((i & (-4)) != 0) {
throw new IllegalArgumentException("Only MODE_IN and MODE_OUT flags are allowed");
}
this.mMode = i;
}
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);
}
@Override // androidx.transition.Transition
public void captureStartValues(TransitionValues transitionValues) {
captureValues(transitionValues);
}
@Override // androidx.transition.Transition
public void captureEndValues(TransitionValues transitionValues) {
captureValues(transitionValues);
}
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;
}
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 = ((Integer) transitionValues.values.get(PROPNAME_VISIBILITY)).intValue();
visibilityInfo.mStartParent = (ViewGroup) transitionValues.values.get(PROPNAME_PARENT);
} else {
visibilityInfo.mStartVisibility = -1;
visibilityInfo.mStartParent = null;
}
if (transitionValues2 != null && transitionValues2.values.containsKey(PROPNAME_VISIBILITY)) {
visibilityInfo.mEndVisibility = ((Integer) transitionValues2.values.get(PROPNAME_VISIBILITY)).intValue();
visibilityInfo.mEndParent = (ViewGroup) transitionValues2.values.get(PROPNAME_PARENT);
} else {
visibilityInfo.mEndVisibility = -1;
visibilityInfo.mEndParent = null;
}
if (transitionValues != null && transitionValues2 != null) {
if (visibilityInfo.mStartVisibility == visibilityInfo.mEndVisibility && visibilityInfo.mStartParent == visibilityInfo.mEndParent) {
return visibilityInfo;
}
if (visibilityInfo.mStartVisibility != visibilityInfo.mEndVisibility) {
if (visibilityInfo.mStartVisibility == 0) {
visibilityInfo.mFadeIn = false;
visibilityInfo.mVisibilityChange = true;
} else if (visibilityInfo.mEndVisibility == 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 Animator createAnimator(ViewGroup viewGroup, TransitionValues transitionValues, TransitionValues transitionValues2) {
VisibilityInfo visibilityChangeInfo = getVisibilityChangeInfo(transitionValues, transitionValues2);
if (!visibilityChangeInfo.mVisibilityChange) {
return null;
}
if (visibilityChangeInfo.mStartParent == null && visibilityChangeInfo.mEndParent == null) {
return null;
}
if (visibilityChangeInfo.mFadeIn) {
return onAppear(viewGroup, transitionValues, visibilityChangeInfo.mStartVisibility, transitionValues2, visibilityChangeInfo.mEndVisibility);
}
return onDisappear(viewGroup, transitionValues, visibilityChangeInfo.mStartVisibility, transitionValues2, visibilityChangeInfo.mEndVisibility);
}
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);
}
/* JADX WARN: Code restructure failed: missing block: B:51:0x007f, code lost:
if (r10.mCanRemoveViews != false) goto L43;
*/
/* JADX WARN: Removed duplicated region for block: B:37:0x0040 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public android.animation.Animator onDisappear(final android.view.ViewGroup r11, androidx.transition.TransitionValues r12, int r13, androidx.transition.TransitionValues r14, int r15) {
/*
Method dump skipped, instructions count: 254
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.transition.Visibility.onDisappear(android.view.ViewGroup, androidx.transition.TransitionValues, int, androidx.transition.TransitionValues, int):android.animation.Animator");
}
@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;
}
/* JADX INFO: Access modifiers changed from: private */
/* loaded from: classes2.dex */
public static class DisappearListener extends AnimatorListenerAdapter implements Transition.TransitionListener, AnimatorUtils.AnimatorPauseListenerCompat {
boolean mCanceled = false;
private final int mFinalVisibility;
private boolean mLayoutSuppressed;
private final ViewGroup mParent;
private final boolean mSuppressLayout;
private final View mView;
@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 onAnimationRepeat(Animator animator) {
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationStart(Animator animator) {
}
@Override // androidx.transition.Transition.TransitionListener
public void onTransitionCancel(Transition transition) {
}
@Override // androidx.transition.Transition.TransitionListener
public void onTransitionStart(Transition transition) {
}
DisappearListener(View view, int i, boolean z) {
this.mView = view;
this.mFinalVisibility = i;
this.mParent = (ViewGroup) view.getParent();
this.mSuppressLayout = z;
suppressLayout(true);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener, androidx.transition.AnimatorUtils.AnimatorPauseListenerCompat
public void onAnimationPause(Animator animator) {
if (this.mCanceled) {
return;
}
ViewUtils.setTransitionVisibility(this.mView, this.mFinalVisibility);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorPauseListener, androidx.transition.AnimatorUtils.AnimatorPauseListenerCompat
public void onAnimationResume(Animator animator) {
if (this.mCanceled) {
return;
}
ViewUtils.setTransitionVisibility(this.mView, 0);
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
hideViewWhenNotCanceled();
}
@Override // androidx.transition.Transition.TransitionListener
public void onTransitionEnd(Transition transition) {
hideViewWhenNotCanceled();
transition.removeListener(this);
}
@Override // androidx.transition.Transition.TransitionListener
public void onTransitionPause(Transition transition) {
suppressLayout(false);
}
@Override // androidx.transition.Transition.TransitionListener
public void onTransitionResume(Transition transition) {
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 z) {
ViewGroup viewGroup;
if (!this.mSuppressLayout || this.mLayoutSuppressed == z || (viewGroup = this.mParent) == null) {
return;
}
this.mLayoutSuppressed = z;
ViewGroupUtils.suppressLayout(viewGroup, z);
}
}
}