[Android] UI: show last position of last video played

Sébastien Toque git at videolan.org
Thu May 24 20:03:42 CEST 2012


android | branch: master | Sébastien Toque <xilasz at gmail.com> | Thu May 24 20:03:39 2012 +0200| [0d17d4fdd1f0dbfb7530d59af01d77c6120588e3] | committer: Sébastien Toque

UI: show last position of last video played

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=0d17d4fdd1f0dbfb7530d59af01d77c6120588e3
---

 .../videolan/vlc/gui/video/VideoListActivity.java  |    2 +-
 .../videolan/vlc/gui/video/VideoListAdapter.java   |   24 ++++++++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
index 3ae701e..5d19844 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListActivity.java
@@ -81,7 +81,7 @@ public class VideoListActivity extends ListActivity implements ISortable {
         SharedPreferences preferences = getSharedPreferences(PreferencesActivity.NAME, Context.MODE_PRIVATE);
         String lastPath = preferences.getString("LastMedia", null);
         long lastTime = preferences.getLong("LastTime", 0);
-        mVideoAdapter.setLastMedia(lastTime > 0 ? lastPath : null);
+        mVideoAdapter.setLastMedia(lastTime, lastPath);
         mVideoAdapter.notifyDataSetChanged();
         super.onResume();
     }
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 1a5fdf2..bb4af68 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -46,6 +46,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
     public final static int SORT_BY_LENGTH = 1;
     private int mSortDirection = 1;
     private int mSortBy = SORT_BY_TITLE;
+    private long mLastTime;
     private String mLastMRL;
 
     public VideoListAdapter(Context context) {
@@ -62,8 +63,9 @@ public class VideoListAdapter extends ArrayAdapter<Media>
         }
     }
 
-    public void setLastMedia(String lastMRL) {
-        mLastMRL = lastMRL;
+    public void setLastMedia(long lastTime, String lastMRL) {
+        mLastTime = lastTime;
+        mLastMRL = lastTime > 0 ? lastMRL : null;
     }
 
     public void sortBy(int sortby) {
@@ -145,9 +147,21 @@ public class VideoListAdapter extends ArrayAdapter<Media>
             holder.thumbnail.setImageBitmap(thumbnail);
         }
 
-        holder.title.setTextColor(media.getLocation().equals(mLastMRL) ? 0xFFF48B00 /* ORANGE */ : Color.WHITE);
-        holder.subtitle.setText(String.format("%s - %dx%d",
-                                Util.millisToString(media.getLength()), media.getWidth(), media.getHeight()));
+        if (media.getLocation().equals(mLastMRL))
+        {
+            holder.title.setTextColor(0xFFF48B00 /* ORANGE */);
+            holder.subtitle.setText(String.format("%s / %s - %dx%d",
+                    Util.millisToString(mLastTime),
+                    Util.millisToString(media.getLength()),
+                    media.getWidth(), media.getHeight()));
+        }
+        else
+        {
+            holder.title.setTextColor(Color.WHITE);
+            holder.subtitle.setText(String.format("%s - %dx%d",
+                    Util.millisToString(media.getLength()),
+                    media.getWidth(), media.getHeight()));
+        }
         holder.more.setTag(media);
         holder.more.setOnClickListener(moreClickListener);
 



More information about the Android mailing list