summaryrefslogtreecommitdiff
path: root/vdrmanager
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2012-02-02 15:05:47 +0100
committerlado <herrlado@gmail.com>2012-02-02 15:05:47 +0100
commit8668262e5e5840984871ea33243a8456f0f4ebbd (patch)
treed2ec28f9a3073ec0fc788853e06c874cd4c7408a /vdrmanager
parent125343257f531941886f5ce9523c5ec5b422b6fa (diff)
downloadvdr-manager-8668262e5e5840984871ea33243a8456f0f4ebbd.tar.gz
vdr-manager-8668262e5e5840984871ea33243a8456f0f4ebbd.tar.bz2
current vdr handling changed
Diffstat (limited to 'vdrmanager')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java1
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java63
2 files changed, 36 insertions, 28 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
index d2b5e3f..b1f75df 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/app/VdrManagerApp.java
@@ -56,6 +56,7 @@ public class VdrManagerApp extends Application {
public void onCreate() {
super.onCreate();
Preferences.init(this);
+ Preferences.initVDR(this);
}
public void clear() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
index 3a788b6..f734855 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java
@@ -36,8 +36,8 @@ public class Preferences {
}
public static void setCurrentVdr(Context context, Vdr vdr) {
- final SharedPreferences sharedPrefs = getSharedPreferences(context);
current = vdr;
+ final SharedPreferences sharedPrefs = getSharedPreferences(context);
sharedPrefs
.edit()
.putInt(context.getString(R.string.current_vdr_id_key),
@@ -502,37 +502,13 @@ public class Preferences {
thePrefs = null;
}
-
- /**
- * Loads all preferences
- *
- * @param context
- * Context
- * @return Preferences
- */
- public static void init(final Context context) {
- // if (thePrefs != null) {
- // return;
- // }
- if (db == null) {
- db = new OrmDatabaseHelper(context);
- }
-
- synchronized (Preferences.class) {
- // if (thePrefs != null) {
- // return;
- // }
- initInternal(context);
- setLocale(context);
- }
-
+
+ public static void initVDR(final Context context){
// if (current != null) {
// return;
// }
- final SharedPreferences sharedPrefs = getSharedPreferences(context);
- int id = sharedPrefs.getInt(
- context.getString(R.string.current_vdr_id_key), -1);
+ int id = getInteger(context, R.string.current_vdr_id_key, -1);
Vdr vdr = null;
if (id != -1) {
@@ -558,7 +534,31 @@ public class Preferences {
context.startActivity(intent);
Toast.makeText(context, R.string.no_vdr, Toast.LENGTH_SHORT).show();
}
+
+ }
+
+ /**
+ * Loads all preferences
+ *
+ * @param context
+ * Context
+ * @return Preferences
+ */
+ public static void init(final Context context) {
+ // if (thePrefs != null) {
+ // return;
+ // }
+ if (db == null) {
+ db = new OrmDatabaseHelper(context);
+ }
+ synchronized (Preferences.class) {
+ // if (thePrefs != null) {
+ // return;
+ // }
+ initInternal(context);
+ setLocale(context);
+ }
}
private static boolean initFromOldVersion(Context context) {
@@ -703,6 +703,13 @@ public class Preferences {
return sharedPrefs.getString(context.getString(resId), defValue);
}
+ private static int getInteger(final Context context, final int resId,
+ final int defValue) {
+ final SharedPreferences sharedPrefs = getSharedPreferences(context);
+ return sharedPrefs.getInt(context.getString(resId), defValue);
+ }
+
+
public String getTimeFormat() {
if (isUse24hFormat()) {
return "HH:mm";