package com.ubt.jimu.utils; import android.content.Context; import android.content.SharedPreferences; import com.ubt.jimu.JimuApplication; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.StreamCorruptedException; /* loaded from: classes2.dex */ public class SPUtils { private static SharedPreferences a; public static int a(String str, int i) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } return a.getInt(str, i); } public static boolean b(String str, int i) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } SharedPreferences.Editor edit = a.edit(); edit.putInt(str, i); return edit.commit(); } public static Object c(String str) { return a(JimuApplication.l(), "JIMU_APP_CONFIG", str); } public static boolean a(String str, String str2) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } SharedPreferences.Editor edit = a.edit(); edit.putString(str, str2); return edit.commit(); } public static String b(String str) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } return a.getString(str, ""); } public static boolean a(String str, boolean z) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } SharedPreferences.Editor edit = a.edit(); edit.putBoolean(str, z); return edit.commit(); } public static Object b(String str, String str2) { return a(JimuApplication.l(), str, str2); } public static boolean a(String str) { if (a == null) { a = JimuApplication.l().getSharedPreferences("JIMU_APP_CONFIG", 0); } return a.getBoolean(str, false); } /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:47:0x004c -> B:11:0x004f). Please report as a decompilation issue!!! */ public static void a(Context context, String str, String str2, Object obj) { ObjectOutputStream objectOutputStream; SharedPreferences sharedPreferences = context.getSharedPreferences(str, 0); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream2 = null; try { try { try { objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); try { objectOutputStream.writeObject(obj); String encodeToString = android.util.Base64.encodeToString(byteArrayOutputStream.toByteArray(), 0); SharedPreferences.Editor edit = sharedPreferences.edit(); edit.putString(str2, encodeToString); edit.commit(); try { byteArrayOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } objectOutputStream.close(); } catch (IOException e2) { e = e2; objectOutputStream2 = objectOutputStream; e.printStackTrace(); try { byteArrayOutputStream.close(); } catch (IOException e3) { e3.printStackTrace(); } if (objectOutputStream2 != null) { objectOutputStream2.close(); } } catch (Throwable th) { th = th; try { byteArrayOutputStream.close(); } catch (IOException e4) { e4.printStackTrace(); } if (objectOutputStream != null) { try { objectOutputStream.close(); throw th; } catch (IOException e5) { e5.printStackTrace(); throw th; } } throw th; } } catch (Throwable th2) { th = th2; objectOutputStream = objectOutputStream2; } } catch (IOException e6) { e = e6; } } catch (IOException e7) { e7.printStackTrace(); } } public static void a(String str, Object obj) { a(JimuApplication.l(), "JIMU_APP_CONFIG", str, obj); } public static void a(String str, String str2, Object obj) { a(JimuApplication.l(), str, str2, obj); } public static Object a(Context context, String str, String str2) { String string = context.getSharedPreferences(str, 0).getString(str2, ""); if (android.text.TextUtils.isEmpty(string)) { return null; } try { try { return new ObjectInputStream(new ByteArrayInputStream(android.util.Base64.decode(string.getBytes(), 0))).readObject(); } catch (ClassNotFoundException e) { e.printStackTrace(); return null; } } catch (StreamCorruptedException e2) { e2.printStackTrace(); return null; } catch (IOException e3) { e3.printStackTrace(); return null; } } public static Object a(Context context, String str) { return a(context, "JIMU_USER_CONFIG", str); } }