summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/gallery
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2009-06-22 15:53:26 -0700
committerOwen Lin <owenlin@google.com>2009-06-24 01:40:27 -0700
commitb0e1282810ec68fd7585beb9ab9afab9bcafe1bd (patch)
treebfe09b7ca2fc1b59e63288ea1329bd8bb3240c15 /src/com/android/camera/gallery
parent2bb9e74cc84b60a349ec90b34e39973b019ec0bd (diff)
downloadLegacyCamera-b0e1282810ec68fd7585beb9ab9afab9bcafe1bd.zip
LegacyCamera-b0e1282810ec68fd7585beb9ab9afab9bcafe1bd.tar.gz
LegacyCamera-b0e1282810ec68fd7585beb9ab9afab9bcafe1bd.tar.bz2
Fix several issues with ImageList.
One is bug 1933327 It seems to be timing issue. We assign the value of mAllImages in only "onCreate" and will set it to null in "onActivityResult". I modified the code so that it won't be null after "onCreate()". The other issue is the crop image won't . The reason is we don't clean up the cache when we reopen the cache. It won't work for ImageListUber for the original fix since "buildImageListFromUri" won't return ImageList of type ImageListUber. The final one is the "getImaegForUri", last time, I made a change but cause review fails in Camera. But, I need the check if the given uri is actually the same as the image list not just check the "id".
Diffstat (limited to 'src/com/android/camera/gallery')
-rw-r--r--src/com/android/camera/gallery/BaseImageList.java29
-rw-r--r--src/com/android/camera/gallery/ImageListUber.java14
2 files changed, 38 insertions, 5 deletions
diff --git a/src/com/android/camera/gallery/BaseImageList.java b/src/com/android/camera/gallery/BaseImageList.java
index ae117cd..f8aa808 100644
--- a/src/com/android/camera/gallery/BaseImageList.java
+++ b/src/com/android/camera/gallery/BaseImageList.java
@@ -36,6 +36,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* A collection of <code>BaseImage</code>s.
@@ -79,8 +81,14 @@ public abstract class BaseImageList implements IImageList {
public void open(ContentResolver resolver) {
mContentResolver = resolver;
mCursor = createCursor();
+
+ // TODO: We need to clear the cache because we may "reopen" the image
+ // list. After we implement the image list state, we can remove this
+ // kind of usage.
+ mCache.clear();
}
+ // TODO: merge close() and deactivate()
public void close() {
mContentResolver = null;
if (mCursor != null) {
@@ -408,7 +416,28 @@ public abstract class BaseImageList implements IImageList {
mCache.clear();
}
+ private static final Pattern sPathWithId = Pattern.compile("(.*)/\\d+");
+
+ private static String getPathWithoutId(Uri uri) {
+ String path = uri.getPath();
+ Matcher matcher = sPathWithId.matcher(path);
+ return matcher.matches() ? matcher.group(1) : path;
+ }
+
+ private boolean isChildImageUri(Uri uri) {
+ // Sometimes, the URI of an image contains a query string with key
+ // "bucketId" inorder to restore the image list. However, the query
+ // string is not part of the mBaseUri. So, we check only other parts
+ // of the two Uri to see if they are the same.
+ Uri base = mBaseUri;
+ return Util.equals(base.getScheme(), uri.getScheme())
+ && Util.equals(base.getHost(), uri.getHost())
+ && Util.equals(base.getAuthority(), uri.getAuthority())
+ && Util.equals(base.getPath(), getPathWithoutId(uri));
+ }
+
public IImage getImageForUri(Uri uri) {
+ if (!isChildImageUri(uri)) return null;
// Find the id of the input URI.
long matchId;
try {
diff --git a/src/com/android/camera/gallery/ImageListUber.java b/src/com/android/camera/gallery/ImageListUber.java
index 691c680..db8a299 100644
--- a/src/com/android/camera/gallery/ImageListUber.java
+++ b/src/com/android/camera/gallery/ImageListUber.java
@@ -50,14 +50,13 @@ public class ImageListUber implements IImageList {
//
// * The higher 32bit component indicates which sublist we're referring
// to.
- private long[] mSkipList = new long[16];
- private int mSkipListSize = 0;
- private int [] mSkipCounts = null;
- private int mLastListIndex = -1;
+ private long[] mSkipList;
+ private int mSkipListSize;
+ private int [] mSkipCounts;
+ private int mLastListIndex;
public ImageListUber(IImageList [] sublist, int sort) {
mSubList = sublist.clone();
- mSkipCounts = new int[mSubList.length];
mQueue = new PriorityQueue<MergeSlot>(4,
sort == ImageManager.SORT_ASCENDING
? new AscendingComparator()
@@ -340,6 +339,11 @@ public class ImageListUber implements IImageList {
}
public void open(ContentResolver cr) {
+ mSkipList = new long[16];
+ mSkipListSize = 0;
+ mSkipCounts = new int[mSubList.length];
+ mLastListIndex = -1;
+ mQueue.clear();
for (int i = 0, n = mSubList.length; i < n; ++i) {
IImageList list = mSubList[i];
if (list instanceof BaseImageList) {