[Android] Audio: synchronously compute headers
Geoffrey Métais
git at videolan.org
Mon Jul 15 17:55:39 CEST 2019
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 15 15:07:50 2019 +0200| [cef38d5bc24a831181ca7b654295fbacb174827a] | committer: Geoffrey Métais
Audio: synchronously compute headers
> https://code.videolan.org/videolan/vlc-android/commit/cef38d5bc24a831181ca7b654295fbacb174827a
---
.../src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt | 2 +-
.../src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt | 2 +-
vlc-android/src/org/videolan/vlc/providers/HeaderProvider.kt | 2 +-
.../org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt | 6 ++----
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
index 8ad3d942d..21555ae3c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/FileBrowserTvFragment.kt
@@ -74,7 +74,7 @@ class FileBrowserTvFragment : BaseBrowserTvFragment() {
headerList.layoutManager = GridLayoutManager(requireActivity(), nbColumns)
headerAdapter.sortType = (viewModel as BrowserModel).sort
val headerItems = ArrayList<String>()
- viewModel.provider.liveHeaders.value?.run {
+ viewModel.provider.headers.run {
for (i in 0 until size()) {
headerItems.add(valueAt(i))
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
index 9a32d600c..f1d91ebcc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/MediaBrowserTvFragment.kt
@@ -78,7 +78,7 @@ class MediaBrowserTvFragment : BaseBrowserTvFragment() {
headerList.layoutManager = GridLayoutManager(requireActivity(), nbColumns)
headerAdapter.sortType = (viewModel as MediaBrowserViewModel).sort
val headerItems = ArrayList<String>()
- viewModel.provider.liveHeaders.value?.run {
+ viewModel.provider.headers.run {
for (i in 0 until size()) {
headerItems.add(valueAt(i))
}
diff --git a/vlc-android/src/org/videolan/vlc/providers/HeaderProvider.kt b/vlc-android/src/org/videolan/vlc/providers/HeaderProvider.kt
index 3534016ee..14ea7adb3 100644
--- a/vlc-android/src/org/videolan/vlc/providers/HeaderProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/HeaderProvider.kt
@@ -9,7 +9,7 @@ typealias HeadersIndex = SparseArrayCompat<String>
open class HeaderProvider {
val headers = HeadersIndex()
- val liveHeaders: LiveData<HeadersIndex> = MutableLiveData<HeadersIndex>()
+ val liveHeaders: LiveData<HeadersIndex> = MutableLiveData()
@MainThread
diff --git a/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt b/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
index 4e101fcfc..4cf7f1d8e 100644
--- a/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
+++ b/vlc-android/src/org/videolan/vlc/providers/medialibrary/MedialibraryProvider.kt
@@ -99,10 +99,8 @@ abstract class MedialibraryProvider<T : MediaLibraryItem>(val context: Context,
else -> null
}
ModelsHelper.getHeader(context, sort, item, previous)?.let {
- scope.launch {
- headers.put(startposition + position, it)
- (liveHeaders as MutableLiveData<HeadersIndex>).value = headers
- }
+ headers.put(startposition + position, it)
+ (liveHeaders as MutableLiveData<HeadersIndex>).postValue(headers)
}
}
}
More information about the Android
mailing list