[Android] Show browse/scan dialog for new devices only

Geoffrey Métais git at videolan.org
Tue Feb 26 09:45:59 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 26 09:45:15 2019 +0100| [f9f375d03009f5db4d97cd08094851d3b735a1ee] | committer: Geoffrey Métais

Show browse/scan dialog for new devices only

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

 vlc-android/src/org/videolan/vlc/StoragesMonitor.kt | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/StoragesMonitor.kt b/vlc-android/src/org/videolan/vlc/StoragesMonitor.kt
index 71d62258b..728baee40 100644
--- a/vlc-android/src/org/videolan/vlc/StoragesMonitor.kt
+++ b/vlc-android/src/org/videolan/vlc/StoragesMonitor.kt
@@ -42,15 +42,17 @@ class StoragesMonitor : BroadcastReceiver() {
                 if (action.path.scanAllowed()) {
                     val knownDevices = action.ctx.getFromMl { devices }
                     val ml = Medialibrary.getInstance()
-                    val scan = !containsDevice(knownDevices, action.path) && ml.addDevice(action.uuid, action.path, true)
-                    val intent = Intent(action.ctx, DialogActivity::class.java).apply {
-                        setAction(DialogActivity.KEY_DEVICE)
-                        putExtra(DialogActivity.EXTRA_PATH, action.path)
-                        putExtra(DialogActivity.EXTRA_UUID, action.uuid)
-                        putExtra(DialogActivity.EXTRA_SCAN, scan)
-                        addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                    val isNew = !containsDevice(knownDevices, action.path) && ml.addDevice(action.uuid, action.path, true)
+                    if (isNew) {
+                        val intent = Intent(action.ctx, DialogActivity::class.java).apply {
+                            setAction(DialogActivity.KEY_DEVICE)
+                            putExtra(DialogActivity.EXTRA_PATH, action.path)
+                            putExtra(DialogActivity.EXTRA_UUID, action.uuid)
+                            putExtra(DialogActivity.EXTRA_SCAN, isNew)
+                            addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                        }
+                        action.ctx.startActivity(intent)
                     }
-                    action.ctx.startActivity(intent)
                 }
             }
             is Unmount -> {



More information about the Android mailing list