package c.j;

import android.annotation.SuppressLint;
import android.os.Bundle;
import androidx.savedstate.Recreator;

/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"RestrictedApi"})
public final class a {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Bundle f5395b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Recreator.a f5397d;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public c.c.a.b.b<String, b> f5394a = new c.c.a.b.b<>();

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public boolean f5398e = true;

    /* JADX INFO: renamed from: c.j.a$a, reason: collision with other inner class name */
    public interface InterfaceC0073a {
        void a(c cVar);
    }

    public interface b {
        Bundle a();
    }

    public Bundle a(String str) {
        if (!this.f5396c) {
            throw new IllegalStateException("You can consumeRestoredStateForKey only after super.onCreate of corresponding component");
        }
        Bundle bundle = this.f5395b;
        if (bundle == null) {
            return null;
        }
        Bundle bundle2 = bundle.getBundle(str);
        this.f5395b.remove(str);
        if (this.f5395b.isEmpty()) {
            this.f5395b = null;
        }
        return bundle2;
    }

    public void b(String str, b bVar) {
        if (this.f5394a.d(str, bVar) != null) {
            throw new IllegalArgumentException("SavedStateProvider with the given key is already registered");
        }
    }

    public void c(Class<? extends InterfaceC0073a> cls) {
        if (!this.f5398e) {
            throw new IllegalStateException("Can not perform this action after onSaveInstanceState");
        }
        if (this.f5397d == null) {
            this.f5397d = new Recreator.a(this);
        }
        try {
            cls.getDeclaredConstructor(new Class[0]);
            Recreator.a aVar = this.f5397d;
            aVar.f4710a.add(cls.getName());
        } catch (NoSuchMethodException e2) {
            StringBuilder sbC = a.b.c.a.a.C("Class");
            sbC.append(cls.getSimpleName());
            sbC.append(" must have default constructor in order to be automatically recreated");
            throw new IllegalArgumentException(sbC.toString(), e2);
        }
    }
}
