[Android] TV: Update browsers on storages (un)plugged

Geoffrey Métais git at videolan.org
Tue Dec 11 14:20:19 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec 11 13:57:47 2018 +0100| [3fb19f0997bc11909f8519d13b474941996a59aa] | committer: Geoffrey Métais

TV: Update browsers on storages (un)plugged

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

 vlc-android/src/org/videolan/vlc/ExternalMonitor.kt       | 6 +++++-
 vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
index af9c1bee0..d213c7a7c 100644
--- a/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
+++ b/vlc-android/src/org/videolan/vlc/ExternalMonitor.kt
@@ -123,7 +123,10 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
             }
             Intent.ACTION_MEDIA_MOUNTED -> {
                 if (AndroidDevices.watchDevices || storageObserver != null && storageObserver!!.get() != null) {
-                    intent.data?.let { actor.offer(MediaMounted(it)) }
+                    intent.data?.let {
+                        actor.offer(MediaMounted(it))
+                        storagePlugged.postValue(it)
+                    }
                 }
             }
             Intent.ACTION_MEDIA_UNMOUNTED,
@@ -172,6 +175,7 @@ object ExternalMonitor : BroadcastReceiver(), LifecycleObserver, CoroutineScope
 
     val connected = MutableLiveData<Boolean>()
     val storageUnplugged = LiveEvent<Uri>()
+    val storagePlugged = LiveEvent<Uri>()
     @Volatile
     var isMobile = true
         private set
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
index a01a197bf..c24788d5d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvFragment.kt
@@ -160,6 +160,8 @@ class MainTvFragment : BrowseSupportFragment(), OnItemViewSelectedListener, OnIt
             (requireActivity() as MainTvActivity).hideLoading()
         })
         ExternalMonitor.connected.observe(this, Observer { updateActor.offer(Browsers) })
+        ExternalMonitor.storageUnplugged.observe(this, Observer { updateActor.offer(Browsers) })
+        ExternalMonitor.storagePlugged.observe(this, Observer { updateActor.offer(Browsers) })
         onItemViewClickedListener = this
         onItemViewSelectedListener = this
     }



More information about the Android mailing list