package androidx.fragment.app;

import android.R;
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;

/* JADX INFO: loaded from: classes.dex */
public final class g extends o0.i {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final boolean f2451b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f2452c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public com.google.android.gms.internal.atv_ads_framework.d1 f2453d;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public g(f2 f2Var, boolean z10) {
        super(f2Var);
        nb.g.i(f2Var, "operation");
        this.f2451b = z10;
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0029  */
    /* JADX WARN: Removed duplicated region for block: B:38:0x0060  */
    /* JADX WARN: Removed duplicated region for block: B:85:0x00fb A[Catch: RuntimeException -> 0x0101, TRY_LEAVE, TryCatch #1 {RuntimeException -> 0x0101, blocks: (B:83:0x00f5, B:85:0x00fb), top: B:96:0x00f5 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final com.google.android.gms.internal.atv_ads_framework.d1 x(Context context) {
        int iS;
        Animation animationLoadAnimation;
        com.google.android.gms.internal.atv_ads_framework.d1 d1Var;
        com.google.android.gms.internal.atv_ads_framework.d1 d1Var2;
        Animator animatorLoadAnimator;
        if (this.f2452c) {
            return this.f2453d;
        }
        f2 f2Var = (f2) this.f31277a;
        e0 e0Var = f2Var.f2442c;
        boolean z10 = f2Var.f2440a == SpecialEffectsController$Operation$State.f2306b;
        a0 a0Var = e0Var.f2424n0;
        int i10 = a0Var == null ? 0 : a0Var.f2318f;
        if (this.f2451b) {
            if (z10) {
                iS = a0Var == null ? 0 : a0Var.f2316d;
            } else if (a0Var != null) {
                iS = a0Var.f2317e;
            }
        } else if (z10) {
            if (a0Var != null) {
                iS = a0Var.f2314b;
            }
        } else if (a0Var != null) {
            iS = a0Var.f2315c;
        }
        e0Var.I(0, 0, 0, 0);
        ViewGroup viewGroup = e0Var.f2417j0;
        if (viewGroup != null) {
            int i11 = i1.b.visible_removing_fragment_view_tag;
            if (viewGroup.getTag(i11) != null) {
                e0Var.f2417j0.setTag(i11, null);
            }
        }
        ViewGroup viewGroup2 = e0Var.f2417j0;
        if (viewGroup2 == null || viewGroup2.getLayoutTransition() == null) {
            Animation animationOnCreateAnimation = e0Var.onCreateAnimation(i10, z10, iS);
            if (animationOnCreateAnimation != null) {
                d1Var2 = new com.google.android.gms.internal.atv_ads_framework.d1(animationOnCreateAnimation);
            } else {
                Animator animatorOnCreateAnimator = e0Var.onCreateAnimator(i10, z10, iS);
                if (animatorOnCreateAnimator != null) {
                    d1Var2 = new com.google.android.gms.internal.atv_ads_framework.d1(animatorOnCreateAnimator);
                } else {
                    if (iS == 0 && i10 != 0) {
                        iS = i10 != 4097 ? i10 != 8194 ? i10 != 8197 ? i10 != 4099 ? i10 != 4100 ? -1 : z10 ? androidx.datastore.preferences.core.c.s(context, R.attr.activityOpenEnterAnimation) : androidx.datastore.preferences.core.c.s(context, R.attr.activityOpenExitAnimation) : z10 ? i1.a.fragment_fade_enter : i1.a.fragment_fade_exit : z10 ? androidx.datastore.preferences.core.c.s(context, R.attr.activityCloseEnterAnimation) : androidx.datastore.preferences.core.c.s(context, R.attr.activityCloseExitAnimation) : z10 ? i1.a.fragment_close_enter : i1.a.fragment_close_exit : z10 ? i1.a.fragment_open_enter : i1.a.fragment_open_exit;
                    }
                    if (iS == 0) {
                        d1Var2 = null;
                    } else {
                        boolean zEquals = "anim".equals(context.getResources().getResourceTypeName(iS));
                        if (zEquals) {
                            try {
                                animationLoadAnimation = AnimationUtils.loadAnimation(context, iS);
                            } catch (Resources.NotFoundException e10) {
                                throw e10;
                            } catch (RuntimeException unused) {
                                try {
                                    animatorLoadAnimator = AnimatorInflater.loadAnimator(context, iS);
                                    if (animatorLoadAnimator != null) {
                                    }
                                } catch (RuntimeException e11) {
                                    if (zEquals) {
                                        throw e11;
                                    }
                                    Animation animationLoadAnimation2 = AnimationUtils.loadAnimation(context, iS);
                                    if (animationLoadAnimation2 != null) {
                                        d1Var2 = new com.google.android.gms.internal.atv_ads_framework.d1(animationLoadAnimation2);
                                    }
                                    this.f2453d = d1Var2;
                                    this.f2452c = true;
                                    return d1Var2;
                                }
                            }
                            if (animationLoadAnimation != null) {
                                d1Var = new com.google.android.gms.internal.atv_ads_framework.d1(animationLoadAnimation);
                                d1Var2 = d1Var;
                            }
                            d1Var2 = null;
                        } else {
                            animatorLoadAnimator = AnimatorInflater.loadAnimator(context, iS);
                            if (animatorLoadAnimator != null) {
                                d1Var = new com.google.android.gms.internal.atv_ads_framework.d1(animatorLoadAnimator);
                                d1Var2 = d1Var;
                            }
                            d1Var2 = null;
                        }
                    }
                }
            }
        }
        this.f2453d = d1Var2;
        this.f2452c = true;
        return d1Var2;
    }
}
