diff options
author | Owen Lin <owenlin@google.com> | 2012-09-04 16:53:42 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-09-11 12:21:59 +0800 |
commit | 5251514287e41c57076029b08484d20beb5967b5 (patch) | |
tree | 355dc94f09d8963c5ba2c0c3abb5b45878e4b5a5 /src/com/android/gallery3d/app/AlbumSetDataLoader.java | |
parent | 960306bb25cb79ded4f5cb0f3b329ff042e0e837 (diff) | |
download | android_packages_apps_Snap-5251514287e41c57076029b08484d20beb5967b5.tar.gz android_packages_apps_Snap-5251514287e41c57076029b08484d20beb5967b5.tar.bz2 android_packages_apps_Snap-5251514287e41c57076029b08484d20beb5967b5.zip |
Ensure peekObject is called in the syncrhonization block.
bug: 7019598
Change-Id: If153287078826afc9827ea64364b4fb64f2b3a5f
Diffstat (limited to 'src/com/android/gallery3d/app/AlbumSetDataLoader.java')
-rw-r--r-- | src/com/android/gallery3d/app/AlbumSetDataLoader.java | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetDataLoader.java b/src/com/android/gallery3d/app/AlbumSetDataLoader.java index 80bc48a46..9f7014ecd 100644 --- a/src/com/android/gallery3d/app/AlbumSetDataLoader.java +++ b/src/com/android/gallery3d/app/AlbumSetDataLoader.java @@ -19,11 +19,9 @@ package com.android.gallery3d.app; import android.os.Handler; import android.os.Message; import android.os.Process; -import android.os.SystemClock; import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.ContentListener; -import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; import com.android.gallery3d.data.MediaSet; @@ -353,39 +351,28 @@ public class AlbumSetDataLoader { mDirty = false; updateLoading(true); - long version; - synchronized (DataManager.LOCK) { - long start = SystemClock.uptimeMillis(); - version = mSource.reload(); - long duration = SystemClock.uptimeMillis() - start; - if (duration > 20) { - Log.v("DebugLoadingTime", "finish reload - " + duration); - } - } + long version = mSource.reload(); UpdateInfo info = executeAndWait(new GetUpdateInfo(version)); updateComplete = info == null; if (updateComplete) continue; - - synchronized (DataManager.LOCK) { - if (info.version != version) { - info.version = version; - info.size = mSource.getSubMediaSetCount(); - - // If the size becomes smaller after reload(), we may - // receive from GetUpdateInfo an index which is too - // big. Because the main thread is not aware of the size - // change until we call UpdateContent. - if (info.index >= info.size) { - info.index = INDEX_NONE; - } - } - if (info.index != INDEX_NONE) { - info.item = mSource.getSubMediaSet(info.index); - if (info.item == null) continue; - info.cover = info.item.getCoverMediaItem(); - info.totalCount = info.item.getTotalMediaItemCount(); + if (info.version != version) { + info.version = version; + info.size = mSource.getSubMediaSetCount(); + + // If the size becomes smaller after reload(), we may + // receive from GetUpdateInfo an index which is too + // big. Because the main thread is not aware of the size + // change until we call UpdateContent. + if (info.index >= info.size) { + info.index = INDEX_NONE; } } + if (info.index != INDEX_NONE) { + info.item = mSource.getSubMediaSet(info.index); + if (info.item == null) continue; + info.cover = info.item.getCoverMediaItem(); + info.totalCount = info.item.getTotalMediaItemCount(); + } executeAndWait(new UpdateContent(info)); } updateLoading(false); |