summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-10-03 15:01:20 -0400
committerChris Wren <cwren@android.com>2012-10-03 15:01:20 -0400
commit58e2a16d9237d2a5674a97062b5d614d8d397845 (patch)
tree85eb0a93688636c73ecbb1c9f749a592ca030b17 /src
parent89ada9791087c8004f300ddd9e8ba58fbc84eaae (diff)
downloadandroid_packages_screensavers_PhotoTable-58e2a16d9237d2a5674a97062b5d614d8d397845.tar.gz
android_packages_screensavers_PhotoTable-58e2a16d9237d2a5674a97062b5d614d8d397845.tar.bz2
android_packages_screensavers_PhotoTable-58e2a16d9237d2a5674a97062b5d614d8d397845.zip
look harder for images to load.
Bug: 7242346 Change-Id: I729286685d7cd19a68e9db5f428ff714f3d2775c
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dreams/phototable/PhotoSource.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/com/android/dreams/phototable/PhotoSource.java b/src/com/android/dreams/phototable/PhotoSource.java
index 21c6646..62c0f4f 100644
--- a/src/com/android/dreams/phototable/PhotoSource.java
+++ b/src/com/android/dreams/phototable/PhotoSource.java
@@ -74,6 +74,7 @@ public abstract class PhotoSource {
private final LinkedList<ImageData> mImageQueue;
private final int mMaxQueueSize;
private final float mMaxCropRatio;
+ private final int mBadImageSkipLimit;
private final PhotoSource mFallbackSource;
protected final Context mContext;
@@ -97,6 +98,7 @@ public abstract class PhotoSource {
mImageQueue = new LinkedList<ImageData>();
mMaxQueueSize = mResources.getInteger(R.integer.image_queue_size);
mMaxCropRatio = mResources.getInteger(R.integer.max_crop_ratio) / 1000000f;
+ mBadImageSkipLimit = mResources.getInteger(R.integer.bad_image_skip_limit);
mRNG = new Random();
mFallbackSource = fallbackSource;
}
@@ -111,18 +113,23 @@ public abstract class PhotoSource {
public Bitmap next(BitmapFactory.Options options, int longSide, int shortSide) {
log(TAG, "decoding a picasa resource to " + longSide + ", " + shortSide);
Bitmap image = null;
+ int tries = 0;
- if (mImageQueue.isEmpty()) {
- fillQueue();
- }
+ while (image == null && tries < mBadImageSkipLimit) {
+ if (mImageQueue.isEmpty()) {
+ fillQueue();
+ }
+
+ if (!mImageQueue.isEmpty()) {
+ image = load(mImageQueue.poll(), options, longSide, shortSide);
+ }
- if (!mImageQueue.isEmpty()) {
- image = load(mImageQueue.poll(), options, longSide, shortSide);
+ tries++;
}
if (image == null && mFallbackSource != null) {
image = load((ImageData) mFallbackSource.findImages(1).toArray()[0],
- options, longSide, shortSide);
+ options, longSide, shortSide);
}
return image;