summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/app/PhotoDataAdapter.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/app/PhotoDataAdapter.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/app/PhotoDataAdapter.java')
-rw-r--r--src/com/android/gallery3d/app/PhotoDataAdapter.java83
1 files changed, 40 insertions, 43 deletions
diff --git a/src/com/android/gallery3d/app/PhotoDataAdapter.java b/src/com/android/gallery3d/app/PhotoDataAdapter.java
index abe4e8aa3..5ba2afceb 100644
--- a/src/com/android/gallery3d/app/PhotoDataAdapter.java
+++ b/src/com/android/gallery3d/app/PhotoDataAdapter.java
@@ -25,7 +25,6 @@ import com.android.gallery3d.common.BitmapUtils;
import com.android.gallery3d.common.Utils;
import com.android.gallery3d.data.BitmapPool;
import com.android.gallery3d.data.ContentListener;
-import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.LocalMediaItem;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -1007,58 +1006,56 @@ public class PhotoDataAdapter implements PhotoPage.Model {
}
mDirty = false;
UpdateInfo info = executeAndWait(new GetUpdateInfo());
- synchronized (DataManager.LOCK) {
- updateLoading(true);
- long version = mSource.reload();
- if (info.version != version) {
- info.reloadContent = true;
- info.size = mSource.getMediaItemCount();
- }
- if (!info.reloadContent) continue;
- info.items = mSource.getMediaItem(
- info.contentStart, info.contentEnd);
-
- int index = MediaSet.INDEX_NOT_FOUND;
+ updateLoading(true);
+ long version = mSource.reload();
+ if (info.version != version) {
+ info.reloadContent = true;
+ info.size = mSource.getMediaItemCount();
+ }
+ if (!info.reloadContent) continue;
+ info.items = mSource.getMediaItem(
+ info.contentStart, info.contentEnd);
- // First try to focus on the given hint path if there is one.
- if (mFocusHintPath != null) {
- index = findIndexOfPathInCache(info, mFocusHintPath);
- mFocusHintPath = null;
- }
+ int index = MediaSet.INDEX_NOT_FOUND;
- // Otherwise try to see if the currently focused item can be found.
- if (index == MediaSet.INDEX_NOT_FOUND) {
- MediaItem item = findCurrentMediaItem(info);
- if (item != null && item.getPath() == info.target) {
- index = info.indexHint;
- } else {
- index = findIndexOfTarget(info);
- }
- }
+ // First try to focus on the given hint path if there is one.
+ if (mFocusHintPath != null) {
+ index = findIndexOfPathInCache(info, mFocusHintPath);
+ mFocusHintPath = null;
+ }
- // The image has been deleted. Focus on the next image (keep
- // mCurrentIndex unchanged) or the previous image (decrease
- // mCurrentIndex by 1). In page mode we want to see the next
- // image, so we focus on the next one. In film mode we want the
- // later images to shift left to fill the empty space, so we
- // focus on the previous image (so it will not move). In any
- // case the index needs to be limited to [0, mSize).
- if (index == MediaSet.INDEX_NOT_FOUND) {
+ // Otherwise try to see if the currently focused item can be found.
+ if (index == MediaSet.INDEX_NOT_FOUND) {
+ MediaItem item = findCurrentMediaItem(info);
+ if (item != null && item.getPath() == info.target) {
index = info.indexHint;
- if (mFocusHintDirection == FOCUS_HINT_PREVIOUS
- && index > 0) {
- index--;
- }
+ } else {
+ index = findIndexOfTarget(info);
}
+ }
- // Don't change index if mSize == 0
- if (mSize > 0) {
- if (index >= mSize) index = mSize - 1;
+ // The image has been deleted. Focus on the next image (keep
+ // mCurrentIndex unchanged) or the previous image (decrease
+ // mCurrentIndex by 1). In page mode we want to see the next
+ // image, so we focus on the next one. In film mode we want the
+ // later images to shift left to fill the empty space, so we
+ // focus on the previous image (so it will not move). In any
+ // case the index needs to be limited to [0, mSize).
+ if (index == MediaSet.INDEX_NOT_FOUND) {
+ index = info.indexHint;
+ if (mFocusHintDirection == FOCUS_HINT_PREVIOUS
+ && index > 0) {
+ index--;
}
+ }
- info.indexHint = index;
+ // Don't change index if mSize == 0
+ if (mSize > 0) {
+ if (index >= mSize) index = mSize - 1;
}
+ info.indexHint = index;
+
executeAndWait(new UpdateContent(info));
}
}