[Android] Set language to English if ISO3 code is not found

Geoffrey Métais git at videolan.org
Mon Apr 10 15:43:36 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 10 10:19:02 2017 +0200| [30b4bdff3cecbdd31ea66a844c6f33d6d6a1968a] | committer: Geoffrey Métais

Set language to English if ISO3 code is not found

> https://code.videolan.org/videolan/vlc-android/commit/30b4bdff3cecbdd31ea66a844c6f33d6d6a1968a
---

 vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
index b88d5c8..3337615 100644
--- a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
+++ b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
@@ -62,6 +62,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map.Entry;
+import java.util.MissingResourceException;
 import java.util.Set;
 import java.util.zip.GZIPInputStream;
 
@@ -101,7 +102,12 @@ public class SubtitlesDownloader {
     public void downloadSubs(final List<MediaWrapper> mediaList, Callback cb) {
         stop = false;
         mCallback = cb;
-        Set<String> languages =  Collections.singleton(Locale.getDefault().getISO3Language().toLowerCase());
+        Set<String> languages;
+        try {
+            languages =  Collections.singleton(Locale.getDefault().getISO3Language().toLowerCase());
+        } catch (MissingResourceException e) {
+            languages = Collections.singleton(Locale.ENGLISH.getISO3Language().toLowerCase());
+        }
         if (AndroidUtil.isHoneycombOrLater) {
             SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
             languages =  pref.getStringSet("languages_download_list", languages);



More information about the Android mailing list