[Android] Adapters: abort binding when job is cancelled
Geoffrey Métais
git at videolan.org
Wed Oct 30 11:27:27 CET 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Oct 30 11:26:49 2019 +0100| [4b8ff286fda296413522e5c8e1a4be05d955dd7b] | committer: Geoffrey Métais
Adapters: abort binding when job is cancelled
> https://code.videolan.org/videolan/vlc-android/commit/4b8ff286fda296413522e5c8e1a4be05d955dd7b
---
vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
index 01b728181..e39e85eb8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.kt
@@ -58,6 +58,7 @@ internal class StorageBrowserAdapter(fragment: StorageBrowserFragment) : BaseBro
if (!storagePath.endsWith("/")) storagePath += "/"
vh.binding.item = storage
updateJob?.join()
+ if (updateJob?.isCancelled == true) return at launch
val hasContextMenu = customDirsLocation.contains(storagePath)
val checked = (fragment as StorageBrowserFragment).scannedDirectory || mediaDirsLocation.containsPath(storagePath)
vh.binding.hasContextMenu = hasContextMenu
@@ -87,7 +88,7 @@ internal class StorageBrowserAdapter(fragment: StorageBrowserFragment) : BaseBro
suspend fun updateListState(context: Context) {
updateMediaDirs(context)
updateJob?.join()
- notifyItemRangeChanged(0, itemCount)
+ if (updateJob?.isCancelled == false) notifyItemRangeChanged(0, itemCount)
}
fun updateMediaDirs(context: Context) {
More information about the Android
mailing list