[Android] Fix playlist started on wrong position

Geoffrey Métais git at videolan.org
Tue Mar 1 19:12:07 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar  1 19:10:49 2016 +0100| [3e8fd3054d7e8d5f2e8fa25204762bb2f48e80ab] | committer: Geoffrey Métais

Fix playlist started on wrong position

We have to handle the mediagroups size

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

 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java      | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 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 5a6844e..9d26c8a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -279,14 +279,20 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
                 return true;
             case R.id.video_list_play_all:
                 ArrayList<MediaWrapper> playList = new ArrayList<>();
-                for (MediaWrapper mw : mVideoAdapter.getAll()) {
+                ArrayList<MediaWrapper> videos = mVideoAdapter.getAll();
+                MediaWrapper mw;
+                int offset = 0;
+                for (int i = 0; i < videos.size(); ++i) {
+                    mw = videos.get(i);
                     if (mw instanceof MediaGroup) {
                         for (MediaWrapper item : ((MediaGroup) mw).getAll())
                             playList.add(item);
+                        if (i < position)
+                            offset += ((MediaGroup)mw).size()-1;
                     } else
                         playList.add(mw);
                 }
-                MediaUtils.openList(getActivity(), playList, position);
+                MediaUtils.openList(getActivity(), playList, position+offset);
                 return true;
             case R.id.video_list_info:
                 Activity activity = getActivity();



More information about the Android mailing list