diff options
author | Chris Wren <cwren@android.com> | 2012-10-03 12:19:09 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-03 12:19:10 -0700 |
commit | c6260b066ebe4817b8ae109e9e69ca169ca2fe05 (patch) | |
tree | f29d8921d4a9d9656bf62e02dd973cec3c03f610 /src | |
parent | 78db95a5df64acdd81983db8cc48b4be302edf49 (diff) | |
parent | 58e2a16d9237d2a5674a97062b5d614d8d397845 (diff) | |
download | android_packages_screensavers_PhotoTable-c6260b066ebe4817b8ae109e9e69ca169ca2fe05.tar.gz android_packages_screensavers_PhotoTable-c6260b066ebe4817b8ae109e9e69ca169ca2fe05.tar.bz2 android_packages_screensavers_PhotoTable-c6260b066ebe4817b8ae109e9e69ca169ca2fe05.zip |
Merge "look harder for images to load." into jb-mr1-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dreams/phototable/PhotoSource.java | 19 |
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; |