[Android] Better list refresh

Geoffrey Métais git at videolan.org
Mon Nov 3 16:53:19 CET 2014


vlc-ports/android | branch: 1.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 30 17:06:13 2014 +0100| [c9246070070a8a4245343364acd84ac317f56a12] | committer: Jean-Baptiste Kempf

Better list refresh

Start media loading earlier, and properly subscribe to medialibrary.
Plus refresh video times on resume, to get updated progress when we leave a video.

(cherry picked from commit 1c4d466e55ec37753db92beadaa15d0fe60bca32)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java    |    8 ++++----
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java |   13 ++++++-------
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index f4052a9..5d5079b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -179,6 +179,10 @@ public class MainActivity extends ActionBarActivity {
             return;
         }
 
+        /* Load media items from database and storage */
+        if (mScanNeeded)
+            MediaLibrary.getInstance().loadMediaItems();
+
         super.onCreate(savedInstanceState);
 
         /*** Start initializing the UI ***/
@@ -334,10 +338,6 @@ public class MainActivity extends ActionBarActivity {
         /* FIXME: this is used to avoid having MainActivity twice in the backstack */
         if (getIntent().hasExtra(AudioService.START_FROM_NOTIFICATION))
             getIntent().removeExtra(AudioService.START_FROM_NOTIFICATION);
-
-        /* Load media items from database and storage */
-        if (mScanNeeded)
-            MediaLibrary.getInstance().loadMediaItems();
    }
 
     @Override
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 a35180a..22a4b36 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -174,15 +174,14 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
     @Override
     public void onResume() {
         super.onResume();
+        mMediaLibrary.addUpdateHandler(mHandler);
         final boolean refresh = mVideoAdapter.isEmpty();
-        if (refresh){
+        if (refresh)
             updateList();
-            //Get & set times
-            HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
-            mVideoAdapter.setTimes(times);
-            mVideoAdapter.notifyDataSetChanged();
-        }
-        mMediaLibrary.addUpdateHandler(mHandler);
+        //Get & set times
+        HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
+        mVideoAdapter.setTimes(times);
+        mVideoAdapter.notifyDataSetChanged();
         mGridView.setSelection(mGVFirstVisiblePos);
         updateViewMode();
         if (refresh)



More information about the Android mailing list