[Android] Fix loading states in lists when content is empty

Nicolas Pomepuy git at videolan.org
Tue Mar 31 10:29:46 CEST 2020


vlc-android | branch: 3.2.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Mar 31 08:58:25 2020 +0200| [abb7d8dcf66270900d23b691e969d34f9bd074a5] | committer: Nicolas Pomepuy

Fix loading states in lists when content is empty

> https://code.videolan.org/videolan/vlc-android/commit/abb7d8dcf66270900d23b691e969d34f9bd074a5
---

 vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt                | 1 +
 vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt    | 1 +
 vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt | 3 +--
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
index e7e9c1ecf..ecd4f0eb3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryFragment.kt
@@ -76,6 +76,7 @@ class HistoryFragment : MediaBrowserFragment<HistoryModel>(), IRefreshable, IHis
         })
         viewModel.loading.observe(this, Observer {
             (activity as? MainActivity)?.refreshing = it
+            updateEmptyView()
         })
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
index 15a738150..50d4c8a84 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.kt
@@ -134,6 +134,7 @@ abstract class BaseBrowserFragment : MediaBrowserFragment<BrowserModel>(), IRefr
         viewModel.getDescriptionUpdate().observe(this, Observer { pair -> if (pair != null) adapter.notifyItemChanged(pair.first, pair.second) })
         viewModel.loading.observe(this, Observer {
             (activity as? MainActivity)?.refreshing = it
+            updateEmptyView()
         })
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
index f001f66f6..d6fb4ec7c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.kt
@@ -33,7 +33,6 @@ import android.view.Menu
 import android.view.MenuInflater
 import android.view.View
 import androidx.fragment.app.Fragment
-import androidx.lifecycle.Observer
 import androidx.lifecycle.ViewModelProviders
 import androidx.localbroadcastmanager.content.LocalBroadcastManager
 import androidx.recyclerview.widget.RecyclerView
@@ -138,7 +137,7 @@ class NetworkBrowserFragment : BaseBrowserFragment() {
     override fun updateEmptyView() {
         if (ExternalMonitor.isConnected) {
             if (Util.isListEmpty(viewModel.dataset.value)) {
-                if (swipeRefreshLayout.isRefreshing) {
+                if (viewModel.loading.value == true) {
                     binding.empty.setText(R.string.loading)
                     binding.empty.visibility = View.VISIBLE
                     binding.networkList.visibility = View.GONE



More information about the Android mailing list