package com.tapjoy; import android.content.SharedPreferences; import android.util.Log; import java.util.List; import java.util.Map; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes4.dex */ public final class TJPreferencesMigration { public final TJKeyValueStorage a; public final SharedPreferences b; public final Map c; public final List d; public TJPreferencesMigration(TJKeyValueStorage tjKeyValueStorage, SharedPreferences migratingPreferences, Map migratingKeysMapping, List listOfDoubles) { Intrinsics.checkNotNullParameter(tjKeyValueStorage, "tjKeyValueStorage"); Intrinsics.checkNotNullParameter(migratingPreferences, "migratingPreferences"); Intrinsics.checkNotNullParameter(migratingKeysMapping, "migratingKeysMapping"); Intrinsics.checkNotNullParameter(listOfDoubles, "listOfDoubles"); this.a = tjKeyValueStorage; this.b = migratingPreferences; this.c = migratingKeysMapping; this.d = listOfDoubles; } public final void a(String str, Object obj) { if (this.b.contains(str)) { Object valueOf = obj instanceof Boolean ? Boolean.valueOf(this.b.getBoolean(str, false)) : obj instanceof Float ? Float.valueOf(this.b.getFloat(str, 0.0f)) : obj instanceof Integer ? Integer.valueOf(this.b.getInt(str, 0)) : obj instanceof Long ? Long.valueOf(this.b.getLong(str, 0L)) : obj instanceof String ? this.b.getString(str, null) : null; String str2 = (String) this.c.get(str); if (str2 == null) { str2 = str; } if (valueOf != null) { try { if (this.d.contains(str)) { this.a.setValue(str2, Double.valueOf(Double.parseDouble(valueOf.toString()))); } else { this.a.setValue(str2, valueOf); } } catch (IllegalArgumentException unused) { Log.e("TJPreferencesMigration", "Failed to migrate key: " + str); } } this.b.edit().remove(str).apply(); } } public final void migrateAllKeysIfExists() { Map all = this.b.getAll(); if (all != null) { for (Map.Entry entry : all.entrySet()) { if (this.c.containsKey(entry.getKey())) { String key = entry.getKey(); Intrinsics.checkNotNullExpressionValue(key, "(...)"); a(key, entry.getValue()); } } } } }