summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/LocalAlbum.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-09-04 16:53:42 +0800
committerOwen Lin <owenlin@google.com>2012-09-11 12:21:59 +0800
commit676d4762496eddae66930c6f8b0bae22a22b3ef6 (patch)
tree0dff10f4ec52047f90055f76572f09038acfb94b /src/com/android/gallery3d/data/LocalAlbum.java
parentd9473d49b311306196327cc3083696911e857df3 (diff)
downloadandroid_packages_apps_Gallery2-676d4762496eddae66930c6f8b0bae22a22b3ef6.tar.gz
android_packages_apps_Gallery2-676d4762496eddae66930c6f8b0bae22a22b3ef6.tar.bz2
android_packages_apps_Gallery2-676d4762496eddae66930c6f8b0bae22a22b3ef6.zip
Ensure peekObject is called in the syncrhonization block.
bug: 7019598 Change-Id: If153287078826afc9827ea64364b4fb64f2b3a5f
Diffstat (limited to 'src/com/android/gallery3d/data/LocalAlbum.java')
-rw-r--r--src/com/android/gallery3d/data/LocalAlbum.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/data/LocalAlbum.java b/src/com/android/gallery3d/data/LocalAlbum.java
index eaf1e54fc..4682e7792 100644
--- a/src/com/android/gallery3d/data/LocalAlbum.java
+++ b/src/com/android/gallery3d/data/LocalAlbum.java
@@ -140,17 +140,19 @@ public class LocalAlbum extends MediaSet {
private static MediaItem loadOrUpdateItem(Path path, Cursor cursor,
DataManager dataManager, GalleryApp app, boolean isImage) {
- LocalMediaItem item = (LocalMediaItem) dataManager.peekMediaObject(path);
- if (item == null) {
- if (isImage) {
- item = new LocalImage(path, app, cursor);
+ synchronized (DataManager.LOCK) {
+ LocalMediaItem item = (LocalMediaItem) dataManager.peekMediaObject(path);
+ if (item == null) {
+ if (isImage) {
+ item = new LocalImage(path, app, cursor);
+ } else {
+ item = new LocalVideo(path, app, cursor);
+ }
} else {
- item = new LocalVideo(path, app, cursor);
+ item.updateContent(cursor);
}
- } else {
- item.updateContent(cursor);
+ return item;
}
- return item;
}
// The pids array are sorted by the (path) id.