[Android] OpenSubtitles: prevent re-sending invalid credentials

Nicolas Pomepuy git at videolan.org
Thu Nov 21 13:19:11 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Nov  6 08:55:03 2024 +0100| [ba2d7152224baf977b6b8142e4143e8f12eeb9b9] | committer: Duncan McNamara

OpenSubtitles: prevent re-sending invalid credentials

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

 .../videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
index 3b0ef9de5f..02bb8b1526 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SubtitleDownloaderDialogFragment.kt
@@ -57,6 +57,8 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
     private lateinit var names: String
     private lateinit var viewModel: SubtitlesModel
     private lateinit var toast: Toast
+    private var lastUsername: String = ""
+    private var lastPassword: String = ""
 
     private var state: SubDownloadDialogState = SubDownloadDialogState.Download
         set(value) {
@@ -142,7 +144,12 @@ class SubtitleDownloaderDialogFragment : VLCBottomSheetDialogFragment() {
         binding.loginButton.setOnClickListener {
             if (viewModel.observableUser.get()?.logged == true) {
                 viewModel.logout(settings)
-            }else {
+            } else {
+                if (lastPassword == binding.password.text.toString() && lastUsername == binding.username.text.toString()) {
+                    return at setOnClickListener
+                }
+                lastPassword = binding.password.text.toString()
+                lastUsername = binding.username.text.toString()
                 viewModel.login(
                     settings,
                     binding.username.text.toString(),



More information about the Android mailing list