[Android] Audio player: improve the drag and drop effect of the playlist items

Adrien Maglo git at videolan.org
Thu Jan 23 22:09:33 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu Jan 23 22:09:22 2014 +0100| [84194c3c7d9e12c431b097e48ef8682e0019b1f9] | committer: Adrien Maglo

Audio player: improve the drag and drop effect of the playlist items

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

 vlc-android/res/layout/audio_playlist_item.xml     |    1 +
 .../videolan/vlc/gui/audio/AudioPlaylistView.java  |   34 +++++++++++---------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/vlc-android/res/layout/audio_playlist_item.xml b/vlc-android/res/layout/audio_playlist_item.xml
index f4b1d38..4dbce13 100644
--- a/vlc-android/res/layout/audio_playlist_item.xml
+++ b/vlc-android/res/layout/audio_playlist_item.xml
@@ -87,6 +87,7 @@
     </LinearLayout>
 
     <View
+        android:id="@+id/layout_footer"
         android:layout_width="match_parent"
         android:layout_height="1dp"
         android:layout_gravity="center"
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
index 0ea330d..b66e922 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -134,15 +134,6 @@ public class AudioPlaylistView extends ListView {
     public void startDrag(int positionDragStart, String title, String artist) {
         mPositionDragStart = positionDragStart;
         if (mDragShadow != null) {
-            for (int i = 0; i < getChildCount(); i++) {
-                View child = getChildAt(i);
-                AudioListAdapter.ViewHolder holder = (AudioListAdapter.ViewHolder)child.getTag();
-                if (holder.position == positionDragStart) {
-                    LinearLayout layout = (LinearLayout)child.findViewById(R.id.layout_item);
-                    layout.setBackgroundResource(R.color.darkorange);
-                }
-            }
-
             TextView titleView = (TextView)mDragShadow.findViewById(R.id.title);
             TextView artistView = (TextView)mDragShadow.findViewById(R.id.artist);
             LinearLayout layout = (LinearLayout)mDragShadow.findViewById(R.id.layout_item);
@@ -159,12 +150,21 @@ public class AudioPlaylistView extends ListView {
         for (int i = 0; i < getChildCount(); i++) {
             View child = getChildAt(i);
             LinearLayout expansion = (LinearLayout)child.findViewById(R.id.item_expansion);
+            LinearLayout layout_item = (LinearLayout)child.findViewById(R.id.layout_item);
+            View layout_footer = (View)child.findViewById(R.id.layout_footer);
+            AudioListAdapter.ViewHolder holder = (AudioListAdapter.ViewHolder)child.getTag();
 
-            child.getHitRect(rect);
-            if (rect.contains(getWidth() / 2, (int)mTouchY))
-                expansion.setVisibility(LinearLayout.VISIBLE);
-            else
-                expansion.setVisibility(LinearLayout.GONE);
+            if (holder.position == mPositionDragStart) {
+                layout_item.setVisibility(LinearLayout.GONE);
+                layout_footer.setVisibility(LinearLayout.GONE);
+            }
+            else {
+                child.getHitRect(rect);
+                if (rect.contains(getWidth() / 2, (int)mTouchY))
+                    expansion.setVisibility(LinearLayout.VISIBLE);
+                else
+                    expansion.setVisibility(LinearLayout.GONE);
+            }
         }
     }
 
@@ -176,7 +176,8 @@ public class AudioPlaylistView extends ListView {
         for (int i = 0; i < getChildCount(); i++) {
             View child = getChildAt(i);
             LinearLayout expansion = (LinearLayout)child.findViewById(R.id.item_expansion);
-            LinearLayout layout = (LinearLayout)child.findViewById(R.id.layout_item);
+            LinearLayout layout_item = (LinearLayout)child.findViewById(R.id.layout_item);
+            View layout_footer = (View)child.findViewById(R.id.layout_footer);
 
             child.getHitRect(rect);
             if (rect.contains(getWidth() / 2, (int)mTouchY)) {
@@ -186,7 +187,8 @@ public class AudioPlaylistView extends ListView {
                     mOnItemDraggedListener.OnItemDradded(mPositionDragStart, holder.position);
             }
             expansion.setVisibility(LinearLayout.GONE);
-            layout.setBackgroundResource(0);
+            layout_item.setVisibility(LinearLayout.VISIBLE);
+            layout_footer.setVisibility(LinearLayout.VISIBLE);
         }
     }
 



More information about the Android mailing list