[Android] Fix handling of the aout preference as an integer
Martin Storsjö
git at videolan.org
Mon Oct 8 17:50:15 CEST 2012
vlc-ports/android | branch: master | Martin Storsjö <martin at martin.st> | Mon Oct 8 18:33:25 2012 +0300| [04813469e3e240dcaeaf0f5c215739e9d729adf1] | committer: Martin Storsjö
Fix handling of the aout preference as an integer
The ListPreference item always handles the chosen value as a string,
therefore conversion from a string to a integer is necessary each
time the preference is set or when loaded from the stored preferences.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=04813469e3e240dcaeaf0f5c215739e9d729adf1
---
vlc-android/src/org/videolan/vlc/LibVLC.java | 6 +++++-
vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/LibVLC.java b/vlc-android/src/org/videolan/vlc/LibVLC.java
index b29455f..873574e 100644
--- a/vlc-android/src/org/videolan/vlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/vlc/LibVLC.java
@@ -156,7 +156,11 @@ public class LibVLC {
public static synchronized void useIOMX(Context context) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
sUseIomx = pref.getBoolean("enable_iomx", false);
- sAout = pref.getInt("aout", AOUT_AUDIOTRACK_JAVA);
+ try {
+ sAout = Integer.parseInt(pref.getString("aout", String.valueOf(AOUT_AUDIOTRACK_JAVA)));
+ } catch (NumberFormatException nfe) {
+ sAout = AOUT_AUDIOTRACK_JAVA;
+ }
}
public static synchronized void setAout(Context context, Integer aoutPref,
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 28fbe01..8ad7cb2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -157,7 +157,7 @@ public class PreferencesActivity extends PreferenceActivity {
aoutPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
- LibVLC.setAout(PreferencesActivity.this, (Integer) newValue, true);
+ LibVLC.setAout(PreferencesActivity.this, Integer.valueOf((String) newValue), true);
return true;
}
});
More information about the Android
mailing list