package androidx.lifecycle; import android.app.Activity; import android.app.Application; import android.content.Context; import android.os.Build; import android.os.Bundle; import android.os.Handler; import androidx.lifecycle.e; import androidx.lifecycle.p; /* loaded from: classes.dex */ public class o implements LifecycleOwner { /* renamed from: i, reason: collision with root package name */ private static final o f2095i = new o(); /* renamed from: e, reason: collision with root package name */ private Handler f2100e; /* renamed from: a, reason: collision with root package name */ private int f2096a = 0; /* renamed from: b, reason: collision with root package name */ private int f2097b = 0; /* renamed from: c, reason: collision with root package name */ private boolean f2098c = true; /* renamed from: d, reason: collision with root package name */ private boolean f2099d = true; /* renamed from: f, reason: collision with root package name */ private final i f2101f = new i(this); /* renamed from: g, reason: collision with root package name */ private Runnable f2102g = new a(); /* renamed from: h, reason: collision with root package name */ p.a f2103h = new b(); class a implements Runnable { a() { } @Override // java.lang.Runnable public void run() { o.this.f(); o.this.g(); } } class b implements p.a { b() { } @Override // androidx.lifecycle.p.a public void a() { } @Override // androidx.lifecycle.p.a public void onResume() { o.this.b(); } @Override // androidx.lifecycle.p.a public void onStart() { o.this.c(); } } class c extends androidx.lifecycle.c { class a extends androidx.lifecycle.c { a() { } @Override // android.app.Application.ActivityLifecycleCallbacks public void onActivityPostResumed(Activity activity) { o.this.b(); } @Override // android.app.Application.ActivityLifecycleCallbacks public void onActivityPostStarted(Activity activity) { o.this.c(); } } c() { } @Override // androidx.lifecycle.c, android.app.Application.ActivityLifecycleCallbacks public void onActivityCreated(Activity activity, Bundle bundle) { if (Build.VERSION.SDK_INT < 29) { p.f(activity).h(o.this.f2103h); } } @Override // androidx.lifecycle.c, android.app.Application.ActivityLifecycleCallbacks public void onActivityPaused(Activity activity) { o.this.a(); } @Override // android.app.Application.ActivityLifecycleCallbacks public void onActivityPreCreated(Activity activity, Bundle bundle) { d.a(activity, new a()); } @Override // androidx.lifecycle.c, android.app.Application.ActivityLifecycleCallbacks public void onActivityStopped(Activity activity) { o.this.d(); } } static class d { static void a(Activity activity, Application.ActivityLifecycleCallbacks activityLifecycleCallbacks) { activity.registerActivityLifecycleCallbacks(activityLifecycleCallbacks); } } private o() { } public static LifecycleOwner h() { return f2095i; } static void i(Context context) { f2095i.e(context); } void a() { int i10 = this.f2097b - 1; this.f2097b = i10; if (i10 == 0) { this.f2100e.postDelayed(this.f2102g, 700L); } } void b() { int i10 = this.f2097b + 1; this.f2097b = i10; if (i10 == 1) { if (!this.f2098c) { this.f2100e.removeCallbacks(this.f2102g); } else { this.f2101f.h(e.b.ON_RESUME); this.f2098c = false; } } } void c() { int i10 = this.f2096a + 1; this.f2096a = i10; if (i10 == 1 && this.f2099d) { this.f2101f.h(e.b.ON_START); this.f2099d = false; } } void d() { this.f2096a--; g(); } void e(Context context) { this.f2100e = new Handler(); this.f2101f.h(e.b.ON_CREATE); ((Application) context.getApplicationContext()).registerActivityLifecycleCallbacks(new c()); } void f() { if (this.f2097b == 0) { this.f2098c = true; this.f2101f.h(e.b.ON_PAUSE); } } void g() { if (this.f2096a == 0 && this.f2098c) { this.f2101f.h(e.b.ON_STOP); this.f2099d = true; } } @Override // androidx.lifecycle.LifecycleOwner public e getLifecycle() { return this.f2101f; } }