[Android] VideoGridFragment: Call updateList later at startup
Martin Storsjö
git at videolan.org
Sat Jul 27 15:49:21 CEST 2013
vlc-ports/android | branch: master | Martin Storsjö <martin at martin.st> | Sat Jul 27 16:27:00 2013 +0300| [69151c9ecffb5885e8ed03ddb130783a8b383c1c] | committer: Martin Storsjö
VideoGridFragment: Call updateList later at startup
Don't call updateList() in onViewCreated, call it in onResume
just before registering the view as a listener to updates.
This reduces the probability for race conditions. Earlier, this
was pretty often visible on the emulator, but also occasionally
on real devices. If the MediaLibrary update finished after
the grid view fragment's onViewCreated method, but before onResume,
the fragment wasn't ever registered for receiving updates about
the media library, and had only updated the list while it was empty.
Technically I guess there's still a risk for race conditions here,
but by moving the updateList() call closer to the addUpdateHandler()
call (and at least calling it in the same FragmentActivity callback)
at least reduces the risk.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=69151c9ecffb5885e8ed03ddb130783a8b383c1c
---
vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 e503e8a..3986df6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -141,7 +141,6 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
actionScanStart(getActivity().getApplicationContext());
}
- updateList();
mAnimator = new VideoGridAnimator(getGridView());
}
@@ -164,6 +163,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
HashMap<String, Long> times = MediaDatabase.getInstance(getActivity()).getVideoTimes(getActivity());
mVideoAdapter.setLastMedia(lastPath, times);
mVideoAdapter.notifyDataSetChanged();
+ updateList();
mMediaLibrary.addUpdateHandler(mHandler);
updateViewMode();
mAnimator.animate();
More information about the Android
mailing list