Files
rr3-apk/decompiled-community/sources/androidx/fragment/app/FragmentAnim.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

201 lines
7.4 KiB
Java

package androidx.fragment.app;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.AnimationUtils;
import android.view.animation.Transformation;
import androidx.annotation.AnimRes;
import androidx.annotation.NonNull;
import androidx.core.view.OneShotPreDrawListener;
import androidx.fragment.R;
/* loaded from: classes.dex */
class FragmentAnim {
private FragmentAnim() {
}
public static AnimationOrAnimator loadAnimation(@NonNull Context context, @NonNull Fragment fragment, boolean z, boolean z2) {
int nextTransition = fragment.getNextTransition();
int nextAnim = getNextAnim(fragment, z, z2);
fragment.setAnimations(0, 0, 0, 0);
ViewGroup viewGroup = fragment.mContainer;
if (viewGroup != null && viewGroup.getTag(R.id.visible_removing_fragment_view_tag) != null) {
fragment.mContainer.setTag(R.id.visible_removing_fragment_view_tag, null);
}
ViewGroup viewGroup2 = fragment.mContainer;
if (viewGroup2 != null && viewGroup2.getLayoutTransition() != null) {
return null;
}
Animation onCreateAnimation = fragment.onCreateAnimation(nextTransition, z, nextAnim);
if (onCreateAnimation != null) {
return new AnimationOrAnimator(onCreateAnimation);
}
Animator onCreateAnimator = fragment.onCreateAnimator(nextTransition, z, nextAnim);
if (onCreateAnimator != null) {
return new AnimationOrAnimator(onCreateAnimator);
}
if (nextAnim == 0 && nextTransition != 0) {
nextAnim = transitToAnimResourceId(context, nextTransition, z);
}
if (nextAnim != 0) {
boolean equals = "anim".equals(context.getResources().getResourceTypeName(nextAnim));
if (equals) {
try {
Animation loadAnimation = AnimationUtils.loadAnimation(context, nextAnim);
if (loadAnimation != null) {
return new AnimationOrAnimator(loadAnimation);
}
} catch (Resources.NotFoundException e) {
throw e;
} catch (RuntimeException unused) {
}
}
try {
Animator loadAnimator = AnimatorInflater.loadAnimator(context, nextAnim);
if (loadAnimator != null) {
return new AnimationOrAnimator(loadAnimator);
}
} catch (RuntimeException e2) {
if (equals) {
throw e2;
}
Animation loadAnimation2 = AnimationUtils.loadAnimation(context, nextAnim);
if (loadAnimation2 != null) {
return new AnimationOrAnimator(loadAnimation2);
}
}
}
return null;
}
@AnimRes
private static int getNextAnim(Fragment fragment, boolean z, boolean z2) {
if (z2) {
if (z) {
return fragment.getPopEnterAnim();
}
return fragment.getPopExitAnim();
}
if (z) {
return fragment.getEnterAnim();
}
return fragment.getExitAnim();
}
@AnimRes
private static int transitToAnimResourceId(@NonNull Context context, int i, boolean z) {
if (i == 4097) {
return z ? R.animator.fragment_open_enter : R.animator.fragment_open_exit;
}
if (i == 8194) {
return z ? R.animator.fragment_close_enter : R.animator.fragment_close_exit;
}
if (i == 8197) {
if (z) {
return toActivityTransitResId(context, android.R.attr.activityCloseEnterAnimation);
}
return toActivityTransitResId(context, android.R.attr.activityCloseExitAnimation);
}
if (i == 4099) {
return z ? R.animator.fragment_fade_enter : R.animator.fragment_fade_exit;
}
if (i != 4100) {
return -1;
}
if (z) {
return toActivityTransitResId(context, android.R.attr.activityOpenEnterAnimation);
}
return toActivityTransitResId(context, android.R.attr.activityOpenExitAnimation);
}
@AnimRes
private static int toActivityTransitResId(@NonNull Context context, int i) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(android.R.style.Animation.Activity, new int[]{i});
int resourceId = obtainStyledAttributes.getResourceId(0, -1);
obtainStyledAttributes.recycle();
return resourceId;
}
public static class AnimationOrAnimator {
public final Animation animation;
public final Animator animator;
public AnimationOrAnimator(Animation animation) {
this.animation = animation;
this.animator = null;
if (animation == null) {
throw new IllegalStateException("Animation cannot be null");
}
}
public AnimationOrAnimator(Animator animator) {
this.animation = null;
this.animator = animator;
if (animator == null) {
throw new IllegalStateException("Animator cannot be null");
}
}
}
public static class EndViewTransitionAnimation extends AnimationSet implements Runnable {
private boolean mAnimating;
private final View mChild;
private boolean mEnded;
private final ViewGroup mParent;
private boolean mTransitionEnded;
public EndViewTransitionAnimation(@NonNull Animation animation, @NonNull ViewGroup viewGroup, @NonNull View view) {
super(false);
this.mAnimating = true;
this.mParent = viewGroup;
this.mChild = view;
addAnimation(animation);
viewGroup.post(this);
}
@Override // android.view.animation.AnimationSet, android.view.animation.Animation
public boolean getTransformation(long j, @NonNull Transformation transformation) {
this.mAnimating = true;
if (this.mEnded) {
return !this.mTransitionEnded;
}
if (!super.getTransformation(j, transformation)) {
this.mEnded = true;
OneShotPreDrawListener.add(this.mParent, this);
}
return true;
}
@Override // android.view.animation.Animation
public boolean getTransformation(long j, @NonNull Transformation transformation, float f) {
this.mAnimating = true;
if (this.mEnded) {
return !this.mTransitionEnded;
}
if (!super.getTransformation(j, transformation, f)) {
this.mEnded = true;
OneShotPreDrawListener.add(this.mParent, this);
}
return true;
}
@Override // java.lang.Runnable
public void run() {
if (!this.mEnded && this.mAnimating) {
this.mAnimating = false;
this.mParent.post(this);
} else {
this.mParent.endViewTransition(this.mChild);
this.mTransitionEnded = true;
}
}
}
}