[Android] Ensure we don't trigger UI updates too soon

Geoffrey Métais git at videolan.org
Thu Sep 28 10:53:33 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Sep 28 09:38:20 2017 +0200| [93d8e85bd78a4f4f641679c5cb46c62e8aff8b6d] | committer: Geoffrey Métais

Ensure we don't trigger UI updates too soon

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

 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java        | 5 ++---
 .../src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java       | 6 ++++--
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java   | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 139929b37..9acd2bebd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -400,9 +400,8 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements SwipeRefre
     }
 
     public void restoreList() {
-        if (mViewPager == null)
-            return;
-        getCurrentAdapter().restoreList();
+        if (mViewPager != null)
+            getCurrentAdapter().restoreList();
     }
 
     private void updateEmptyView(int position) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index bf5788ad3..3aaa8e1d4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -372,8 +372,10 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
      * Update views visibility and emptiness info
      */
     protected void updateEmptyView() {
+        if (mSwipeRefreshLayout == null)
+            return;
         if (mAdapter.isEmpty()) {
-            if (mSwipeRefreshLayout == null || mSwipeRefreshLayout.isRefreshing()) {
+            if (mSwipeRefreshLayout.isRefreshing()) {
                 mEmptyView.setText(R.string.loading);
                 mEmptyView.setVisibility(View.VISIBLE);
                 mRecyclerView.setVisibility(View.GONE);
@@ -788,7 +790,7 @@ public abstract class BaseBrowserFragment extends SortableFragment<BaseBrowserAd
     }
 
     public void restoreList() {
-        if (mAdapter != null)
+        if (mAdapter != null && mEmptyView != null)
             mAdapter.restoreList();
     }
     public void setSearchVisibility(boolean visible) {
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 2153f9c08..507a2da7f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -418,7 +418,7 @@ public class VideoGridFragment extends SortableFragment<VideoListAdapter> implem
 
     @Override
     public void restoreList() {
-        if (mAdapter != null)
+        if (mAdapter != null && mGridView != null)
             mAdapter.restoreList();
     }
 



More information about the Android mailing list