翰林优商.apk(点击下载) / a.java


package com.mbridge.msdk.foundation.a.a;

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;

/* compiled from: SharedPerferenceManager */
public class a {
    public static final String a = "a";
    private static a e;
    SharedPreferences b;
    FastKV c;
    private final boolean d = b.a().d();

    private a() {
    }

    public static synchronized a a() {
        a aVar;
        synchronized (a.class) {
            if (e == null) {
                e = new a();
            }
            aVar = e;
        }
        return aVar;
    }

    public final void a(String str, String str2) {
        try {
            Context j = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j != null) {
                if (this.d && this.c == null) {
                    try {
                        this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                    } catch (Exception unused) {
                        this.c = null;
                    }
                }
                FastKV fastKV = this.c;
                if (fastKV != null) {
                    try {
                        fastKV.putString(str, str2);
                    } catch (Exception unused2) {
                    }
                } else {
                    if (this.b == null && j != null) {
                        this.b = j.getSharedPreferences("mbridge", 0);
                    }
                    SharedPreferences.Editor edit = this.b.edit();
                    edit.putString(str, str2);
                    edit.apply();
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public final void a(String str, int i) {
        try {
            Context j = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j != null) {
                if (this.d && this.c == null) {
                    try {
                        this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                    } catch (Exception unused) {
                        this.c = null;
                    }
                }
                FastKV fastKV = this.c;
                if (fastKV != null) {
                    try {
                        fastKV.putInt(str, i);
                    } catch (Exception unused2) {
                    }
                } else {
                    if (this.b == null && j != null) {
                        this.b = j.getSharedPreferences("mbridge", 0);
                    }
                    SharedPreferences.Editor edit = this.b.edit();
                    edit.putInt(str, i);
                    edit.apply();
                }
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public final void a(String str, long j) {
        try {
            Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j2 == null) {
                w.d(a, "context is null in put");
                return;
            }
            if (this.d && this.c == null) {
                try {
                    this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                } catch (Exception unused) {
                    this.c = null;
                }
            }
            FastKV fastKV = this.c;
            if (fastKV != null) {
                try {
                    fastKV.putLong(str, j);
                } catch (Exception unused2) {
                }
            } else {
                if (this.b == null && j2 != null) {
                    this.b = j2.getSharedPreferences("mbridge", 0);
                }
                SharedPreferences.Editor edit = this.b.edit();
                edit.putLong(str, j);
                edit.apply();
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public final Long a(String str) {
        try {
            Context j = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j == null) {
                w.d(a, "context is null in get");
                return 0L;
            }
            if (this.d && this.c == null) {
                try {
                    this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                } catch (Exception unused) {
                    this.c = null;
                }
            }
            FastKV fastKV = this.c;
            if (fastKV != null) {
                try {
                    return Long.valueOf(fastKV.getLong(str, 0));
                } catch (Exception unused2) {
                    return 0L;
                }
            } else {
                if (this.b == null && j != null) {
                    this.b = j.getSharedPreferences("mbridge", 0);
                }
                return Long.valueOf(this.b.getLong(str, 0));
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            return 0L;
        }
    }

    public final int b(String str, int i) {
        try {
            Context j = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j == null) {
                return i;
            }
            if (this.d && this.c == null) {
                try {
                    this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                } catch (Exception unused) {
                    this.c = null;
                }
            }
            FastKV fastKV = this.c;
            if (fastKV != null) {
                try {
                    return fastKV.getInt(str, i);
                } catch (Exception unused2) {
                    return i;
                }
            } else {
                if (this.b == null) {
                    this.b = j.getSharedPreferences("mbridge", 0);
                }
                return this.b.getInt(str, i);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            return i;
        }
    }

    public final String b(String str) {
        try {
            Context j = com.mbridge.msdk.foundation.controller.a.f().j();
            if (j == null) {
                return null;
            }
            if (this.d && this.c == null) {
                try {
                    this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                } catch (Exception unused) {
                    this.c = null;
                }
            }
            FastKV fastKV = this.c;
            if (fastKV != null) {
                try {
                    return fastKV.getString(str, "");
                } catch (Exception unused2) {
                    return "";
                }
            } else {
                if (this.b == null && j != null) {
                    this.b = j.getSharedPreferences("mbridge", 0);
                }
                return this.b.getString(str, "");
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public final void c(String str) {
        Context j = com.mbridge.msdk.foundation.controller.a.f().j();
        if (j != null) {
            if (this.d && this.c == null) {
                try {
                    this.c = new FastKV.Builder(e.b(c.MBRIDGE_700_CONFIG), "mbridge").build();
                } catch (Exception unused) {
                    this.c = null;
                }
            }
            FastKV fastKV = this.c;
            if (fastKV != null) {
                try {
                    fastKV.remove(str);
                } catch (Exception unused2) {
                }
            } else {
                if (this.b == null && j != null) {
                    this.b = j.getSharedPreferences("mbridge", 0);
                }
                this.b.edit().remove(str).apply();
            }
        }
    }
}