[Android] AudioService: use the new event

Edward Wang git at videolan.org
Thu Jan 23 23:01:00 CET 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Jan 23 16:59:23 2014 -0500| [8b3cb0c7237d43796e4e82c68e5c973d4258cb8f] | committer: Edward Wang

AudioService: use the new event

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=8b3cb0c7237d43796e4e82c68e5c973d4258cb8f
---

 vlc-android/src/org/videolan/vlc/AudioService.java |   39 +++++++++++---------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index d7a3f85..f5840df 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -510,6 +510,28 @@ public class AudioService extends Service {
                 if(service.mCurrentIndex >= index && !expanding)
                     service.mCurrentIndex--;
                 break;
+            case EventHandler.CustomMediaListItemMoved:
+                Log.i(TAG, "CustomMediaListItemMoved");
+                int positionStart = msg.getData().getInt("index_before");
+                int positionEnd = msg.getData().getInt("index_after");
+                if (service.mCurrentIndex == positionStart) {
+                    service.mCurrentIndex = positionEnd;
+                    if (positionEnd > positionStart)
+                        service.mCurrentIndex--;
+                } else if (positionStart > service.mCurrentIndex
+                        && positionEnd <= service.mCurrentIndex)
+                    service.mCurrentIndex++;
+                else if (positionStart < service.mCurrentIndex
+                        && positionEnd >= service.mCurrentIndex)
+                    service.mCurrentIndex--;
+
+                // If we are in random mode, we completely reset the stored previous track
+                // as their indices changed.
+                service.mPrevious.clear();
+
+                service.determinePrevAndNextIndices();
+                service.executeUpdate();
+                break;
             case EventHandler.CustomMediaListExpanding:
                 expanding = true;
                 break;
@@ -1176,23 +1198,6 @@ public class AudioService extends Service {
         @Override
         public void moveItem(int positionStart, int positionEnd) throws RemoteException {
             mLibVLC.getMediaList().move(positionStart, positionEnd);
-            if (mCurrentIndex == positionStart) {
-                mCurrentIndex = positionEnd;
-                if (positionEnd > positionStart)
-                    mCurrentIndex--;
-            }
-            else if (positionStart > mCurrentIndex && positionEnd <= mCurrentIndex)
-                mCurrentIndex++;
-            else if (positionStart < mCurrentIndex && positionEnd >= mCurrentIndex)
-                mCurrentIndex--;
-
-            // If we are in random mode, we completely reset the stored previous track
-            // as their indices changed.
-            // TODO: better handling of item move in random mode?
-            mPrevious.clear();
-
-            determinePrevAndNextIndices();
-            executeUpdate();
         }
 
         @Override



More information about the Android mailing list