Initial commit
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface FileStore {
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.content.Context;
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class FileStoreImpl implements FileStore {
|
||||
private final Context a;
|
||||
|
||||
public FileStoreImpl(Kit kit) {
|
||||
if (kit.d() == null) {
|
||||
throw new IllegalStateException("Cannot get directory before context has been set. Call Fabric.with() first");
|
||||
}
|
||||
this.a = kit.d();
|
||||
kit.h();
|
||||
String str = "Android/" + this.a.getPackageName();
|
||||
}
|
||||
|
||||
public File a() {
|
||||
return a(this.a.getFilesDir());
|
||||
}
|
||||
|
||||
File a(File file) {
|
||||
if (file == null) {
|
||||
Fabric.g().d("Fabric", "Null File");
|
||||
return null;
|
||||
}
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
return file;
|
||||
}
|
||||
Fabric.g().w("Fabric", "Couldn't create file");
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PersistenceStrategy<T> {
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface PreferenceStore {
|
||||
boolean a(SharedPreferences.Editor editor);
|
||||
|
||||
SharedPreferences.Editor edit();
|
||||
|
||||
SharedPreferences get();
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import io.fabric.sdk.android.Kit;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PreferenceStoreImpl implements PreferenceStore {
|
||||
private final SharedPreferences a;
|
||||
private final String b;
|
||||
private final Context c;
|
||||
|
||||
public PreferenceStoreImpl(Context context, String str) {
|
||||
if (context == null) {
|
||||
throw new IllegalStateException("Cannot get directory before context has been set. Call Fabric.with() first");
|
||||
}
|
||||
this.c = context;
|
||||
this.b = str;
|
||||
this.a = this.c.getSharedPreferences(this.b, 0);
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
@TargetApi(9)
|
||||
public boolean a(SharedPreferences.Editor editor) {
|
||||
if (Build.VERSION.SDK_INT < 9) {
|
||||
return editor.commit();
|
||||
}
|
||||
editor.apply();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
public SharedPreferences.Editor edit() {
|
||||
return this.a.edit();
|
||||
}
|
||||
|
||||
@Override // io.fabric.sdk.android.services.persistence.PreferenceStore
|
||||
public SharedPreferences get() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PreferenceStoreImpl(Kit kit) {
|
||||
this(kit.d(), kit.getClass().getName());
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class PreferenceStoreStrategy<T> implements PersistenceStrategy<T> {
|
||||
private final PreferenceStore a;
|
||||
private final SerializationStrategy<T> b;
|
||||
private final String c;
|
||||
|
||||
public PreferenceStoreStrategy(PreferenceStore preferenceStore, SerializationStrategy<T> serializationStrategy, String str) {
|
||||
this.a = preferenceStore;
|
||||
this.b = serializationStrategy;
|
||||
this.c = str;
|
||||
}
|
||||
|
||||
@SuppressLint({"CommitPrefEdits"})
|
||||
public void a(T t) {
|
||||
PreferenceStore preferenceStore = this.a;
|
||||
preferenceStore.a(preferenceStore.edit().putString(this.c, this.b.serialize(t)));
|
||||
}
|
||||
|
||||
public T b() {
|
||||
return this.b.a(this.a.get().getString(this.c, null));
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.a.edit().remove(this.c).commit();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package io.fabric.sdk.android.services.persistence;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface SerializationStrategy<T> {
|
||||
T a(String str);
|
||||
|
||||
String serialize(T t);
|
||||
}
|
Reference in New Issue
Block a user