[Android] Subtitles: Filter available languages on selection

Geoffrey Métais git at videolan.org
Tue Apr 9 11:14:58 CEST 2019


vlc-android | branch: 3.1.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr  9 10:32:38 2019 +0200| [b91db299e24064ff6c365b51ecb21fef3ecc7b95] | committer: Geoffrey Métais

Subtitles: Filter available languages on selection

(cherry picked from commit dd3f1a32a746e69d66bb2fdc384f5f84dc212206)

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

 .../org/videolan/vlc/gui/dialogs/SubtitleDownloadFragment.kt   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloadFragment.kt b/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloadFragment.kt
index 1b773848f..1c1e98c2c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloadFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloadFragment.kt
@@ -4,18 +4,18 @@ import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
+import androidx.core.widget.NestedScrollView
+import androidx.fragment.app.Fragment
 import androidx.lifecycle.Observer
 import androidx.lifecycle.ViewModelProviders
+import androidx.recyclerview.widget.DividerItemDecoration
+import androidx.recyclerview.widget.LinearLayoutManager
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.SubtitleDownloadFragmentBinding
 import org.videolan.vlc.gui.OnItemSelectListener
 import org.videolan.vlc.gui.helpers.UiTools
 import org.videolan.vlc.util.AndroidDevices
 import org.videolan.vlc.viewmodels.SubtitlesModel
-import androidx.core.widget.NestedScrollView
-import androidx.fragment.app.Fragment
-import androidx.recyclerview.widget.DividerItemDecoration
-import androidx.recyclerview.widget.LinearLayoutManager
 
 class SubtitleDownloadFragment : Fragment() {
     private lateinit var viewModel: SubtitlesModel
@@ -59,7 +59,7 @@ class SubtitleDownloadFragment : Fragment() {
         binding.languageListSpinner.setOnItemsSelectListener(object: OnItemSelectListener {
             override fun onItemSelect(selectedItems: List<Int>) {
                 val selectedLanguages = if (selectedItems.size == allValuesOfLanguages.size) listOf<String>()
-                else selectedItems.map { allValuesOfLanguages[it] }
+                else selectedItems.filter { it in 0 until allValuesOfLanguages.size }.map { allValuesOfLanguages[it] }
                 viewModel.observableSearchLanguage.set(selectedLanguages)
             }
         })



More information about the Android mailing list