[Android] Fix NumberFormatException

Nicolas Pomepuy git at videolan.org
Tue Oct 1 14:33:37 CEST 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Thu Sep 26 07:16:33 2019 +0200| [c0b78834b77325776233150e07bce6b780bb9c2e] | committer: Geoffrey Métais

Fix NumberFormatException

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

 vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
index cad6fbe50..c64958f8a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesUi.kt
@@ -129,7 +129,12 @@ class PreferencesUi : BasePreferenceFragment(), SharedPreferences.OnSharedPrefer
                 (activity as PreferencesActivity).setRestart()
             }
             "video_group_size" -> {
-                AbstractMedialibrary.getInstance().setVideoGroupsPrefixLength(Settings.getInstance(requireActivity()).getString(key, "6").toInt())
+                val goupSizeValue = try {
+                    Settings.getInstance(requireActivity()).getString(key, "6").toInt()
+                } catch (e: NumberFormatException) {
+                    6
+                }
+                AbstractMedialibrary.getInstance().setVideoGroupsPrefixLength(goupSizeValue)
                 (activity as PreferencesActivity).setRestart()
             }
         }



More information about the Android mailing list