117 lines
4.6 KiB
Java
117 lines
4.6 KiB
Java
package c.i.a.f.i.b;
|
|
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import androidx.annotation.WorkerThread;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
/* compiled from: com.google.android.gms:play-services-measurement-impl@@18.0.0 */
|
|
public final class i4 {
|
|
public final String a;
|
|
public final Bundle b = new Bundle();
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public boolean f1156c;
|
|
public Bundle d;
|
|
public final /* synthetic */ d4 e;
|
|
|
|
public i4(d4 d4Var, String str) {
|
|
this.e = d4Var;
|
|
AnimatableValueParser.w(str);
|
|
this.a = str;
|
|
}
|
|
|
|
@WorkerThread
|
|
public final Bundle a() {
|
|
if (!this.f1156c) {
|
|
this.f1156c = true;
|
|
String string = this.e.w().getString(this.a, null);
|
|
if (string != null) {
|
|
try {
|
|
Bundle bundle = new Bundle();
|
|
JSONArray jSONArray = new JSONArray(string);
|
|
for (int i = 0; i < jSONArray.length(); i++) {
|
|
JSONObject jSONObject = jSONArray.getJSONObject(i);
|
|
String string2 = jSONObject.getString("n");
|
|
String string3 = jSONObject.getString("t");
|
|
char c2 = 65535;
|
|
int hashCode = string3.hashCode();
|
|
if (hashCode != 100) {
|
|
if (hashCode != 108) {
|
|
if (hashCode == 115 && string3.equals("s")) {
|
|
c2 = 0;
|
|
}
|
|
} else if (string3.equals("l")) {
|
|
c2 = 2;
|
|
}
|
|
} else if (string3.equals("d")) {
|
|
c2 = 1;
|
|
}
|
|
if (c2 == 0) {
|
|
bundle.putString(string2, jSONObject.getString("v"));
|
|
} else if (c2 == 1) {
|
|
bundle.putDouble(string2, Double.parseDouble(jSONObject.getString("v")));
|
|
} else if (c2 != 2) {
|
|
try {
|
|
this.e.g().f.b("Unrecognized persisted bundle type. Type", string3);
|
|
} catch (NumberFormatException | JSONException unused) {
|
|
this.e.g().f.a("Error reading value from SharedPreferences. Value dropped");
|
|
}
|
|
} else {
|
|
bundle.putLong(string2, Long.parseLong(jSONObject.getString("v")));
|
|
}
|
|
}
|
|
this.d = bundle;
|
|
} catch (JSONException unused2) {
|
|
this.e.g().f.a("Error loading bundle from SharedPreferences. Values will be lost");
|
|
}
|
|
}
|
|
if (this.d == null) {
|
|
this.d = this.b;
|
|
}
|
|
}
|
|
return this.d;
|
|
}
|
|
|
|
@WorkerThread
|
|
public final void b(Bundle bundle) {
|
|
if (bundle == null) {
|
|
bundle = new Bundle();
|
|
}
|
|
SharedPreferences.Editor edit = this.e.w().edit();
|
|
if (bundle.size() == 0) {
|
|
edit.remove(this.a);
|
|
} else {
|
|
String str = this.a;
|
|
JSONArray jSONArray = new JSONArray();
|
|
for (String str2 : bundle.keySet()) {
|
|
Object obj = bundle.get(str2);
|
|
if (obj != null) {
|
|
try {
|
|
JSONObject jSONObject = new JSONObject();
|
|
jSONObject.put("n", str2);
|
|
jSONObject.put("v", String.valueOf(obj));
|
|
if (obj instanceof String) {
|
|
jSONObject.put("t", "s");
|
|
} else if (obj instanceof Long) {
|
|
jSONObject.put("t", "l");
|
|
} else if (obj instanceof Double) {
|
|
jSONObject.put("t", "d");
|
|
} else {
|
|
this.e.g().f.b("Cannot serialize bundle value to SharedPreferences. Type", obj.getClass());
|
|
}
|
|
jSONArray.put(jSONObject);
|
|
} catch (JSONException e) {
|
|
this.e.g().f.b("Cannot serialize bundle value to SharedPreferences", e);
|
|
}
|
|
}
|
|
}
|
|
edit.putString(str, jSONArray.toString());
|
|
}
|
|
edit.apply();
|
|
this.d = bundle;
|
|
}
|
|
}
|