[Android] [PATCH] Do not refresh videos list everytime

Geoffrey Métais geoffrey.metais at gmail.com
Tue Oct 14 16:32:24 CEST 2014


---
 .../org/videolan/vlc/gui/video/VideoGridFragment.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

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 64d7fc1..f456d6c 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,19 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
     @Override
     public void onResume() {
         super.onResume();
-        //Get & set times
-        HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
-        mVideoAdapter.setTimes(times);
-        mVideoAdapter.notifyDataSetChanged();
-        updateList();
+        boolean refresh = mVideoAdapter.getCount() == 0;
+        if (refresh){
+            updateList();
+            //Get & set times
+            HashMap<String, Long> times = MediaDatabase.getInstance().getVideoTimes(getActivity());
+            mVideoAdapter.setTimes(times);
+            mVideoAdapter.notifyDataSetChanged();
+        }
         mMediaLibrary.addUpdateHandler(mHandler);
         mGridView.setSelection(mGVFirstVisiblePos);
         updateViewMode();
-        mAnimator.animate();
+        if (refresh)
+            mAnimator.animate();
 
         /* Start the thumbnailer */
         if (mThumbnailer != null)
-- 
1.9.1



More information about the Android mailing list