[Android] Audio player: use the references stored in the holder to modify playlist item views

Adrien Maglo git at videolan.org
Mon Jan 27 12:25:38 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Jan 27 12:25:28 2014 +0100| [13758d6785f7f5f9f5b0f0ab8b773bce062313ca] | committer: Adrien Maglo

Audio player: use the references stored in the holder to modify playlist item views

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

 .../videolan/vlc/gui/audio/AudioPlaylistView.java  |   21 ++++++++------------
 1 file changed, 8 insertions(+), 13 deletions(-)

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 c4d4c3d..e730647 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -149,21 +149,18 @@ 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);
             AudioListAdapter.ViewHolder holder = (AudioListAdapter.ViewHolder)child.getTag();
 
             if (holder.position == mPositionDragStart) {
-                layout_item.setVisibility(LinearLayout.GONE);
-                layout_footer.setVisibility(LinearLayout.GONE);
+                holder.layoutItem.setVisibility(LinearLayout.GONE);
+                holder.layoutFooter.setVisibility(LinearLayout.GONE);
             }
             else {
                 child.getHitRect(rect);
                 if (rect.contains(getWidth() / 2, (int)mTouchY))
-                    expansion.setVisibility(LinearLayout.VISIBLE);
+                    holder.expansion.setVisibility(LinearLayout.VISIBLE);
                 else
-                    expansion.setVisibility(LinearLayout.GONE);
+                    holder.expansion.setVisibility(LinearLayout.GONE);
             }
         }
     }
@@ -195,12 +192,10 @@ 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);
-            layout_item.setVisibility(LinearLayout.VISIBLE);
-            layout_footer.setVisibility(LinearLayout.VISIBLE);
-            expansion.setVisibility(LinearLayout.GONE);
+            AudioListAdapter.ViewHolder holder = (AudioListAdapter.ViewHolder)child.getTag();
+            holder.layoutItem.setVisibility(LinearLayout.VISIBLE);
+            holder.layoutFooter.setVisibility(LinearLayout.VISIBLE);
+            holder.expansion.setVisibility(LinearLayout.GONE);
         }
     }
 



More information about the Android mailing list