package com.mbridge.msdk.mbdownload; import android.content.Context; import android.content.SharedPreferences; import com.mbridge.msdk.foundation.controller.b; import com.mbridge.msdk.foundation.same.b.c; import com.mbridge.msdk.foundation.same.b.e; import com.mbridge.msdk.foundation.tools.FastKV; import com.mbridge.msdk.foundation.tools.w; import java.util.ArrayList; import java.util.List; import java.util.Map; /* compiled from: NotificationRuntimeCache */ public class i { private static final String a = "com.mbridge.msdk.mbdownload.i"; private final Context b; private final boolean c = b.a().d(); private FastKV d; public i(Context context) { this.b = context; } public final void a(int i) { if (this.c && this.d == null) { try { this.d = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "MB_RUNTIME_CACHE").build(); } catch (Exception unused) { this.d = null; } } FastKV fastKV = this.d; if (fastKV != null) { try { fastKV.putString("" + i, ""); } catch (Exception e) { w.b(a, "addNid error", e); } } else { try { SharedPreferences sharedPreferences = this.b.getSharedPreferences("MB_RUNTIME_CACHE", 0); SharedPreferences.Editor edit = sharedPreferences.edit(); synchronized (sharedPreferences) { edit.putString("" + i, ""); edit.apply(); } String str = a; w.b(str, "add nid [" + i + "] to runtime cache."); } catch (Exception unused2) { } } } public final List<Integer> a() { ArrayList arrayList = new ArrayList(); Map<String, Object> map = null; if (this.c && this.d == null) { try { this.d = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "MB_RUNTIME_CACHE").build(); } catch (Exception unused) { this.d = null; } } FastKV fastKV = this.d; if (fastKV != null) { try { map = fastKV.getAll(); } catch (Exception unused2) { } if (map != null) { for (String str : map.keySet()) { try { int parseInt = Integer.parseInt(str); arrayList.add(Integer.valueOf(parseInt)); String str2 = a; w.b(str2, "get nid [" + parseInt + "]"); } catch (NumberFormatException unused3) { } } } this.d.clear(); } else { try { SharedPreferences sharedPreferences = this.b.getSharedPreferences("MB_RUNTIME_CACHE", 0); for (String str3 : sharedPreferences.getAll().keySet()) { try { int parseInt2 = Integer.parseInt(str3); arrayList.add(Integer.valueOf(parseInt2)); String str4 = a; w.b(str4, "get nid [" + parseInt2 + "]"); } catch (NumberFormatException unused4) { } } sharedPreferences.edit().clear().apply(); } catch (Exception unused5) { } } return arrayList; } public final boolean b() { if (this.c && this.d == null) { try { this.d = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "MB_RUNTIME_CACHE").build(); } catch (Exception unused) { this.d = null; } } FastKV fastKV = this.d; if (fastKV != null) { try { if (fastKV.getAll().size() > 0) { return true; } return false; } catch (Exception unused2) { return false; } } else if (this.b.getSharedPreferences("MB_RUNTIME_CACHE", 0).getAll().size() > 0) { return true; } else { return false; } } public final void b(int i) { try { SharedPreferences sharedPreferences = this.b.getSharedPreferences("MB_RUNTIME_CACHE", 0); if (sharedPreferences.contains("" + i)) { SharedPreferences.Editor edit = sharedPreferences.edit(); edit.remove("" + i); edit.apply(); } String str = a; w.b(str, "remove nid [" + i + "] to runtime cache."); } catch (Exception unused) { } } }