[Android] Cancel folders adapter scope on destroy
Geoffrey Métais
git at videolan.org
Wed Oct 30 16:46:42 CET 2019
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 30 15:51:57 2019 +0100| [ec2ce87150c41fcd11f65b63158fe3a281757f91] | committer: Geoffrey Métais
Cancel folders adapter scope on destroy
> https://code.videolan.org/videolan/vlc-android/commit/ec2ce87150c41fcd11f65b63158fe3a281757f91
---
vlc-android/src/org/videolan/vlc/gui/folders/FoldersAdapter.kt | 2 +-
vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersAdapter.kt
index 8596dba4a..f8af03250 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersAdapter.kt
@@ -19,7 +19,7 @@ import org.videolan.vlc.gui.helpers.SelectorViewHolder
import org.videolan.vlc.util.UPDATE_SELECTION
class FoldersAdapter(val actor: SendChannel<FolderAction>) : PagedListAdapter<AbstractFolder, FoldersAdapter.ViewHolder>(DIFF_CALLBACK), MultiSelectAdapter<AbstractFolder>, CoroutineScope {
- override val coroutineContext = Dispatchers.Main.immediate
+ override val coroutineContext = Dispatchers.Main.immediate + SupervisorJob()
private lateinit var inflater: LayoutInflater
val multiSelectHelper = MultiSelectHelper(this, UPDATE_SELECTION)
diff --git a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
index 2d52a65ff..72e361eec 100644
--- a/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/folders/FoldersFragment.kt
@@ -110,6 +110,10 @@ class FoldersFragment : MediaBrowserFragment<FoldersViewModel>(), CtxActionRecei
fabPlay?.setImageResource(R.drawable.ic_fab_play)
}
+ override fun onDestroy() {
+ adapter.cancel()
+ super.onDestroy()
+ }
override fun getTitle(): String = getString(R.string.video)
More information about the Android
mailing list