diff options
author | Sean Leonard <meanderingcode@aetherislands.net> | 2013-02-07 01:34:49 -0700 |
---|---|---|
committer | Sean Leonard <meanderingcode@aetherislands.net> | 2013-02-07 01:34:49 -0700 |
commit | c107e15a1ca7707a7c2351a3c31f3dbd9f156b73 (patch) | |
tree | c9a818953f06ab574283cf9eb989fd729bb3c810 /src/se/leap/leapclient/Provider.java | |
parent | 6e0142a335eafe8a9b0e41b0e968038c0aeabd11 (diff) |
Rearrange singleton Provider.class pattern, Fix isolated SharedPreferences silos
Diffstat (limited to 'src/se/leap/leapclient/Provider.java')
-rw-r--r-- | src/se/leap/leapclient/Provider.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/se/leap/leapclient/Provider.java b/src/se/leap/leapclient/Provider.java index b5e81c9d..4235acfd 100644 --- a/src/se/leap/leapclient/Provider.java +++ b/src/se/leap/leapclient/Provider.java @@ -11,6 +11,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.app.Activity; import android.content.SharedPreferences; /** @@ -49,13 +50,24 @@ final class Provider implements Serializable { /** * */ - private Provider(SharedPreferences preferences) { + private Provider() {} + + protected static Provider getInstance(){ + if(instance==null){ + instance = new Provider(); + } + return instance; + } + + protected void init(Activity activity) { // Load our preferences from SharedPreferences // If there's nothing there, we will end up returning a rather empty object // to whoever called getInstance() and they can run the First Run Wizard //preferences = context.getgetPreferences(0); // 0 == MODE_PRIVATE, but we don't extend Android's classes... + // Load SharedPreferences + preferences = activity.getSharedPreferences(ConfigHelper.PREFERENCES_KEY,0); // We don't get MODE_PRIVATE by importing SharedPreferences; i guess it's in Activity? // Inflate our provider.json data try { definition = new JSONObject( preferences.getString("provider", "") ); @@ -66,13 +78,6 @@ final class Provider implements Serializable { } } - protected static Provider getInstance(SharedPreferences preferences){ - if(instance==null){ - instance = new Provider(preferences); - } - return instance; - } - protected String getName(){ // Should we pass the locale in, or query the system here? String lang = Locale.getDefault().getLanguage(); |