summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2013-05-01 16:56:32 -0700
committerGeorge Mount <mount@google.com>2013-05-02 09:23:45 -0700
commite4600fca519144d8d9b82a82fdfaabcc77182f40 (patch)
treed81f188be8d6dff51a625649a950c30b8d2febe1 /src/com
parent6cf36371a5888be8e137af1ede183bd592bb07b2 (diff)
downloadandroid_packages_apps_Snap-e4600fca519144d8d9b82a82fdfaabcc77182f40.tar.gz
android_packages_apps_Snap-e4600fca519144d8d9b82a82fdfaabcc77182f40.tar.bz2
android_packages_apps_Snap-e4600fca519144d8d9b82a82fdfaabcc77182f40.zip
Allow prefetch for cache, reducing priority for prefetched images.
Bug 8446191 Required for I86cfa59f448daa4e7b9fd7ea9ada2d69357e1f63 Change-Id: I7cccfffc539988d26fc751e16726b05fb2ba21bd
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/photos/data/MediaCache.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/com/android/photos/data/MediaCache.java b/src/com/android/photos/data/MediaCache.java
index 9cf69d643..0952a4017 100644
--- a/src/com/android/photos/data/MediaCache.java
+++ b/src/com/android/photos/data/MediaCache.java
@@ -107,6 +107,8 @@ public class MediaCache {
void notifyReady();
void setFile(File file) throws FileNotFoundException;
+
+ boolean isPrefetch();
}
private static class NotifyOriginalReady implements NotifyReady {
@@ -119,13 +121,20 @@ public class MediaCache {
@Override
public void notifyReady() {
- mCallback.originalReady(mFile);
+ if (mCallback != null) {
+ mCallback.originalReady(mFile);
+ }
}
@Override
public void setFile(File file) {
mFile = file;
}
+
+ @Override
+ public boolean isPrefetch() {
+ return mCallback == null;
+ }
}
private static class NotifyImageReady implements NotifyReady {
@@ -138,7 +147,9 @@ public class MediaCache {
@Override
public void notifyReady() {
- mCallback.imageReady(mInputStream);
+ if (mCallback != null) {
+ mCallback.imageReady(mInputStream);
+ }
}
@Override
@@ -149,6 +160,11 @@ public class MediaCache {
public void setBytes(byte[] bytes) {
mInputStream = new ByteArrayInputStream(bytes);
}
+
+ @Override
+ public boolean isPrefetch() {
+ return mCallback == null;
+ }
}
/** A media item to be retrieved and its notifications. */
@@ -496,7 +512,15 @@ public class MediaCache {
}
synchronized (tasks) {
ProcessingJob job = new ProcessingJob(uri, size, complete, lowResolution);
- tasks.add(job);
+ if (complete.isPrefetch()) {
+ tasks.add(job);
+ } else {
+ int index = tasks.size() - 1;
+ while (index >= 0 && tasks.get(index).complete.isPrefetch()) {
+ index--;
+ }
+ tasks.add(index + 1, job);
+ }
tasks.notifyAll();
}
}