[Android] Use getMediaListSize PlaybackService method

Geoffrey Métais git at videolan.org
Thu Jan 14 11:17:49 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 14 11:17:06 2016 +0100| [005f7f291d94b8dac6da6acbd4325cc30102c4bc] | committer: Geoffrey Métais

Use getMediaListSize PlaybackService method

Instead of duplicating media list for counting

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java       |  4 ++++
 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java | 12 ++++++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index c3aae4f..c1457df 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1756,6 +1756,10 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         determinePrevAndNextIndices();
     }
 
+    public int getMediaListSize() {
+        return mMediaList.size();
+    }
+
     @MainThread
     public List<MediaWrapper> getMedias() {
         final ArrayList<MediaWrapper> ml = new ArrayList<MediaWrapper>();
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 4dd06d2..0bfefe7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -354,8 +354,7 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             break;
         }
 
-        final List<String> mediaLocations = mService.getMediaLocations();
-        mShuffle.setVisibility(mediaLocations != null && mediaLocations.size() > 2 ? View.VISIBLE : View.INVISIBLE);
+        mShuffle.setVisibility(mService.getMediaListSize() > 2 ? View.VISIBLE : View.INVISIBLE);
         mTimeline.setOnSeekBarChangeListener(mTimelineListner);
 
         if (playlistDiffer())
@@ -372,11 +371,12 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
     }
 
     private boolean playlistDiffer() {
-        List<MediaWrapper> serviceList = mService.getMedias();
-        List<MediaWrapper> adapterList = mPlaylistAdapter.getMedias();
-        if (serviceList.size() != adapterList.size())
+        int serviceListSize = mService.getMediaListSize();
+        if (serviceListSize != mPlaylistAdapter.getItemCount())
             return true;
-        for (int i = 0 ; i < serviceList.size() ; ++i)
+        List<MediaWrapper> adapterList = mPlaylistAdapter.getMedias();
+        List<MediaWrapper> serviceList = mService.getMedias();
+        for (int i = 0 ; i < serviceListSize ; ++i)
             if (serviceList.get(i) != adapterList.get(i))
                 return true;
         return false;



More information about the Android mailing list