[Android] Audio player: avoid flickering on item dragged

Adrien Maglo git at videolan.org
Fri Jan 24 08:39:47 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jan 24 08:39:17 2014 +0100| [490761ae5cd295be2e4b6862a607ca701b4e6a1e] | committer: Adrien Maglo

Audio player: avoid flickering on item dragged

Let the adapter reset the item layout state.

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

 .../src/org/videolan/vlc/gui/audio/AudioListAdapter.java |    8 ++++++++
 .../org/videolan/vlc/gui/audio/AudioPlaylistView.java    |   14 +-------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
index 1921596..c082f83 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
@@ -35,6 +35,7 @@ import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.ImageButton;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 public class AudioListAdapter extends ArrayAdapter<Media> {
@@ -85,6 +86,13 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
         } else
             holder = (ViewHolder) v.getTag();
 
+        LinearLayout expansion = (LinearLayout)v.findViewById(R.id.item_expansion);
+        LinearLayout layout_item = (LinearLayout)v.findViewById(R.id.layout_item);
+        View layout_footer = (View)v.findViewById(R.id.layout_footer);
+        expansion.setVisibility(LinearLayout.GONE);
+        layout_item.setVisibility(LinearLayout.VISIBLE);
+        layout_footer.setVisibility(LinearLayout.VISIBLE);
+
         Media media = getItem(position);
         final String title = media.getTitle();
         final String artist = media.getSubtitle();
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 b66e922..9d78aad 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -175,31 +175,19 @@ public class AudioPlaylistView extends ListView {
         Rect rect = new Rect();
         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);
-
             child.getHitRect(rect);
             if (rect.contains(getWidth() / 2, (int)mTouchY)) {
                 // Send back the performed change thanks to the listener.
                 AudioListAdapter.ViewHolder holder = (AudioListAdapter.ViewHolder)child.getTag();
                 if (mOnItemDraggedListener != null)
                     mOnItemDraggedListener.OnItemDradded(mPositionDragStart, holder.position);
+                break;
             }
-            expansion.setVisibility(LinearLayout.GONE);
-            layout_item.setVisibility(LinearLayout.VISIBLE);
-            layout_footer.setVisibility(LinearLayout.VISIBLE);
         }
     }
 
     public void dragAborted() {
         mIsDragging = false;
-
-        for (int i = 0; i < getChildCount(); i++) {
-            View child = getChildAt(i);
-            LinearLayout expansion = (LinearLayout)child.findViewById(R.id.item_expansion);
-            expansion.setVisibility(LinearLayout.GONE);
-        }
     }
 
     public interface OnItemDraggedListener {



More information about the Android mailing list