[Android] [PATCH 08/10] Make display async process mandatory to implement

Geoffrey Métais geoffrey.metais at gmail.com
Mon Apr 20 10:49:54 CEST 2015


- display() method is now abstract, every MediaBrowserFragment child has to implement it
- basic implementation of setReadyToDisplay(), wich should suit to most children
---
 vlc-android/src/org/videolan/vlc/gui/MediaBrowserFragment.java | 10 ++++++++--
 .../org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java   |  3 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MediaBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/MediaBrowserFragment.java
index 66190ff..518277d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MediaBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MediaBrowserFragment.java
@@ -32,8 +32,14 @@ public abstract class MediaBrowserFragment extends Fragment {
     protected SwipeRefreshLayout mSwipeRefreshLayout;
     protected volatile boolean mReadyToDisplay = true;
 
-    protected void setReadyToDisplay(boolean ready){}
-    protected void display(){}
+    public void setReadyToDisplay(boolean ready) {
+        if (ready && !mReadyToDisplay)
+            display();
+        else
+            mReadyToDisplay = ready;
+    }
+
+    protected abstract void display();
 
     protected abstract String getTitle();
     public abstract void clear();
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 9149e0e..c45f0f9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -170,6 +170,9 @@ public class AudioAlbumsSongsFragment extends MediaBrowserFragment implements Sw
     }
 
     @Override
+    protected void display() {}
+
+    @Override
     protected String getTitle() {
         return mTitle;
     }
-- 
2.1.0



More information about the Android mailing list