[Android] Videos: Improve "loading" & "empty" display

Geoffrey Métais git at videolan.org
Mon Feb 25 15:47:56 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 25 15:47:18 2019 +0100| [ab826374835112d78bf800490cbc5a516b70f4b9] | committer: Geoffrey Métais

Videos: Improve "loading" & "empty" display

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 8 +++++---
 vlc-android/src/org/videolan/vlc/viewmodels/BaseModel.kt          | 2 ++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 8513f9fcf..51eb263d4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -242,9 +242,11 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
     }
 
     void updateEmptyView() {
-        mBinding.loadingFlipper.setVisibility(View.GONE);
-        mBinding.loadingTitle.setVisibility(View.GONE);
-        mBinding.setEmpty(mAdapter.isEmpty());
+        final boolean empty = viewModel.isEmpty();
+        final boolean working = mMediaLibrary.isWorking();
+        mBinding.loadingFlipper.setVisibility(empty && working ? View.VISIBLE : View.GONE);
+        mBinding.loadingTitle.setVisibility(empty && working ? View.VISIBLE : View.GONE);
+        mBinding.setEmpty(empty && !working);
     }
 
     public void setGroup(String prefix) {
diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/BaseModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/BaseModel.kt
index 987597692..477c177e4 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/BaseModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/BaseModel.kt
@@ -63,6 +63,8 @@ abstract class BaseModel<T : MediaLibraryItem>(context: Context) : SortableModel
         }
     }
 
+    fun isEmpty() = dataset.value.isNullOrEmpty()
+
     override fun refresh() : Boolean {
         if (!updateActor.isClosedForSend) updateActor.offer(Refresh)
         return true



More information about the Android mailing list