大漢易經書院.apk(点击下载) / c.java


package com.baidu.techain.h;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import com.baidu.techain.i.u;
import java.util.Map;
import java.util.Set;

/* compiled from: SharedPreferencesWarpper */
public final class c implements SharedPreferences {
    private SharedPreferences a;
    private Context b;
    private int c;
    private SharedPreferences.Editor d;
    private boolean e;
    private String f;
    private String g;

    public c(Context context, SharedPreferences sharedPreferences, String str, int i) {
        this(context, sharedPreferences, str, false, i, null);
    }

    public c(Context context, SharedPreferences sharedPreferences, String str, boolean z, int i, String str2) {
        this.b = context;
        this.c = i;
        this.a = sharedPreferences;
        this.d = new b(context, sharedPreferences != null ? sharedPreferences.edit() : null, str, z, this.c);
        this.e = z;
        this.f = str;
        this.g = str2;
    }

    @Override // android.content.SharedPreferences
    public final Map<String, ?> getAll() {
        throw new RuntimeException("This preference not allow to call getAll.");
    }

    public final String getString(String str, String str2) {
        try {
            if (this.c != 1 || (this.e && !TextUtils.isEmpty(this.g))) {
                Bundle a2 = a("getString", str, str2);
                if (a2 != null) {
                    return a2.getString("result", str2);
                }
                return str2;
            } else if (this.a == null) {
                return str2;
            } else {
                return this.a.getString(str, str2);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    @Override // android.content.SharedPreferences
    public final Set<String> getStringSet(String str, Set<String> set) {
        throw new RuntimeException("This preference not allow to call getStringSet.");
    }

    public final int getInt(String str, int i) {
        try {
            if (this.c != 1 || (this.e && !TextUtils.isEmpty(this.g))) {
                Bundle a2 = a("getInt", str, String.valueOf(i));
                if (a2 != null) {
                    return a2.getInt("result", i);
                }
                return i;
            } else if (this.a == null) {
                return i;
            } else {
                return this.a.getInt(str, i);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    public final long getLong(String str, long j) {
        try {
            if (this.c != 1 || (this.e && !TextUtils.isEmpty(this.g))) {
                Bundle a2 = a("getLong", str, String.valueOf(j));
                if (a2 != null) {
                    return a2.getLong("result", j);
                }
                return j;
            } else if (this.a == null) {
                return j;
            } else {
                return this.a.getLong(str, j);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    public final float getFloat(String str, float f2) {
        try {
            if (this.c != 1 || (this.e && !TextUtils.isEmpty(this.g))) {
                Bundle a2 = a("getFloat", str, String.valueOf(f2));
                if (a2 != null) {
                    return a2.getFloat("result", f2);
                }
                return f2;
            } else if (this.a == null) {
                return f2;
            } else {
                return this.a.getFloat(str, f2);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    public final boolean getBoolean(String str, boolean z) {
        try {
            if (this.c != 1 || (this.e && !TextUtils.isEmpty(this.g))) {
                Bundle a2 = a("getBoolean", str, String.valueOf(z));
                if (a2 != null) {
                    return a2.getBoolean("result", z);
                }
                return z;
            } else if (this.a == null) {
                return z;
            } else {
                return this.a.getBoolean(str, z);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    public final boolean contains(String str) {
        throw new RuntimeException("This preference not allow to call contains.");
    }

    public final SharedPreferences.Editor edit() {
        SharedPreferences.Editor editor = this.d;
        if (editor != null) {
            return editor;
        }
        SharedPreferences sharedPreferences = this.a;
        if (sharedPreferences != null) {
            return sharedPreferences.edit();
        }
        return null;
    }

    public final void registerOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
        try {
            if (this.a != null) {
                this.a.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    public final void unregisterOnSharedPreferenceChangeListener(SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
        try {
            if (this.a != null) {
                this.a.unregisterOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
            }
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
        }
    }

    private Bundle a(String str, String str2, String str3) {
        try {
            Bundle bundle = new Bundle();
            bundle.putString("operation", str);
            bundle.putString("pref_name", this.f);
            bundle.putString("key", str2);
            bundle.putString("defult_value", str3);
            if (!this.e) {
                return u.a(this.b, "CallPreferences", bundle);
            }
            if (TextUtils.isEmpty(this.g)) {
                return u.a(this.b, "CallPreferences", bundle);
            }
            return u.a(this.b, "CallPreferences", bundle, this.g);
        } catch (Throwable unused) {
            com.baidu.techain.i.c.a();
            return null;
        }
    }
}