- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
82 lines
3.8 KiB
Java
82 lines
3.8 KiB
Java
package androidx.datastore.preferences;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.GuardedBy;
|
|
import androidx.datastore.core.DataStore;
|
|
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler;
|
|
import androidx.datastore.preferences.core.PreferenceDataStoreFactory;
|
|
import androidx.datastore.preferences.core.Preferences;
|
|
import java.io.File;
|
|
import java.util.List;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.properties.ReadOnlyProperty;
|
|
import kotlin.reflect.KProperty;
|
|
import kotlinx.coroutines.CoroutineScope;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class PreferenceDataStoreSingletonDelegate implements ReadOnlyProperty {
|
|
|
|
@GuardedBy("lock")
|
|
private volatile DataStore<Preferences> INSTANCE;
|
|
private final ReplaceFileCorruptionHandler<Preferences> corruptionHandler;
|
|
private final Object lock;
|
|
private final String name;
|
|
private final Function1 produceMigrations;
|
|
private final CoroutineScope scope;
|
|
|
|
public PreferenceDataStoreSingletonDelegate(String name, ReplaceFileCorruptionHandler<Preferences> replaceFileCorruptionHandler, Function1 produceMigrations, CoroutineScope scope) {
|
|
Intrinsics.checkNotNullParameter(name, "name");
|
|
Intrinsics.checkNotNullParameter(produceMigrations, "produceMigrations");
|
|
Intrinsics.checkNotNullParameter(scope, "scope");
|
|
this.name = name;
|
|
this.corruptionHandler = replaceFileCorruptionHandler;
|
|
this.produceMigrations = produceMigrations;
|
|
this.scope = scope;
|
|
this.lock = new Object();
|
|
}
|
|
|
|
@Override // kotlin.properties.ReadOnlyProperty
|
|
public DataStore<Preferences> getValue(Context thisRef, KProperty property) {
|
|
DataStore<Preferences> dataStore;
|
|
Intrinsics.checkNotNullParameter(thisRef, "thisRef");
|
|
Intrinsics.checkNotNullParameter(property, "property");
|
|
DataStore<Preferences> dataStore2 = this.INSTANCE;
|
|
if (dataStore2 != null) {
|
|
return dataStore2;
|
|
}
|
|
synchronized (this.lock) {
|
|
try {
|
|
if (this.INSTANCE == null) {
|
|
final Context applicationContext = thisRef.getApplicationContext();
|
|
PreferenceDataStoreFactory preferenceDataStoreFactory = PreferenceDataStoreFactory.INSTANCE;
|
|
ReplaceFileCorruptionHandler<Preferences> replaceFileCorruptionHandler = this.corruptionHandler;
|
|
Function1 function1 = this.produceMigrations;
|
|
Intrinsics.checkNotNullExpressionValue(applicationContext, "applicationContext");
|
|
this.INSTANCE = preferenceDataStoreFactory.create(replaceFileCorruptionHandler, (List) function1.invoke(applicationContext), this.scope, new Function0() { // from class: androidx.datastore.preferences.PreferenceDataStoreSingletonDelegate$getValue$1$1
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
{
|
|
super(0);
|
|
}
|
|
|
|
@Override // kotlin.jvm.functions.Function0
|
|
public final File invoke() {
|
|
String str;
|
|
Context applicationContext2 = applicationContext;
|
|
Intrinsics.checkNotNullExpressionValue(applicationContext2, "applicationContext");
|
|
str = this.name;
|
|
return PreferenceDataStoreFile.preferencesDataStoreFile(applicationContext2, str);
|
|
}
|
|
});
|
|
}
|
|
dataStore = this.INSTANCE;
|
|
Intrinsics.checkNotNull(dataStore);
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return dataStore;
|
|
}
|
|
}
|