apkfuckery/com.discord/smali/androidx/savedstate/Recreator.smali
2020-09-16 23:45:23 +00:00

241 lines
6.7 KiB
Smali

.class public final Landroidx/savedstate/Recreator;
.super Ljava/lang/Object;
.source "Recreator.java"
# interfaces
.implements Landroidx/lifecycle/GenericLifecycleObserver;
# annotations
.annotation build Landroid/annotation/SuppressLint;
value = {
"RestrictedApi"
}
.end annotation
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Landroidx/savedstate/Recreator$SavedStateProvider;
}
.end annotation
# static fields
.field public static final CLASSES_KEY:Ljava/lang/String; = "classes_to_restore"
.field public static final COMPONENT_KEY:Ljava/lang/String; = "androidx.savedstate.Restarter"
# instance fields
.field public final mOwner:Landroidx/savedstate/SavedStateRegistryOwner;
# direct methods
.method public constructor <init>(Landroidx/savedstate/SavedStateRegistryOwner;)V
.locals 0
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Landroidx/savedstate/Recreator;->mOwner:Landroidx/savedstate/SavedStateRegistryOwner;
return-void
.end method
.method private reflectiveNew(Ljava/lang/String;)V
.locals 4
:try_start_0
const-class v0, Landroidx/savedstate/Recreator;
invoke-virtual {v0}, Ljava/lang/Class;->getClassLoader()Ljava/lang/ClassLoader;
move-result-object v0
const/4 v1, 0x0
invoke-static {p1, v1, v0}, Ljava/lang/Class;->forName(Ljava/lang/String;ZLjava/lang/ClassLoader;)Ljava/lang/Class;
move-result-object v0
const-class v2, Landroidx/savedstate/SavedStateRegistry$AutoRecreated;
invoke-virtual {v0, v2}, Ljava/lang/Class;->asSubclass(Ljava/lang/Class;)Ljava/lang/Class;
move-result-object v0
:try_end_0
.catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_2
:try_start_1
new-array v2, v1, [Ljava/lang/Class;
invoke-virtual {v0, v2}, Ljava/lang/Class;->getDeclaredConstructor([Ljava/lang/Class;)Ljava/lang/reflect/Constructor;
move-result-object v0
:try_end_1
.catch Ljava/lang/NoSuchMethodException; {:try_start_1 .. :try_end_1} :catch_1
const/4 v2, 0x1
invoke-virtual {v0, v2}, Ljava/lang/reflect/Constructor;->setAccessible(Z)V
:try_start_2
new-array v1, v1, [Ljava/lang/Object;
invoke-virtual {v0, v1}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroidx/savedstate/SavedStateRegistry$AutoRecreated;
:try_end_2
.catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_0
iget-object p1, p0, Landroidx/savedstate/Recreator;->mOwner:Landroidx/savedstate/SavedStateRegistryOwner;
invoke-interface {v0, p1}, Landroidx/savedstate/SavedStateRegistry$AutoRecreated;->onRecreated(Landroidx/savedstate/SavedStateRegistryOwner;)V
return-void
:catch_0
move-exception v0
new-instance v1, Ljava/lang/RuntimeException;
const-string v2, "Failed to instantiate "
invoke-static {v2, p1}, Lf/e/b/a/a;->q(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object p1
invoke-direct {v1, p1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
:catch_1
move-exception p1
new-instance v1, Ljava/lang/IllegalStateException;
const-string v2, "Class"
invoke-static {v2}, Lf/e/b/a/a;->E(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v2
invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;
move-result-object v0
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v0, " must have default constructor in order to be automatically recreated"
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-direct {v1, v0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
:catch_2
move-exception v0
new-instance v1, Ljava/lang/RuntimeException;
const-string v2, "Class "
const-string v3, " wasn\'t found"
invoke-static {v2, p1, v3}, Lf/e/b/a/a;->r(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object p1
invoke-direct {v1, p1, v0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v1
.end method
# virtual methods
.method public onStateChanged(Landroidx/lifecycle/LifecycleOwner;Landroidx/lifecycle/Lifecycle$Event;)V
.locals 1
sget-object v0, Landroidx/lifecycle/Lifecycle$Event;->ON_CREATE:Landroidx/lifecycle/Lifecycle$Event;
if-ne p2, v0, :cond_3
invoke-interface {p1}, Landroidx/lifecycle/LifecycleOwner;->getLifecycle()Landroidx/lifecycle/Lifecycle;
move-result-object p1
invoke-virtual {p1, p0}, Landroidx/lifecycle/Lifecycle;->removeObserver(Landroidx/lifecycle/LifecycleObserver;)V
iget-object p1, p0, Landroidx/savedstate/Recreator;->mOwner:Landroidx/savedstate/SavedStateRegistryOwner;
invoke-interface {p1}, Landroidx/savedstate/SavedStateRegistryOwner;->getSavedStateRegistry()Landroidx/savedstate/SavedStateRegistry;
move-result-object p1
const-string p2, "androidx.savedstate.Restarter"
invoke-virtual {p1, p2}, Landroidx/savedstate/SavedStateRegistry;->consumeRestoredStateForKey(Ljava/lang/String;)Landroid/os/Bundle;
move-result-object p1
if-nez p1, :cond_0
return-void
:cond_0
const-string p2, "classes_to_restore"
invoke-virtual {p1, p2}, Landroid/os/Bundle;->getStringArrayList(Ljava/lang/String;)Ljava/util/ArrayList;
move-result-object p1
if-eqz p1, :cond_2
invoke-virtual {p1}, Ljava/util/ArrayList;->iterator()Ljava/util/Iterator;
move-result-object p1
:goto_0
invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z
move-result p2
if-eqz p2, :cond_1
invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object p2
check-cast p2, Ljava/lang/String;
invoke-direct {p0, p2}, Landroidx/savedstate/Recreator;->reflectiveNew(Ljava/lang/String;)V
goto :goto_0
:cond_1
return-void
:cond_2
new-instance p1, Ljava/lang/IllegalStateException;
const-string p2, "Bundle with restored state for the component \"androidx.savedstate.Restarter\" must contain list of strings by the key \"classes_to_restore\""
invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw p1
:cond_3
new-instance p1, Ljava/lang/AssertionError;
const-string p2, "Next event must be ON_CREATE"
invoke-direct {p1, p2}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
throw p1
.end method