[Android] Stop network discovery on root view removed
Geoffrey Métais
git at videolan.org
Thu Dec 6 16:52:44 CET 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec 6 16:45:28 2018 +0100| [d5d9acc9fcdea3181438f2dde7571801e7472fc3] | committer: Geoffrey Métais
Stop network discovery on root view removed
> https://code.videolan.org/videolan/vlc-android/commit/d5d9acc9fcdea3181438f2dde7571801e7472fc3
---
vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt | 7 +++++--
vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt | 7 ++++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
index 4fcb04a79..ab572d281 100644
--- a/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/BrowserProvider.kt
@@ -221,11 +221,14 @@ abstract class BrowserProvider(val context: Context, val dataset: LiveDataset<Me
initBrowser()
mediabrowser?.let {
if (url != null) it.browse(Uri.parse(url), getFlags())
- else it.discoverNetworkShares()
+ else {
+ it.changeEventListener(this at BrowserProvider)
+ it.discoverNetworkShares()
+ }
}
}
- fun stop() = job?.cancel()
+ open fun stop() = job?.cancel()
open fun release() {
browserActor.close()
diff --git a/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt b/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
index a6c0f1573..01a1cdf63 100644
--- a/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/NetworkProvider.kt
@@ -20,8 +20,8 @@
package org.videolan.vlc.providers
-import androidx.lifecycle.Observer
import android.content.Context
+import androidx.lifecycle.Observer
import kotlinx.coroutines.launch
import org.videolan.medialibrary.media.DummyItem
import org.videolan.medialibrary.media.MediaLibraryItem
@@ -60,6 +60,11 @@ class NetworkProvider(context: Context, dataset: LiveDataset<MediaLibraryItem>,
if (url != null) super.parseSubDirectories()
}
+ override fun stop(): Unit? {
+ if (url == null) mediabrowser?.changeEventListener(null)
+ return super.stop()
+ }
+
override fun release() {
favorites?.removeObserver(this)
super.release()
More information about the Android
mailing list