[Android] Audio player: to hide a view, use the visibility attribute instead of the zero height hack
Adrien Maglo
git at videolan.org
Fri Jan 17 12:49:23 CET 2014
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jan 17 12:49:17 2014 +0100| [15921d2974a2694b8d3fc7562ba9cefbe2de90f2] | committer: Adrien Maglo
Audio player: to hide a view, use the visibility attribute instead of the zero height hack
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=15921d2974a2694b8d3fc7562ba9cefbe2de90f2
---
.../res/layout/audio_browser_item_simple.xml | 2 +-
vlc-android/res/values/dimens.xml | 1 -
.../vlc/gui/audio/AudioBrowserListAdapter.java | 20 +++-----------------
3 files changed, 4 insertions(+), 19 deletions(-)
diff --git a/vlc-android/res/layout/audio_browser_item_simple.xml b/vlc-android/res/layout/audio_browser_item_simple.xml
index 541fc65..ec96ef9 100644
--- a/vlc-android/res/layout/audio_browser_item_simple.xml
+++ b/vlc-android/res/layout/audio_browser_item_simple.xml
@@ -58,7 +58,7 @@
<View
android:id="@+id/footer"
android:layout_width="match_parent"
- android:layout_height="@dimen/audio_browser_item_footer_height"
+ android:layout_height="1dp"
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 5830731..0055427 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -2,5 +2,4 @@
<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 98c0bb1..cbce186 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -188,25 +188,11 @@ public class AudioBrowserListAdapter extends BaseAdapter {
paramsCover = new RelativeLayout.LayoutParams(0, RelativeLayout.LayoutParams.WRAP_CONTENT);
holder.cover.setLayoutParams(paramsCover);
- LinearLayout.LayoutParams paramsSubTitle;
- if (item.mSubTitle == null)
- paramsSubTitle = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, 0);
- else {
- paramsSubTitle = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- holder.subtitle.setText(item.mSubTitle);
- }
- holder.subtitle.setLayoutParams(paramsSubTitle);
+ holder.subtitle.setVisibility(item.mSubTitle == null ? TextView.GONE : TextView.VISIBLE);
+ holder.subtitle.setText(item.mSubTitle);
// 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);
+ holder.footer.setVisibility(isMediaItemAboveASeparator(position) ? View.GONE : View.VISIBLE);
final int pos = position;
holder.more.setOnClickListener(new OnClickListener() {
More information about the Android
mailing list