Commit e43b7e3a authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix loading states for Audio and Browse tabs

parent eeb3ebc3
Pipeline #17072 failed with stage
in 2 minutes and 19 seconds
...@@ -277,7 +277,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() { ...@@ -277,7 +277,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
override fun enableSearchOption() = true override fun enableSearchOption() = true
private fun updateEmptyView() { private fun updateEmptyView() {
empty_loading.state = if (empty) EmptyLoadingState.EMPTY else EmptyLoadingState.NONE empty_loading.state = if (viewModel.providers[currentTab].loading.value == true) EmptyLoadingState.LOADING else if (empty) EmptyLoadingState.EMPTY else EmptyLoadingState.NONE
setFabPlayShuffleAllVisibility() setFabPlayShuffleAllVisibility()
} }
......
...@@ -134,7 +134,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei ...@@ -134,7 +134,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
localViewModel.dataset.observe(viewLifecycleOwner, Observer<List<MediaLibraryItem>> { list -> localViewModel.dataset.observe(viewLifecycleOwner, Observer<List<MediaLibraryItem>> { list ->
list?.let { list?.let {
storageBrowserAdapter.update(it) storageBrowserAdapter.update(it)
localEntry.loading.state = if (list.isEmpty()) EmptyLoadingState.EMPTY else EmptyLoadingState.NONE localEntry.loading.state = if (list.isNotEmpty()) EmptyLoadingState.NONE else if (localViewModel.loading.value == true) EmptyLoadingState.LOADING else EmptyLoadingState.EMPTY
} }
}) })
localViewModel.loading.observe(viewLifecycleOwner, Observer { localViewModel.loading.observe(viewLifecycleOwner, Observer {
...@@ -154,12 +154,15 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei ...@@ -154,12 +154,15 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
favoritesViewModel = BrowserFavoritesModel(requireContext()) favoritesViewModel = BrowserFavoritesModel(requireContext())
containerAdapterAssociation[favoritesBrowserContainer] = Pair(favoritesAdapter, favoritesViewModel) containerAdapterAssociation[favoritesBrowserContainer] = Pair(favoritesAdapter, favoritesViewModel)
favoritesViewModel.favorites.observe(viewLifecycleOwner, Observer { list -> favoritesViewModel.favorites.observe(viewLifecycleOwner, Observer { list ->
list?.let { list.let {
if (list.isEmpty()) favoritesEntry.setGone() else favoritesEntry.setVisible() if (list.isEmpty()) favoritesEntry.setGone() else favoritesEntry.setVisible()
favoritesAdapter.update(it) favoritesAdapter.update(it)
favoritesEntry.loading.state = if (list.isEmpty()) EmptyLoadingState.EMPTY else EmptyLoadingState.NONE favoritesEntry.loading.state = if (list.isNotEmpty()) EmptyLoadingState.NONE else if (localViewModel.loading.value == true) EmptyLoadingState.LOADING else EmptyLoadingState.EMPTY
} }
}) })
favoritesViewModel.provider.loading.observe(viewLifecycleOwner, Observer {
if (it) localEntry.loading.state = EmptyLoadingState.LOADING
})
favoritesViewModel.provider.descriptionUpdate.observe(viewLifecycleOwner, Observer { pair -> favoritesViewModel.provider.descriptionUpdate.observe(viewLifecycleOwner, Observer { pair ->
if (pair != null) favoritesAdapter.notifyItemChanged(pair.first, pair.second) if (pair != null) favoritesAdapter.notifyItemChanged(pair.first, pair.second)
}) })
...@@ -230,7 +233,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei ...@@ -230,7 +233,7 @@ class MainBrowserFragment : BaseFragment(), View.OnClickListener, CtxActionRecei
return return
} }
val dialog = NetworkServerDialog() val dialog = NetworkServerDialog()
mw?.let { dialog.setServer(it) } mw.let { dialog.setServer(it) }
dialog.show(fm, "fragment_add_server") dialog.show(fm, "fragment_add_server")
} }
......
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