[Android] Fix playlist button showed when no playlist

Geoffrey Métais git at videolan.org
Thu Jan 28 16:30:13 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 28 16:27:10 2016 +0100| [d0184c82db8b55f3e809fa3ba4badad0bd0040d2] | committer: Geoffrey Métais

Fix playlist button showed when no playlist

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

 .../vlc/gui/video/VideoPlayerActivity.java         | 29 +++++++++++-----------
 1 file changed, 15 insertions(+), 14 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 e0eaf43..aa0b02d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -742,6 +742,21 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 mService.addSubtitleTrack(file);
             }
         }
+
+        if (mService.getMediaListSize() > 1) {
+            mPlaylistAdapter = new PlaylistAdapter(this);
+            mPlaylistAdapter.setService(mService);
+            final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
+            layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
+            mPlaylist.setLayoutManager(layoutManager);
+            mPlaylistToggle.setVisibility(View.VISIBLE);
+            mPlaylistToggle.setOnClickListener(VideoPlayerActivity.this);
+            mSeekbar.setNextFocusUpId(mPlaylistToggle.getId());
+
+            ItemTouchHelper.Callback callback =  new SwipeDragItemTouchHelperCallback(mPlaylistAdapter);
+            ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
+            touchHelper.attachToRecyclerView(mPlaylist);
+        }
     }
 
     private void initUI() {
@@ -3142,20 +3157,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     @Override
     public void onConnected(PlaybackService service) {
         mService = service;
-        if (mService.hasNext() || mService.hasPrevious()) {
-            mPlaylistAdapter = new PlaylistAdapter(this);
-            mPlaylistAdapter.setService(service);
-            final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
-            layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
-            mPlaylist.setLayoutManager(layoutManager);
-            mPlaylistToggle.setVisibility(View.VISIBLE);
-            mPlaylistToggle.setOnClickListener(VideoPlayerActivity.this);
-            mSeekbar.setNextFocusUpId(mPlaylistToggle.getId());
-
-            ItemTouchHelper.Callback callback =  new SwipeDragItemTouchHelperCallback(mPlaylistAdapter);
-            ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
-            touchHelper.attachToRecyclerView(mPlaylist);
-        }
         mHandler.sendEmptyMessage(START_PLAYBACK);
     }
 



More information about the Android mailing list