[Android] GridView: show the viewing progress under the thumbnails

Ludovic Fauvet git at videolan.org
Fri Oct 12 16:49:17 CEST 2012


vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Fri Oct 12 16:31:31 2012 +0200| [73ac31a45c3e4329aa3eee3a07c1525acefb3796] | committer: Ludovic Fauvet

GridView: show the viewing progress under the thumbnails

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

 vlc-android/res/drawable/gridview_progressbar.xml  |   26 ++++++++++++++++++
 vlc-android/res/layout/video_grid_item.xml         |   29 +++++++++++++++-----
 vlc-android/res/layout/video_list_item.xml         |   27 ++++++++++++++----
 .../videolan/vlc/gui/video/VideoListAdapter.java   |   10 +++++--
 4 files changed, 77 insertions(+), 15 deletions(-)

diff --git a/vlc-android/res/drawable/gridview_progressbar.xml b/vlc-android/res/drawable/gridview_progressbar.xml
new file mode 100644
index 0000000..4f82abd
--- /dev/null
+++ b/vlc-android/res/drawable/gridview_progressbar.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@android:id/background">
+        <shape>
+            <solid android:color="#000" />
+        </shape>
+    </item>
+
+    <item android:id="@android:id/secondaryProgress">
+        <clip>
+            <shape>
+                <solid android:color="#80CCCCCC" />
+            </shape>
+        </clip>
+    </item>
+
+    <item android:id="@android:id/progress">
+        <clip>
+            <shape>
+                <solid android:color="#F48B00" />
+            </shape>
+        </clip>
+    </item>
+
+</layer-list>
\ No newline at end of file
diff --git a/vlc-android/res/layout/video_grid_item.xml b/vlc-android/res/layout/video_grid_item.xml
index 9d11b59..2c77d8d 100644
--- a/vlc-android/res/layout/video_grid_item.xml
+++ b/vlc-android/res/layout/video_grid_item.xml
@@ -6,13 +6,28 @@
     android:layout_height="150dip"
     android:orientation="vertical"
     android:gravity="center_vertical">
-    <ImageView
-        android:id="@+id/ml_item_thumbnail"
-        android:layout_width="160dip"
-        android:layout_height="100dip"
-        android:scaleType="fitCenter"
-        android:layout_gravity="center_horizontal"
-        android:background="@drawable/dropshadow" />
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:background="@drawable/dropshadow">
+        <ImageView
+            android:id="@+id/ml_item_thumbnail"
+            android:layout_width="160dip"
+            android:layout_height="100dip"
+            android:scaleType="fitCenter"
+            android:layout_gravity="center_horizontal" />
+        <ProgressBar
+            style="@android:style/Widget.ProgressBar.Horizontal"
+            android:id="@+id/ml_item_progress"
+            android:layout_height="wrap_content"
+            android:layout_width="fill_parent"
+            android:minHeight="1dip"
+            android:maxHeight="1dip"
+            android:progressDrawable="@drawable/gridview_progressbar"
+            android:focusable="false"
+            android:indeterminate="false" />
+    </LinearLayout>
     <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="0dp"
diff --git a/vlc-android/res/layout/video_list_item.xml b/vlc-android/res/layout/video_list_item.xml
index 39c9fb2..b602da5 100644
--- a/vlc-android/res/layout/video_list_item.xml
+++ b/vlc-android/res/layout/video_list_item.xml
@@ -6,12 +6,27 @@
     android:layout_height="wrap_content"
     android:orientation="horizontal"
     android:gravity="center_vertical">
-    <ImageView
-        android:id="@+id/ml_item_thumbnail"
-        android:layout_width="120dip"
-        android:layout_height="75dip"
-        android:scaleType="fitCenter"
-        android:background="@drawable/dropshadow" />
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="vertical"
+        android:background="@drawable/dropshadow">
+        <ImageView
+            android:id="@+id/ml_item_thumbnail"
+            android:layout_width="120dip"
+            android:layout_height="75dip"
+            android:scaleType="fitCenter" />
+        <ProgressBar
+            style="@android:style/Widget.ProgressBar.Horizontal"
+            android:id="@+id/ml_item_progress"
+            android:layout_height="wrap_content"
+            android:layout_width="fill_parent"
+            android:minHeight="1dip"
+            android:maxHeight="1dip"
+            android:progressDrawable="@drawable/gridview_progressbar"
+            android:focusable="false"
+            android:indeterminate="false" />
+    </LinearLayout>
     <LinearLayout
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
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 c8d90fb..63be673 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -37,6 +37,7 @@ import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
 import android.widget.GridView;
 import android.widget.ImageView;
+import android.widget.ProgressBar;
 import android.widget.TextView;
 
 public class VideoListAdapter extends ArrayAdapter<Media>
@@ -137,6 +138,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             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.progress = (ProgressBar) v.findViewById(R.id.ml_item_progress);
             holder.listmode = mListMode;
             v.setTag(holder);
             /* Set the layoutParams based on the values set in the video_grid_item.xml root element */
@@ -169,10 +171,13 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             text = String.format("%s / %s",
                     Util.millisToString(lastTime),
                     Util.millisToString(media.getLength()));
-        }
-        else {
+            holder.progress.setVisibility(View.VISIBLE);
+            holder.progress.setMax((int) (media.getLength() / 1000));
+            holder.progress.setProgress((int) (lastTime / 1000));
+        } else {
             text = String.format("%s",
                     Util.millisToString(media.getLength()));
+            holder.progress.setVisibility(View.GONE);
         }
 
         if (media.getWidth() > 0 && media.getHeight() > 0) {
@@ -191,6 +196,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
         TextView title;
         TextView subtitle;
         ImageView more;
+        ProgressBar progress;
     }
 
     public void setListMode(boolean value) {



More information about the Android mailing list