diff options
author | lado <herrlado@gmail.com> | 2012-02-23 16:26:34 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2012-02-23 16:26:34 +0100 |
commit | 6f7db9f6a14c414fc91232984f6d33bf2d27e7ef (patch) | |
tree | dbd6afef13da56ababf8b90ea778e94c4cf790a7 | |
parent | 1f057f2186264fc1ef2f10e7df7219257c575756 (diff) | |
download | vdr-manager-6f7db9f6a14c414fc91232984f6d33bf2d27e7ef.tar.gz vdr-manager-6f7db9f6a14c414fc91232984f6d33bf2d27e7ef.tar.bz2 |
bug fix with settings and margin pre
3 files changed, 61 insertions, 49 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java index dcb3f59..88156cd 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java @@ -41,14 +41,17 @@ public class Preferences { sharedPrefs .edit() .putInt(context.getString(R.string.current_vdr_id_key), - current.getId()).commit(); + current != null ? current.getId() : -1 ).commit(); } - public Vdr getCurrentVdr() { return current; } + public int getCurrentVdrContext(Context context){ + return getInteger(context, R.string.current_vdr_id_key, -1); + } + /** user defined epg search times */ private String epgSearchTimes; /** @@ -77,11 +80,9 @@ public class Preferences { * Show TMDb button in epg details */ private boolean showTmdbButton = false; - - + private int maxRecentChannels = 10; - public int getMaxRecentChannels() { return maxRecentChannels; } @@ -215,10 +216,10 @@ public class Preferences { * @return SVDRO password */ public String getPassword() { - String pwd = getCurrentVdr().getPassword(); - if(pwd == null){ - return StringUtils.EMPTY_STRING; - } + String pwd = getCurrentVdr().getPassword(); + if (pwd == null) { + return StringUtils.EMPTY_STRING; + } return pwd; } @@ -228,7 +229,7 @@ public class Preferences { * @return true, if remote wakeup is enabled */ public boolean isWakeupEnabled() { - return getCurrentVdr().isWakeupEnabled(); + return getCurrentVdr().isWakeupEnabled(); } /** @@ -266,15 +267,15 @@ public class Preferences { public boolean isAliveCheckEnabled() { return getCurrentVdr().isAliveCheckEnabled(); } - - public boolean isEnableRecStream(){ + + public boolean isEnableRecStream() { return getCurrentVdr().isEnableRecStreaming(); } - public int getLivePort(){ + public int getLivePort() { return getCurrentVdr().getLivePort(); } - + /** * Gets the time between alive checks * @@ -471,8 +472,8 @@ public class Preferences { prefs.epgSearchTimes = getString(context, R.string.epg_search_times_key, ""); - prefs.use24hFormat = getBoolean(context, - R.string.gui_enable_24h_format_key, true); + prefs.use24hFormat = getBoolean(context, + R.string.gui_enable_24h_format_key, true); prefs.showChannelNumbers = getBoolean(context, R.string.gui_channels_show_channel_numbers_key, false); @@ -486,34 +487,34 @@ public class Preferences { prefs.showOmdbButton = getBoolean(context, R.string.qui_show_omdb_button_key, true); - prefs.showTmdbButton = getBoolean(context, R.string.qui_show_tmdb_button_key, true); + prefs.imdbUrl = getString(context, R.string.qui_imdb_url_key, + "akas.imdb.com"); + + prefs.maxRecentChannels = getInt(context, + R.string.gui_max_recent_channels_key, 10); - prefs.imdbUrl = getString(context, R.string.qui_imdb_url_key, "akas.imdb.com"); - - prefs.maxRecentChannels = getInt(context, R.string.gui_max_recent_channels_key, 10); - thePrefs = prefs; } public static void reset() { thePrefs = null; } - - - public static void reloadVDR(){ - if(current == null){ + + public static void reloadVDR() { + if (current == null) { return; } db.getVdrDAO().refresh(current); } - - public static void initVDR(final Context context){ - // if (current != null) { - // return; - // } + + public static boolean initVDR(final Context context) { + + if (current != null) { + return true; + } int id = getInteger(context, R.string.current_vdr_id_key, -1); @@ -522,28 +523,28 @@ public class Preferences { vdr = db.getVdrDAO().queryForId(id); } + setCurrentVdr(context, vdr); + if (vdr != null) { - setCurrentVdr(context, vdr); - return; + return true; } List<Vdr> list = db.getVdrDAO().queryForAll(); if (list != null && list.isEmpty() == false) { vdr = list.get(0); setCurrentVdr(context, vdr); - return; - } - if (initFromOldVersion(context) == false) { - Intent intent = new Intent(); - intent.setClass(context, VdrListActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra(Intents.EMPTY_CONFIG, Boolean.TRUE); - context.startActivity(intent); - Toast.makeText(context, R.string.no_vdr, Toast.LENGTH_SHORT).show(); + return true; } + return initFromOldVersion(context); + //Intent intent = new Intent(); + //intent.setClass(context, VdrListActivity.class); + //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + //intent.putExtra(Intents.EMPTY_CONFIG, Boolean.TRUE); + //context.startActivity(intent); + //Toast.makeText(context, R.string.no_vdr, Toast.LENGTH_SHORT).show(); } - + /** * Loads all preferences * @@ -573,7 +574,7 @@ public class Preferences { Vdr vdr = new Vdr(); String host = getString(context, R.string.vdr_host_key, null); - if(host == null){ + if (host == null) { return false; } vdr.setHost(host); @@ -670,7 +671,7 @@ public class Preferences { private static int getInt(final Context context, final int resId, final int defValue) { final String value = getString(context, resId, String.valueOf(defValue)); - if(TextUtils.isEmpty(value) || !TextUtils.isDigitsOnly(value)){ + if (TextUtils.isEmpty(value) || !TextUtils.isDigitsOnly(value)) { return 0; } return Integer.parseInt(value); @@ -716,7 +717,6 @@ public class Preferences { return sharedPrefs.getInt(context.getString(resId), defValue); } - public String getTimeFormat() { if (isUse24hFormat()) { return "HH:mm"; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java index 5f1828d..fa16e69 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java @@ -481,6 +481,18 @@ public class Vdr { return (T) map.get(key); } + private static Integer getInteger(Map<String, Object> map, String key, Integer def) { + if (map.containsKey(key) == false) { + return def; + } + + Object obj = get(map, key); + if (obj instanceof Integer) { + return (Integer) obj; + } + return Integer.valueOf(String.valueOf(obj)); + } + private static Integer getInteger(Map<String, Object> map, String key) { if (map.containsKey(key) == false) { return Integer.valueOf(0); @@ -568,8 +580,8 @@ public class Vdr { readTimeout = getInteger(map, "key_vdr_readtimeout"); timeout = getInteger(map, "key_vdr_timeout"); - timerPreMargin = getInteger(map, "timer_pre_start_buffer"); - timerPostMargin = getInteger(map, "timer_post_end_buffer"); + timerPreMargin = getInteger(map, "timer_pre_start_buffer", 5); + timerPostMargin = getInteger(map, "timer_post_end_buffer", 30); timerDefaultPriority = getInteger(map, "timer_default_priority"); timerDefaultLifetime = getInteger(map, "timer_default_lifetime"); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java index ff130b5..7619d77 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java @@ -169,7 +169,7 @@ public class VdrListActivity extends OrmLiteBaseListActivity<OrmDatabaseHelper> */ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - editVdr(Long.valueOf(id).intValue()); + editVdr(adapter.getItem(position).getId()); } /** @@ -246,7 +246,7 @@ public class VdrListActivity extends OrmLiteBaseListActivity<OrmDatabaseHelper> public void onClick(DialogInterface dialog, int which) { if (getHelper().getVdrDAO() - .deleteById((int) id) > 0) { + .deleteById(adapter.getItem(position).getId()) > 0) { if(Preferences.get().getCurrentVdrContext(VdrListActivity.this) == id){ Preferences.setCurrentVdr(VdrListActivity.this, null); } |