[Android] Fix loading state in file browser
Nicolas Pomepuy
git at videolan.org
Fri Apr 24 11:07:53 CEST 2020
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Apr 22 12:53:03 2020 +0200| [a4fff6d3b125482f7bbf73980c74eab097aeeccf] | committer: Geoffrey Métais
Fix loading state in file browser
Fixes #1282
> https://code.videolan.org/videolan/vlc-android/commit/a4fff6d3b125482f7bbf73980c74eab097aeeccf
---
.../videolan/vlc/gui/browser/BaseBrowserFragment.kt | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 7fa7b982d..bc61c0c3d 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -50,7 +50,6 @@ import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.databinding.DirectoryBrowserBinding
import org.videolan.vlc.gui.AudioPlayerContainerActivity
-import org.videolan.vlc.gui.MainActivity
import org.videolan.vlc.gui.dialogs.CtxActionReceiver
import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
import org.videolan.vlc.gui.dialogs.showContext
@@ -156,8 +155,9 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
if (::addPlaylistFolderOnly.isInitialized) addPlaylistFolderOnly.isVisible = adapter.mediaCount > 0
})
viewModel.getDescriptionUpdate().observe(viewLifecycleOwner, Observer { pair -> if (pair != null) adapter.notifyItemChanged(pair.first, pair.second) })
- viewModel.loading.observe(viewLifecycleOwner, Observer {
- (activity as? MainActivity)?.refreshing = it
+ viewModel.loading.observe(viewLifecycleOwner, Observer { loading ->
+ swipeRefreshLayout.isRefreshing = loading
+ updateEmptyView()
})
}
@@ -285,17 +285,19 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
*/
protected open fun updateEmptyView() {
swipeRefreshLayout.let {
- if (viewModel.isEmpty()) {
- if (it.isRefreshing) {
+ when {
+ it.isRefreshing -> {
binding.emptyLoading.state = EmptyLoadingState.LOADING
binding.networkList.visibility = View.GONE
- } else {
+ }
+ viewModel.isEmpty() -> {
binding.emptyLoading.state = EmptyLoadingState.EMPTY
binding.networkList.visibility = View.GONE
}
- } else {
- binding.emptyLoading.state = EmptyLoadingState.NONE
- binding.networkList.visibility = View.VISIBLE
+ else -> {
+ binding.emptyLoading.state = EmptyLoadingState.NONE
+ binding.networkList.visibility = View.VISIBLE
+ }
}
}
}
More information about the Android
mailing list