diff options
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoSource.java')
-rw-r--r-- | src/com/android/dreams/phototable/PhotoSource.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/android/dreams/phototable/PhotoSource.java b/src/com/android/dreams/phototable/PhotoSource.java index fc4cf7b..d05eace 100644 --- a/src/com/android/dreams/phototable/PhotoSource.java +++ b/src/com/android/dreams/phototable/PhotoSource.java @@ -23,6 +23,7 @@ import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; +import android.net.Uri; import android.util.Log; import java.io.BufferedInputStream; @@ -44,7 +45,7 @@ public abstract class PhotoSource { // This should be large enough for BitmapFactory to decode the header so // that we can mark and reset the input stream to avoid duplicate network i/o - private static final int BUFFER_SIZE = 128 * 1024; + private static final int BUFFER_SIZE = 32 * 1024; public class ImageData { public String id; @@ -54,6 +55,7 @@ public abstract class PhotoSource { protected String albumId; protected Cursor cursor; protected int position; + protected Uri uri; InputStream getStream(int longSide) { return PhotoSource.this.getStream(this, longSide); @@ -184,7 +186,15 @@ public abstract class PhotoSource { } log(TAG, "decoding with inSampleSize " + options.inSampleSize); - bis.reset(); + try { + bis.reset(); + } catch (IOException ioe) { + // start over, something went wrong and we read too far into the image. + bis.close(); + is = data.getStream(longSide); + bis = new BufferedInputStream(is); + log(TAG, "resetting the stream"); + } options.inJustDecodeBounds = false; image = BitmapFactory.decodeStream(bis, null, options); rawLongSide = Math.max(options.outWidth, options.outHeight); |