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.AbstractC0424i;
import androidx.lifecycle.FragmentC0449w;

/* renamed from: androidx.lifecycle.u */
/* loaded from: classes.dex */
public class C0443u implements InterfaceC0434m {

    /* renamed from: l */
    public static final C0443u f1652l = new C0443u();

    /* renamed from: h */
    public Handler f1657h;

    /* renamed from: d */
    public int f1653d = 0;

    /* renamed from: e */
    public int f1654e = 0;

    /* renamed from: f */
    public boolean f1655f = true;

    /* renamed from: g */
    public boolean f1656g = true;

    /* renamed from: i */
    public final C0435n f1658i = new C0435n(this);

    /* renamed from: j */
    public Runnable f1659j = new RunnableC0444a();

    /* renamed from: k */
    public FragmentC0449w.InterfaceC0450a f1660k = new C0445b();

    /* renamed from: androidx.lifecycle.u$a */
    /* loaded from: classes.dex */
    public class RunnableC0444a implements Runnable {
        public RunnableC0444a() {
        }

        @Override // java.lang.Runnable
        public void run() {
            C0443u.this.m3664i();
            C0443u.this.m3663j();
        }
    }

    /* renamed from: androidx.lifecycle.u$b */
    /* loaded from: classes.dex */
    public class C0445b implements FragmentC0449w.InterfaceC0450a {
        public C0445b() {
        }

        @Override // androidx.lifecycle.FragmentC0449w.InterfaceC0450a
        /* renamed from: a */
        public void mo3651a() {
        }

        @Override // androidx.lifecycle.FragmentC0449w.InterfaceC0450a
        /* renamed from: b */
        public void mo3650b() {
            C0443u.this.m3668e();
        }

        @Override // androidx.lifecycle.FragmentC0449w.InterfaceC0450a
        /* renamed from: c */
        public void mo3649c() {
            C0443u.this.m3667f();
        }
    }

    /* renamed from: androidx.lifecycle.u$c */
    /* loaded from: classes.dex */
    public class C0446c extends C0406d {

        /* renamed from: androidx.lifecycle.u$c$a */
        /* loaded from: classes.dex */
        public class C0447a extends C0406d {
            public C0447a() {
            }

            @Override // android.app.Application.ActivityLifecycleCallbacks
            public void onActivityPostResumed(Activity activity) {
                C0443u.this.m3668e();
            }

            @Override // android.app.Application.ActivityLifecycleCallbacks
            public void onActivityPostStarted(Activity activity) {
                C0443u.this.m3667f();
            }
        }

        public C0446c() {
        }

        @Override // androidx.lifecycle.C0406d, android.app.Application.ActivityLifecycleCallbacks
        public void onActivityCreated(Activity activity, Bundle bundle) {
            if (Build.VERSION.SDK_INT < 29) {
                FragmentC0449w.m3654f(activity).m3652h(C0443u.this.f1660k);
            }
        }

        @Override // androidx.lifecycle.C0406d, android.app.Application.ActivityLifecycleCallbacks
        public void onActivityPaused(Activity activity) {
            C0443u.this.m3669b();
        }

        @Override // android.app.Application.ActivityLifecycleCallbacks
        public void onActivityPreCreated(Activity activity, Bundle bundle) {
            activity.registerActivityLifecycleCallbacks(new C0447a());
        }

        @Override // androidx.lifecycle.C0406d, android.app.Application.ActivityLifecycleCallbacks
        public void onActivityStopped(Activity activity) {
            C0443u.this.m3666g();
        }
    }

    /* renamed from: k */
    public static InterfaceC0434m m3662k() {
        return f1652l;
    }

    /* renamed from: l */
    public static void m3661l(Context context) {
        f1652l.m3665h(context);
    }

    @Override // androidx.lifecycle.InterfaceC0434m
    /* renamed from: a */
    public AbstractC0424i mo421a() {
        return this.f1658i;
    }

    /* renamed from: b */
    public void m3669b() {
        int i = this.f1654e - 1;
        this.f1654e = i;
        if (i == 0) {
            this.f1657h.postDelayed(this.f1659j, 700L);
        }
    }

    /* renamed from: e */
    public void m3668e() {
        int i = this.f1654e + 1;
        this.f1654e = i;
        if (i == 1) {
            if (!this.f1655f) {
                this.f1657h.removeCallbacks(this.f1659j);
                return;
            }
            this.f1658i.m3686h(AbstractC0424i.EnumC0426b.ON_RESUME);
            this.f1655f = false;
        }
    }

    /* renamed from: f */
    public void m3667f() {
        int i = this.f1653d + 1;
        this.f1653d = i;
        if (i == 1 && this.f1656g) {
            this.f1658i.m3686h(AbstractC0424i.EnumC0426b.ON_START);
            this.f1656g = false;
        }
    }

    /* renamed from: g */
    public void m3666g() {
        this.f1653d--;
        m3663j();
    }

    /* renamed from: h */
    public void m3665h(Context context) {
        this.f1657h = new Handler();
        this.f1658i.m3686h(AbstractC0424i.EnumC0426b.ON_CREATE);
        ((Application) context.getApplicationContext()).registerActivityLifecycleCallbacks(new C0446c());
    }

    /* renamed from: i */
    public void m3664i() {
        if (this.f1654e == 0) {
            this.f1655f = true;
            this.f1658i.m3686h(AbstractC0424i.EnumC0426b.ON_PAUSE);
        }
    }

    /* renamed from: j */
    public void m3663j() {
        if (this.f1653d == 0 && this.f1655f) {
            this.f1658i.m3686h(AbstractC0424i.EnumC0426b.ON_STOP);
            this.f1656g = true;
        }
    }
}