[Android] Dialog: Check showing() before dismiss

Geoffrey Métais git at videolan.org
Tue Feb 5 13:48:17 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb  5 13:29:32 2019 +0100| [5534bbcea211d077ba4e5d7983c1ef33afa31c70] | committer: Geoffrey Métais

Dialog: Check showing() before dismiss

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

 vlc-android/src/org/videolan/vlc/media/MediaUtils.kt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
index d4ae92cbc..ed847fa00 100644
--- a/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
+++ b/vlc-android/src/org/videolan/vlc/media/MediaUtils.kt
@@ -317,7 +317,7 @@ object MediaUtils : CoroutineScope {
                 }
                 handler.removeCallbacksAndMessages(null)
                 if (this::dialog.isInitialized) dialog.cancel()
-            } else if (this::dialog.isInitialized) dialog.dismiss()
+            } else if (this::dialog.isInitialized && dialog.isShowing) dialog.dismiss()
         }
     }
 
@@ -360,7 +360,7 @@ object MediaUtils : CoroutineScope {
         }
 
         private fun dismiss() {
-            if (this::dialog.isInitialized) dialog.dismiss()
+            if (this::dialog.isInitialized && dialog.isShowing) dialog.dismiss()
         }
     }
 
@@ -400,4 +400,6 @@ fun List<Folder>.getAll(type: Int = Folder.TYPE_FOLDER_VIDEO, sort: Int = Medial
 private sealed class Action
 private object Connect : Action()
 private object Disconnect : Action()
+ at ObsoleteCoroutinesApi
+ at ExperimentalCoroutinesApi
 private class Task(val service : PlaybackService, val task: suspend (service: PlaybackService) -> Unit): Action()



More information about the Android mailing list