Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static synchronized GlobalClass getInstance()
  2. {
  3. if(instance==null)
  4. {
  5. instance=new GlobalClass();
  6. }
  7. return instance;
  8. }
  9.  
  10. /**
  11. * @return This session's config data.
  12. */
  13. public Config getConfig() {
  14. Config config = new Gson().fromJson(mPreferences.getString(KEY_CONFIG, null), Config.class);
  15. return config;
  16. }
  17.  
  18. /**
  19. * Save this session's config data.
  20. *
  21. * @param config
  22. * Config data.
  23. */
  24. public void setConfig(Config config) {
  25. mPreferences.edit().putString(KEY_CONFIG, new Gson().toJson(config)).commit();
  26. }
  27.  
  28. /**
  29. * @return Application configuration parameters.
  30. */
  31. public static Config getConfig() {
  32. if (sConfig == null)
  33. sConfig = sPreferences.getConfig();
  34. return sConfig;
  35. }
  36.  
  37. /**
  38. * Set application configuration parameters.
  39. *
  40. * @param config
  41. * Config to set.
  42. */
  43. public static void setConfig(Config config) {
  44. sPreferences.setConfig(config);
  45. sConfig = config;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement