[Android] [PATCH] Better list refresh

Geoffrey Métais geoffrey.metais at gmail.com
Mon Nov 3 16:02:23 CET 2014


Start media loading earlier, and properly subscribe to medialibrary.
Plus refresh video times on resume, to get updated progress when we leave a video.
---
 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 d3fd535..47c5e0f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -182,6 +182,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 ***/
@@ -337,10 +341,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 abf2701..1b4cad2 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)
-- 
1.9.1



More information about the Android mailing list