[Android] Faster update for video playlist

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


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 14 16:14:22 2016 +0100| [7194cc2ee699f6dc7dad1aaf188ac36fa2b5f23f] | committer: Geoffrey Métais

Faster update for video playlist

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

 .../videolan/vlc/gui/video/VideoPlayerActivity.java    | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 3598e32..d95f7b8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2082,32 +2082,20 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
 
     @Override
     public void updateList() {
-        int currentIndex = -1, oldCount = mPlaylistAdapter.getItemCount();
+        int oldCount = mPlaylistAdapter.getItemCount();
         if (mService == null)
             return;
 
-        final List<MediaWrapper> previousAudioList = mPlaylistAdapter.getMedias();
         mPlaylistAdapter.clear();
 
-        final List<MediaWrapper> playlist = mService.getMedias();
-        final String currentItem = mService.getCurrentMediaLocation();
-
-        if (playlist != null) {
-            for (int i = 0; i < playlist.size(); i++) {
-                final MediaWrapper media = playlist.get(i);
-                if (currentItem != null && currentItem.equals(media.getLocation()))
-                    currentIndex = i;
-                mPlaylistAdapter.add(media);
-            }
-        }
-        mPlaylistAdapter.setCurrentIndex(currentIndex);
+        mPlaylistAdapter.addAll(mService.getMedias());
         int count = mPlaylistAdapter.getItemCount();
         if (oldCount != count)
             mPlaylistAdapter.notifyDataSetChanged();
         else
             mPlaylistAdapter.notifyItemRangeChanged(0, count);
 
-        final int selectionIndex = currentIndex;
+        final int selectionIndex = mService.getCurrentMediaPosition();
         mPlaylist.post(new Runnable() {
             @Override
             public void run() {



More information about the Android mailing list