summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2012-11-01 12:57:36 -0400
committerChris Wren <cwren@android.com>2012-11-01 12:57:36 -0400
commitb6c75a5e1a9dfc7753a451e97607510d37264374 (patch)
tree6fb727ccda1a7478567c1be879721b2c5addab07 /src
parent9ab175f5902c66a266261ccf191bc2d213918eca (diff)
downloadandroid_packages_screensavers_PhotoTable-b6c75a5e1a9dfc7753a451e97607510d37264374.tar.gz
android_packages_screensavers_PhotoTable-b6c75a5e1a9dfc7753a451e97607510d37264374.tar.bz2
android_packages_screensavers_PhotoTable-b6c75a5e1a9dfc7753a451e97607510d37264374.zip
don't reuse mOptions across threads.
Bug: 7370134 Change-Id: If6e02c2095f5f70e4dd506e651efbbd5ad47fa07
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dreams/phototable/PhotoCarousel.java14
-rw-r--r--src/com/android/dreams/phototable/PhotoTable.java18
2 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/dreams/phototable/PhotoCarousel.java b/src/com/android/dreams/phototable/PhotoCarousel.java
index 495e73c..70ba046 100644
--- a/src/com/android/dreams/phototable/PhotoCarousel.java
+++ b/src/com/android/dreams/phototable/PhotoCarousel.java
@@ -48,7 +48,6 @@ public class PhotoCarousel extends FrameLayout {
private final PhotoSourcePlexor mPhotoSource;
private final GestureDetector mGestureDetector;
private final View[] mPanel;
- private final BitmapFactory.Options mOptions;
private final int mFlipDuration;
private final int mDropPeriod;
private final int mBitmapQueueLimit;
@@ -100,8 +99,6 @@ public class PhotoCarousel extends FrameLayout {
mDropPeriod = resources.getInteger(R.integer.carousel_drop_period);
mBitmapQueueLimit = resources.getInteger(R.integer.num_images_to_preload);
mFlipDuration = resources.getInteger(R.integer.flip_duration);
- mOptions = new BitmapFactory.Options();
- mOptions.inTempStorage = new byte[32768];
mPhotoSource = new PhotoSourcePlexor(getContext(),
getContext().getSharedPreferences(FlipperDreamSettings.PREFS_NAME, 0));
mBitmapStore = new HashMap<View, Bitmap>();
@@ -130,6 +127,13 @@ public class PhotoCarousel extends FrameLayout {
}
private class PhotoLoadTask extends AsyncTask<Void, Void, Bitmap> {
+ private final BitmapFactory.Options mOptions;
+
+ public PhotoLoadTask () {
+ mOptions = new BitmapFactory.Options();
+ mOptions.inTempStorage = new byte[32768];
+ }
+
@Override
public Bitmap doInBackground(Void... unused) {
Bitmap decodedPhoto;
@@ -180,8 +184,8 @@ public class PhotoCarousel extends FrameLayout {
if (photo != null) {
ImageView destination = getBackface();
Bitmap old = mBitmapStore.get(destination);
- int width = mOptions.outWidth;
- int height = mOptions.outHeight;
+ int width = photo.getWidth();
+ int height = photo.getHeight();
int orientation = (width > height ? LANDSCAPE : PORTRAIT);
destination.setImageBitmap(photo);
diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java
index ddf2f58..50212c9 100644
--- a/src/com/android/dreams/phototable/PhotoTable.java
+++ b/src/com/android/dreams/phototable/PhotoTable.java
@@ -85,7 +85,6 @@ public class PhotoTable extends FrameLayout {
private PhotoLaunchTask mPhotoLaunchTask;
private boolean mStarted;
private boolean mIsLandscape;
- private BitmapFactory.Options mOptions;
private int mLongSide;
private int mShortSide;
private int mWidth;
@@ -114,8 +113,6 @@ public class PhotoTable extends FrameLayout {
mDropInterpolator = new DecelerateInterpolator(
(float) mResources.getInteger(R.integer.drop_deceleration_exponent));
mOnTable = new LinkedList<View>();
- mOptions = new BitmapFactory.Options();
- mOptions.inTempStorage = new byte[32768];
mPhotoSource = new PhotoSourcePlexor(getContext(),
getContext().getSharedPreferences(PhotoTableDreamSettings.PREFS_NAME, 0));
mLauncher = new Launcher(this);
@@ -242,6 +239,13 @@ public class PhotoTable extends FrameLayout {
}
private class PhotoLaunchTask extends AsyncTask<Void, Void, View> {
+ private final BitmapFactory.Options mOptions;
+
+ public PhotoLaunchTask () {
+ mOptions = new BitmapFactory.Options();
+ mOptions.inTempStorage = new byte[32768];
+ }
+
@Override
public View doInBackground(Void... unused) {
log("load a new photo");
@@ -252,11 +256,11 @@ public class PhotoTable extends FrameLayout {
View photo = inflater.inflate(R.layout.photo, null);
ImageView image = (ImageView) photo;
Drawable[] layers = new Drawable[2];
- Bitmap decodedPhoto = table.mPhotoSource.next(table.mOptions,
+ Bitmap decodedPhoto = table.mPhotoSource.next(mOptions,
table.mLongSide, table.mShortSide);
- int photoWidth = table.mOptions.outWidth;
- int photoHeight = table.mOptions.outHeight;
- if (table.mOptions.outWidth <= 0 || table.mOptions.outHeight <= 0) {
+ int photoWidth = mOptions.outWidth;
+ int photoHeight = mOptions.outHeight;
+ if (mOptions.outWidth <= 0 || mOptions.outHeight <= 0) {
photo = null;
} else {
decodedPhoto.setHasMipMap(true);