package androidx.fragment.app;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.res.Resources;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import com.google.android.gms.common.R;
import o.C2887xC;
import o.DH;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class d extends e {
    public boolean c;
    public boolean d;
    public DH e;

    public final DH c(Context context) {
        Animation animationLoadAnimation;
        DH dh;
        if (this.d) {
            return this.e;
        }
        x xVar = this.a;
        l lVar = xVar.c;
        boolean z = xVar.a == 2;
        boolean z2 = this.c;
        int nextTransition = lVar.getNextTransition();
        int popEnterAnim = z2 ? z ? lVar.getPopEnterAnim() : lVar.getPopExitAnim() : z ? lVar.getEnterAnim() : lVar.getExitAnim();
        lVar.setAnimations(0, 0, 0, 0);
        ViewGroup viewGroup = lVar.mContainer;
        DH dh2 = null;
        if (viewGroup != null && viewGroup.getTag(R.id.visible_removing_fragment_view_tag) != null) {
            lVar.mContainer.setTag(R.id.visible_removing_fragment_view_tag, null);
        }
        ViewGroup viewGroup2 = lVar.mContainer;
        if (viewGroup2 == null || viewGroup2.getLayoutTransition() == null) {
            Animation animationOnCreateAnimation = lVar.onCreateAnimation(nextTransition, z, popEnterAnim);
            if (animationOnCreateAnimation != null) {
                dh2 = new DH(false, (Object) animationOnCreateAnimation);
            } else {
                Animator animatorOnCreateAnimator = lVar.onCreateAnimator(nextTransition, z, popEnterAnim);
                if (animatorOnCreateAnimator != null) {
                    dh2 = new DH(animatorOnCreateAnimator);
                } else {
                    if (popEnterAnim == 0 && nextTransition != 0) {
                        popEnterAnim = nextTransition != 4097 ? nextTransition != 8194 ? nextTransition != 8197 ? nextTransition != 4099 ? nextTransition != 4100 ? -1 : z ? C2887xC.F(context, android.R.attr.activityOpenEnterAnimation) : C2887xC.F(context, android.R.attr.activityOpenExitAnimation) : z ? R.animator.fragment_fade_enter : R.animator.fragment_fade_exit : z ? C2887xC.F(context, android.R.attr.activityCloseEnterAnimation) : C2887xC.F(context, android.R.attr.activityCloseExitAnimation) : z ? R.animator.fragment_close_enter : R.animator.fragment_close_exit : z ? R.animator.fragment_open_enter : R.animator.fragment_open_exit;
                    }
                    if (popEnterAnim != 0) {
                        boolean zEquals = "anim".equals(context.getResources().getResourceTypeName(popEnterAnim));
                        if (zEquals) {
                            try {
                                animationLoadAnimation = AnimationUtils.loadAnimation(context, popEnterAnim);
                            } catch (Resources.NotFoundException e) {
                                throw e;
                            } catch (RuntimeException unused) {
                            }
                            if (animationLoadAnimation != null) {
                                dh = new DH(false, (Object) animationLoadAnimation);
                                dh2 = dh;
                            }
                        } else {
                            try {
                                Animator animatorLoadAnimator = AnimatorInflater.loadAnimator(context, popEnterAnim);
                                if (animatorLoadAnimator != null) {
                                    dh = new DH(animatorLoadAnimator);
                                    dh2 = dh;
                                }
                            } catch (RuntimeException e2) {
                                if (zEquals) {
                                    throw e2;
                                }
                                Animation animationLoadAnimation2 = AnimationUtils.loadAnimation(context, popEnterAnim);
                                if (animationLoadAnimation2 != null) {
                                    dh2 = new DH(false, (Object) animationLoadAnimation2);
                                }
                            }
                        }
                    }
                }
            }
        }
        this.e = dh2;
        this.d = true;
        return dh2;
    }
}
