Commit cef38d5b authored by Geoffrey Métais's avatar Geoffrey Métais

Audio: synchronously compute headers

parent f5ac25e2
......@@ -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))
}
......
......@@ -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))
}
......
......@@ -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
......
......@@ -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)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment