diff options
author | Chris Wren <cwren@android.com> | 2012-10-12 15:32:46 -0400 |
---|---|---|
committer | Chris Wren <cwren@android.com> | 2012-10-15 17:11:12 -0400 |
commit | 5006d4093ad1455ee98c157a71f57e9ea42b4dae (patch) | |
tree | 35da5d8ccdaefc11f8070e03d9c67ee6e7351e16 /src/com/android/dreams/phototable/PhotoSource.java | |
parent | e8f4d55d6895e1f2bc298ef8978e1aef43ff57c5 (diff) | |
download | PhotoTable-5006d4093ad1455ee98c157a71f57e9ea42b4dae.tar.gz |
Better handling for network lag and large images.
Bug: 7339488
Change-Id: I3a26b30f766fc240e73e19c14a5ee14288bd4fb1
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoSource.java')
-rw-r--r-- | src/com/android/dreams/phototable/PhotoSource.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/com/android/dreams/phototable/PhotoSource.java b/src/com/android/dreams/phototable/PhotoSource.java index 62c0f4f..1fe6194 100644 --- a/src/com/android/dreams/phototable/PhotoSource.java +++ b/src/com/android/dreams/phototable/PhotoSource.java @@ -113,15 +113,19 @@ 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; + ImageData imageData = null; int tries = 0; while (image == null && tries < mBadImageSkipLimit) { - if (mImageQueue.isEmpty()) { - fillQueue(); - } + synchronized(mImageQueue) { + if (mImageQueue.isEmpty()) { + fillQueue(); + } + imageData = mImageQueue.poll(); + } if (!mImageQueue.isEmpty()) { - image = load(mImageQueue.poll(), options, longSide, shortSide); + image = load(imageData, options, longSide, shortSide); } tries++; @@ -211,10 +215,15 @@ public abstract class PhotoSource { log(TAG, "Stream decoding failed with no error" + (options.mCancel ? " due to cancelation." : ".")); } + } catch (OutOfMemoryError ome) { + log(TAG, "OUT OF MEMORY: " + ome); + image = null; } catch (FileNotFoundException fnf) { log(TAG, "file not found: " + fnf); + image = null; } catch (IOException ioe) { log(TAG, "i/o exception: " + ioe); + image = null; } finally { try { if (is != null) { |