[Android] Prevent search subtitle again on rotation

Habib Kazemi git at videolan.org
Thu Oct 18 17:11:45 CEST 2018


vlc-android | branch: master | Habib Kazemi <kazemihabib1996 at gmail.com> | Thu Oct 18 18:46:00 2018 +0330| [317feaa306a8771b24c8bd6586ce3f9dee142fc1] | committer: Geoffrey Métais

Prevent search subtitle again on rotation

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

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

 vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
index cbc9f69e3..f55686a1b 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt
@@ -25,6 +25,7 @@ class SubtitlesModel(private val context: Context, private val mediaPath: String
     val observableSearchEpisode = ObservableField<String>()
     val observableSearchSeason = ObservableField<String>()
     val observableSearchLanguage = ObservableField<String>()
+    private var previousSearchLanguage: String? = null
     val manualSearchEnabled = ObservableBoolean(false)
 
     val isApiLoading = ObservableBoolean(false)
@@ -44,8 +45,11 @@ class SubtitlesModel(private val context: Context, private val mediaPath: String
     init {
         observableSearchLanguage.addOnPropertyChangedCallback(object: Observable.OnPropertyChangedCallback() {
             override fun onPropertyChanged(sender: Observable?, propertyId: Int) {
-                saveLastUsedLanguage(observableSearchLanguage.get() ?: "")
-                search(!manualSearchEnabled.get())
+                if (observableSearchLanguage.get() != previousSearchLanguage) {
+                    previousSearchLanguage = observableSearchLanguage.get()
+                    saveLastUsedLanguage(observableSearchLanguage.get() ?: "")
+                    search(!manualSearchEnabled.get())
+                }
             }
         })
 



More information about the Android mailing list