[Android] Audio browser: remove the footer if the item is just above a separator
Adrien Maglo
git at videolan.org
Tue Nov 19 21:00:19 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Nov 19 21:00:12 2013 +0100| [3ddc4e973a21a0a7a9cc8dfd01989adcfdee524b] | committer: Adrien Maglo
Audio browser: remove the footer if the item is just above a separator
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=3ddc4e973a21a0a7a9cc8dfd01989adcfdee524b
---
.../res/layout/audio_browser_item_simple.xml | 3 ++-
vlc-android/res/values/dimens.xml | 1 +
.../vlc/gui/audio/AudioBrowserListAdapter.java | 25 ++++++++++++++++++++
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/vlc-android/res/layout/audio_browser_item_simple.xml b/vlc-android/res/layout/audio_browser_item_simple.xml
index 8c2eec3..f600246 100644
--- a/vlc-android/res/layout/audio_browser_item_simple.xml
+++ b/vlc-android/res/layout/audio_browser_item_simple.xml
@@ -51,8 +51,9 @@
</RelativeLayout>
<View
+ android:id="@+id/footer"
android:layout_width="match_parent"
- android:layout_height="1dip"
+ android:layout_height="@dimen/audio_browser_item_footer_height"
android:background="@color/item_footer" />
</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 0055427..5830731 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -2,4 +2,5 @@
<dimen name="shadow_width">6px</dimen>
<dimen name="widget_margin">10dp</dimen>
<dimen name="audio_browser_item_size">50dp</dimen>
+ <dimen name="audio_browser_item_footer_height">1dp</dimen>
</resources>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index 9420e63..568ef47 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -137,6 +137,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements ListAdapter
holder.title = (TextView) v.findViewById(R.id.title);
holder.cover = (ImageView) v.findViewById(R.id.cover);
holder.subtitle = (TextView) v.findViewById(R.id.subtitle);
+ holder.footer = (View) v.findViewById(R.id.footer);
v.setTag(holder);
} else
holder = (ViewHolder) v.getTag();
@@ -168,6 +169,16 @@ public class AudioBrowserListAdapter extends BaseAdapter implements ListAdapter
}
holder.subtitle.setLayoutParams(paramsSubTitle);
+ // Remove the footer if the item is just above a separator.
+ LinearLayout.LayoutParams paramsFooter;
+ if (isMediaItemAboveASeparator(position))
+ paramsFooter = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);
+ else {
+ int height = (int) mContext.getResources().getDimension(R.dimen.audio_browser_item_footer_height);
+ paramsFooter = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, height);
+ }
+ holder.footer.setLayoutParams(paramsFooter);
+
return v;
}
@@ -205,6 +216,7 @@ public class AudioBrowserListAdapter extends BaseAdapter implements ListAdapter
ImageView cover;
TextView title;
TextView subtitle;
+ View footer;
int viewType;
}
@@ -269,4 +281,17 @@ public class AudioBrowserListAdapter extends BaseAdapter implements ListAdapter
mediaList.addAll(mItems.get(position).mMediaList);
return mediaList;
}
+
+ private boolean isMediaItemAboveASeparator(int position) {
+ // Test if a media item if above or not a separator.
+ if (mItems.get(position).mIsSeparator)
+ throw new IllegalArgumentException("Tested item must be a media item and not a separator.");
+
+ if (position == mItems.size() - 1)
+ return false;
+ else if (mItems.get(position + 1).mIsSeparator )
+ return true;
+ else
+ return false;
+ }
}
More information about the Android
mailing list