[Android] Better list refresh

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


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 30 17:06:13 2014 +0100| [1c4d466e55ec37753db92beadaa15d0fe60bca32] | committer: Geoffrey Métais

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.

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

 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)



More information about the Android mailing list