Commit eeb3ebc3 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais

Fix loading states for Video, playlist and Artist tab

Fixes #1328
parent 8044126f
Pipeline #17062 passed with stage
in 3 minutes and 40 seconds
......@@ -103,11 +103,10 @@ class PlaylistFragment : BaseAudioBrowser<PlaylistsViewModel>(), SwipeRefreshLay
super.onActivityCreated(savedInstanceState)
viewModel.provider.pagedList.observe(requireActivity(), Observer {
playlistAdapter.submitList(it as PagedList<MediaLibraryItem>)
binding.empty.visibility = if (it.isEmpty())View.VISIBLE else View.GONE
})
viewModel.provider.loading.observe(requireActivity(), Observer<Boolean> { loading ->
setRefreshing(loading) { refresh ->
if (!refresh) binding.empty.visibility = if (empty) View.VISIBLE else View.GONE
}
viewModel.provider.loading.observe(requireActivity(), Observer { loading ->
setRefreshing(loading) { }
})
fastScroller.setRecyclerView(getCurrentRV(), viewModel.provider)
......
......@@ -133,6 +133,7 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
viewModel.albumsProvider.pagedList.observe(requireActivity(), Observer { albums ->
@Suppress("UNCHECKED_CAST")
(albums as? PagedList<MediaLibraryItem>)?.let { albumsAdapter.submitList(it) }
if (viewModel.albumsProvider.loading.value == false && empty && !viewModel.isFiltering()) currentTab = 1
})
viewModel.tracksProvider.pagedList.observe(requireActivity(), Observer { tracks ->
@Suppress("UNCHECKED_CAST")
......@@ -141,7 +142,6 @@ class AudioAlbumsSongsFragment : BaseAudioBrowser<AlbumSongsViewModel>(), SwipeR
for (i in 0..1) setupLayoutManager(viewModel.providersInCard[i], lists[i], viewModel.providers[i] as MedialibraryProvider<MediaLibraryItem>, adapters[i], spacing)
viewModel.albumsProvider.loading.observe(requireActivity(), Observer { loading ->
if (!loading) {
if (empty && !viewModel.isFiltering()) currentTab = 1
fastScroller.setRecyclerView(getCurrentRV(), viewModel.providers[currentTab])
}
setRefreshing(loading)
......
......@@ -295,7 +295,7 @@ class VideoGridFragment : MediaBrowserFragment<VideosViewModel>(), SwipeRefreshL
private fun updateEmptyView() {
if (!::binding.isInitialized) return
val empty = viewModel.isEmpty() && videoListAdapter.currentList.isNullOrEmpty()
val working = mediaLibrary.isWorking
val working = viewModel.provider.loading.value != false
binding.emptyLoading.state = when {
empty && working -> EmptyLoadingState.LOADING
empty && !working -> EmptyLoadingState.EMPTY
......
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