[Android] [PATCH] Video items lifting

Geoffrey Métais geoffrey.metais at gmail.com
Thu Nov 20 14:15:55 CET 2014


Fix alignment
split time and resolution texts
---
 vlc-android/res/layout/video_grid_card.xml         | 31 ++++++++---
 vlc-android/res/layout/video_list_card.xml         | 63 +++++++++++++---------
 vlc-android/res/values/dimens.xml                  |  1 +
 .../videolan/vlc/gui/video/VideoGridFragment.java  |  3 ++
 .../videolan/vlc/gui/video/VideoListAdapter.java   | 49 +++++++++--------
 5 files changed, 93 insertions(+), 54 deletions(-)

diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index 2bd11ce..23fe6a3 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -26,32 +26,49 @@
             android:textSize="@dimen/grid_card_title_text_size"
             android:textColor="?attr/list_title"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_below="@id/ml_item_thumbnail"
+            android:layout_above="@+id/ml_item_time"
             android:layout_toLeftOf="@+id/item_more"
             android:layout_marginTop="5dp"
+            android:gravity="center_vertical"
+            android:paddingLeft="10dp"
             android:ellipsize="end"
-            android:gravity="center_horizontal"
             android:maxLines="2" />
 
         <ImageView
             android:id="@+id/item_more"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_height="match_parent"
             android:layout_alignParentRight="true"
             android:layout_below="@id/ml_item_thumbnail"
-            android:layout_marginTop="10dp"
+            android:layout_above="@+id/ml_item_resolution"
             android:layout_marginRight="7dp"
+            android:scaleType="fitCenter"
             android:clickable="true"
             android:src="@drawable/ic_more_vert_grey600_24dp" />
 
         <TextView
-            android:id="@+id/ml_item_subtitle"
-            android:layout_width="fill_parent"
+            android:id="@+id/ml_item_time"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:layout_toLeftOf="@+id/ml_item_resolution"
+            android:gravity="left"
+            android:layout_marginBottom="3dp"
+            android:layout_marginLeft="5dp"
+            android:singleLine="true"
+            android:textSize="@dimen/grid_card_subtitle_text_size"
+            android:textColor="?attr/list_subtitle" />
+
+        <TextView
+            android:id="@+id/ml_item_resolution"
+            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_alignParentBottom="true"
+            android:layout_alignParentRight="true"
             android:layout_marginBottom="3dp"
-            android:gravity="center_horizontal"
+            android:layout_marginRight="5dp"
             android:singleLine="true"
             android:textSize="@dimen/grid_card_subtitle_text_size"
             android:textColor="?attr/list_subtitle" />
diff --git a/vlc-android/res/layout/video_list_card.xml b/vlc-android/res/layout/video_list_card.xml
index 51b84df..66656cc 100644
--- a/vlc-android/res/layout/video_list_card.xml
+++ b/vlc-android/res/layout/video_list_card.xml
@@ -9,47 +9,73 @@
     card_view:cardElevation="1sp" >
 
     <RelativeLayout
-        android:id="@+id/ml_item_layout_thumbnail"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content">
+        android:layout_height="75dip"
+        android:orientation="horizontal">
 
         <ImageView
             android:id="@+id/ml_item_thumbnail"
             android:layout_width="120dip"
             android:layout_height="75dip"
-            android:scaleType="fitCenter"
-        	android:layout_alignParentLeft="true" />
+            android:layout_alignParentLeft="true"
+            android:scaleType="fitCenter" />
 
         <TextView
             android:id="@+id/ml_item_title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
             android:layout_toRightOf="@id/ml_item_thumbnail"
             android:layout_toLeftOf="@+id/item_more"
+            android:layout_above="@+id/ml_item_time"
+            android:layout_alignParentTop="true"
+            android:gravity="center_vertical"
             android:ellipsize="end"
             android:maxLines="2"
             android:paddingLeft="12dip"
             android:textColor="?attr/list_title"
             android:textSize="17sp" />
 
-        <TextView
-            android:id="@+id/ml_item_subtitle"
+        <ImageView
+            android:id="@+id/item_more"
             android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:layout_alignParentRight="true"
+            android:layout_alignParentTop="true"
+            android:layout_above="@+id/ml_item_resolution"
+            android:clickable="true"
+            android:src="@drawable/ic_more_vert_grey600_24dp"
+            android:scaleType="fitCenter" />
+
+        <TextView
+            android:id="@+id/ml_item_time"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_below="@id/ml_item_title"
-            android:layout_alignLeft="@id/ml_item_title"
+            android:layout_toRightOf="@+id/ml_item_thumbnail"
+            android:layout_toLeftOf="@+id/ml_item_resolution"
+            android:layout_above="@id/ml_item_progress"
+            android:gravity="left"
             android:paddingLeft="12dip"
             android:textColor="?attr/list_subtitle"
             android:textSize="14sp" />
+        <TextView
+            android:id="@+id/ml_item_resolution"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_above="@id/ml_item_progress"
+            android:layout_alignParentRight="true"
+            android:layout_marginRight="10dp"
+            android:textColor="?attr/list_subtitle"
+            android:textSize="14sp" />
 
         <ProgressBar
             android:id="@+id/ml_item_progress"
             style="@android:style/Widget.ProgressBar.Horizontal"
-            android:layout_width="fill_parent"
+            android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_toRightOf="@+id/ml_item_thumbnail"
             android:layout_alignParentBottom="true"
-            android:layout_toRightOf="@id/ml_item_thumbnail"
-            android:layout_marginRight="20dip"
+            android:layout_marginTop="1dp"
+            android:layout_marginRight="10dip"
             android:layout_marginLeft="10dip"
             android:paddingBottom="3dip"
             android:focusable="false"
@@ -57,17 +83,6 @@
             android:maxHeight="3dip"
             android:minHeight="3dip"
             android:progressDrawable="@drawable/gridview_progressbar" />
-
-        <ImageView
-            android:id="@+id/item_more"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentTop="true"
-            android:layout_marginTop="10dip"
-            android:layout_alignParentRight="true"
-            android:clickable="true"
-            android:src="@drawable/ic_more_vert_grey600_24dp" />
-
     </RelativeLayout>
 
 </android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 1400716..67264c7 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -4,6 +4,7 @@
     <dimen name="audio_browser_item_size">40dp</dimen>
     <dimen name="directory_browser_item_size">40dp</dimen>
     <dimen name="listview_bottom_padding">50dp</dimen>
+    <dimen name="listview_side_padding">5dp</dimen>
     <dimen name="grid_card_width">160dp</dimen>
     <dimen name="grid_card_height">160dp</dimen>
     <dimen name="grid_card_thumb_height">100dp</dimen>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 347a1fe..1f022a0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -232,9 +232,12 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
             mGridView.setVerticalSpacing(res.getDimensionPixelSize(R.dimen.grid_card_vertical_spacing));
             mVideoAdapter.setListMode(false);
         } else {
+            int padding = res.getDimensionPixelSize(R.dimen.listview_side_padding);
             mGridView.setNumColumns(1);
             mGridView.setStretchMode(LIST_STRETCH_MODE);
             mGridView.setVerticalSpacing(0);
+            mGridView.setHorizontalSpacing(0);
+            mGridView.setPadding(padding,0,padding,0);
             mVideoAdapter.setListMode(true);
         }
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 70ec8bc..c2515c9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -147,7 +147,8 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             holder.layout = v.findViewById(R.id.layout_item);
             holder.thumbnail = (ImageView) v.findViewById(R.id.ml_item_thumbnail);
             holder.title = (TextView) v.findViewById(R.id.ml_item_title);
-            holder.subtitle = (TextView) v.findViewById(R.id.ml_item_subtitle);
+            holder.time = (TextView) v.findViewById(R.id.ml_item_time);
+            holder.resolution = (TextView) v.findViewById(R.id.ml_item_resolution);
             holder.progress = (ProgressBar) v.findViewById(R.id.ml_item_progress);
             holder.more = (ImageView) v.findViewById(R.id.item_more);
             holder.listmode = mListMode;
@@ -200,33 +201,34 @@ public class VideoListAdapter extends ArrayAdapter<Media>
         int size = mediaGroup.size();
         String text = getContext().getResources().getQuantityString(R.plurals.videos_quantity, size, size);
 
-        holder.subtitle.setText(text);
+        holder.resolution.setText(text);
         holder.title.setText(media.getTitle() + "\u2026"); // ellipsis
-        holder.more.setVisibility(View.INVISIBLE);
+        holder.more.setVisibility(View.GONE);
         holder.progress.setVisibility(View.INVISIBLE);
     }
 
     private void fillVideoView(ViewHolder holder, Media media) {
         /* Time / Duration */
-        long lastTime = media.getTime();
-        String text;
-        if (lastTime > 0) {
-            text = String.format("%s / %s",
-                    Strings.millisToText(lastTime),
-                    Strings.millisToText(media.getLength()));
-            holder.progress.setVisibility(View.VISIBLE);
-            holder.progress.setMax((int) (media.getLength() / 1000));
-            holder.progress.setProgress((int) (lastTime / 1000));
-        } else {
-            text = Strings.millisToText(media.getLength());
-            holder.progress.setVisibility(View.INVISIBLE);
-        }
-
-        if (media.getWidth() > 0 && media.getHeight() > 0) {
-            text += String.format(" - %dx%d", media.getWidth(), media.getHeight());
-        }
-
-        holder.subtitle.setText(text);
+        if (media.getLength() > 0) {
+            long lastTime = media.getTime();
+            String text;
+            if (lastTime > 0) {
+                text = String.format("%s / %s",
+                        Strings.millisToText(lastTime),
+                        Strings.millisToText(media.getLength()));
+                holder.progress.setVisibility(View.VISIBLE);
+                holder.progress.setMax((int) (media.getLength() / 1000));
+                holder.progress.setProgress((int) (lastTime / 1000));
+            } else {
+                text = Strings.millisToText(media.getLength());
+                holder.progress.setVisibility(View.INVISIBLE);
+            }
+
+            holder.time.setText(text);
+        } else
+                holder.progress.setVisibility(View.INVISIBLE);
+        if (media.getWidth() > 0 && media.getHeight() > 0)
+            holder.resolution.setText(String.format("%dx%d", media.getWidth(), media.getHeight()));
         holder.title.setText(media.getTitle());
         holder.more.setVisibility(View.VISIBLE);
     }
@@ -236,7 +238,8 @@ public class VideoListAdapter extends ArrayAdapter<Media>
         View layout;
         ImageView thumbnail;
         TextView title;
-        TextView subtitle;
+        TextView time;
+        TextView resolution;
         ImageView more;
         ProgressBar progress;
     }
-- 
1.9.1



More information about the Android mailing list