package androidx.fragment.app; import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.content.res.Resources; 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.core.view.l0; import androidx.fragment.app.w; import v.b; /* loaded from: classes.dex */ abstract class f { class a implements b.a { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ Fragment f1809a; a(Fragment fragment) { this.f1809a = fragment; } @Override // v.b.a public void a() { if (this.f1809a.getAnimatingAway() != null) { View animatingAway = this.f1809a.getAnimatingAway(); this.f1809a.setAnimatingAway(null); animatingAway.clearAnimation(); } this.f1809a.setAnimator(null); } } class b implements Animation.AnimationListener { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ViewGroup f1810a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ Fragment f1811b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ w.g f1812c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ v.b f1813d; class a implements Runnable { a() { } @Override // java.lang.Runnable public void run() { if (b.this.f1811b.getAnimatingAway() != null) { b.this.f1811b.setAnimatingAway(null); b bVar = b.this; bVar.f1812c.b(bVar.f1811b, bVar.f1813d); } } } b(ViewGroup viewGroup, Fragment fragment, w.g gVar, v.b bVar) { this.f1810a = viewGroup; this.f1811b = fragment; this.f1812c = gVar; this.f1813d = bVar; } @Override // android.view.animation.Animation.AnimationListener public void onAnimationEnd(Animation animation) { this.f1810a.post(new a()); } @Override // android.view.animation.Animation.AnimationListener public void onAnimationRepeat(Animation animation) { } @Override // android.view.animation.Animation.AnimationListener public void onAnimationStart(Animation animation) { } } class c extends AnimatorListenerAdapter { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ ViewGroup f1815a; /* renamed from: b, reason: collision with root package name */ final /* synthetic */ View f1816b; /* renamed from: c, reason: collision with root package name */ final /* synthetic */ Fragment f1817c; /* renamed from: d, reason: collision with root package name */ final /* synthetic */ w.g f1818d; /* renamed from: e, reason: collision with root package name */ final /* synthetic */ v.b f1819e; c(ViewGroup viewGroup, View view, Fragment fragment, w.g gVar, v.b bVar) { this.f1815a = viewGroup; this.f1816b = view; this.f1817c = fragment; this.f1818d = gVar; this.f1819e = bVar; } @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener public void onAnimationEnd(Animator animator) { this.f1815a.endViewTransition(this.f1816b); Animator animator2 = this.f1817c.getAnimator(); this.f1817c.setAnimator(null); if (animator2 == null || this.f1815a.indexOfChild(this.f1816b) >= 0) { return; } this.f1818d.b(this.f1817c, this.f1819e); } } static void a(Fragment fragment, d dVar, w.g gVar) { View view = fragment.mView; ViewGroup viewGroup = fragment.mContainer; viewGroup.startViewTransition(view); v.b bVar = new v.b(); bVar.c(new a(fragment)); gVar.a(fragment, bVar); if (dVar.f1820a != null) { e eVar = new e(dVar.f1820a, viewGroup, view); fragment.setAnimatingAway(fragment.mView); eVar.setAnimationListener(new b(viewGroup, fragment, gVar, bVar)); fragment.mView.startAnimation(eVar); return; } Animator animator = dVar.f1821b; fragment.setAnimator(animator); animator.addListener(new c(viewGroup, view, fragment, gVar, bVar)); animator.setTarget(fragment.mView); animator.start(); } private static int b(Fragment fragment, boolean z10, boolean z11) { return z11 ? z10 ? fragment.getPopEnterAnim() : fragment.getPopExitAnim() : z10 ? fragment.getEnterAnim() : fragment.getExitAnim(); } static d c(Context context, Fragment fragment, boolean z10, boolean z11) { int nextTransition = fragment.getNextTransition(); int b10 = b(fragment, z10, z11); boolean z12 = false; fragment.setAnimations(0, 0, 0, 0); ViewGroup viewGroup = fragment.mContainer; if (viewGroup != null) { int i10 = f0.b.f9491c; if (viewGroup.getTag(i10) != null) { fragment.mContainer.setTag(i10, null); } } ViewGroup viewGroup2 = fragment.mContainer; if (viewGroup2 != null && viewGroup2.getLayoutTransition() != null) { return null; } Animation onCreateAnimation = fragment.onCreateAnimation(nextTransition, z10, b10); if (onCreateAnimation != null) { return new d(onCreateAnimation); } Animator onCreateAnimator = fragment.onCreateAnimator(nextTransition, z10, b10); if (onCreateAnimator != null) { return new d(onCreateAnimator); } if (b10 == 0 && nextTransition != 0) { b10 = d(nextTransition, z10); } if (b10 != 0) { boolean equals = "anim".equals(context.getResources().getResourceTypeName(b10)); if (equals) { try { Animation loadAnimation = AnimationUtils.loadAnimation(context, b10); if (loadAnimation != null) { return new d(loadAnimation); } z12 = true; } catch (Resources.NotFoundException e10) { throw e10; } catch (RuntimeException unused) { } } if (!z12) { try { Animator loadAnimator = AnimatorInflater.loadAnimator(context, b10); if (loadAnimator != null) { return new d(loadAnimator); } } catch (RuntimeException e11) { if (equals) { throw e11; } Animation loadAnimation2 = AnimationUtils.loadAnimation(context, b10); if (loadAnimation2 != null) { return new d(loadAnimation2); } } } } return null; } private static int d(int i10, boolean z10) { if (i10 == 4097) { return z10 ? f0.a.f9487e : f0.a.f9488f; } if (i10 == 4099) { return z10 ? f0.a.f9485c : f0.a.f9486d; } if (i10 != 8194) { return -1; } return z10 ? f0.a.f9483a : f0.a.f9484b; } static class d { /* renamed from: a, reason: collision with root package name */ public final Animation f1820a; /* renamed from: b, reason: collision with root package name */ public final Animator f1821b; d(Animation animation) { this.f1820a = animation; this.f1821b = null; if (animation == null) { throw new IllegalStateException("Animation cannot be null"); } } d(Animator animator) { this.f1820a = null; this.f1821b = animator; if (animator == null) { throw new IllegalStateException("Animator cannot be null"); } } } static class e extends AnimationSet implements Runnable { /* renamed from: a, reason: collision with root package name */ private final ViewGroup f1822a; /* renamed from: b, reason: collision with root package name */ private final View f1823b; /* renamed from: c, reason: collision with root package name */ private boolean f1824c; /* renamed from: d, reason: collision with root package name */ private boolean f1825d; /* renamed from: e, reason: collision with root package name */ private boolean f1826e; e(Animation animation, ViewGroup viewGroup, View view) { super(false); this.f1826e = true; this.f1822a = viewGroup; this.f1823b = view; addAnimation(animation); viewGroup.post(this); } @Override // android.view.animation.AnimationSet, android.view.animation.Animation public boolean getTransformation(long j10, Transformation transformation) { this.f1826e = true; if (this.f1824c) { return !this.f1825d; } if (!super.getTransformation(j10, transformation)) { this.f1824c = true; l0.a(this.f1822a, this); } return true; } @Override // java.lang.Runnable public void run() { if (this.f1824c || !this.f1826e) { this.f1822a.endViewTransition(this.f1823b); this.f1825d = true; } else { this.f1826e = false; this.f1822a.post(this); } } @Override // android.view.animation.Animation public boolean getTransformation(long j10, Transformation transformation, float f10) { this.f1826e = true; if (this.f1824c) { return !this.f1825d; } if (!super.getTransformation(j10, transformation, f10)) { this.f1824c = true; l0.a(this.f1822a, this); } return true; } } }