diff options
author | Clark Scheff <clark@cyngn.com> | 2014-05-16 14:32:28 -0700 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2014-05-16 14:32:28 -0700 |
commit | 0f1b3dc4d022dc8af5cf0c63fc58f891df147383 (patch) | |
tree | e63d04d714498adef3aa00b2853cc531d6050f2c | |
parent | abf8ea82b4a80f949389acb58871d77bee4c730d (diff) | |
download | packages_apps_ThemeChooser-0f1b3dc4d022dc8af5cf0c63fc58f891df147383.zip packages_apps_ThemeChooser-0f1b3dc4d022dc8af5cf0c63fc58f891df147383.tar.gz packages_apps_ThemeChooser-0f1b3dc4d022dc8af5cf0c63fc58f891df147383.tar.bz2 |
Don't rely on dimensions given in desc.txt
It is possible for a boot animation to have images that are not
the same dimensions as those given in the desc.txt. For this
reason we should not rely on those dimensions when allocating
bitmaps.
Change-Id: Ic4996c419d542bdcfbec5ebf6df3c9d6364e5af6
-rw-r--r-- | src/org/cyanogenmod/theme/util/BootAnimationHelper.java | 2 | ||||
-rw-r--r-- | src/org/cyanogenmod/theme/widget/BootAniImageView.java | 53 |
2 files changed, 24 insertions, 31 deletions
diff --git a/src/org/cyanogenmod/theme/util/BootAnimationHelper.java b/src/org/cyanogenmod/theme/util/BootAnimationHelper.java index b594fe5..a3bdeaa 100644 --- a/src/org/cyanogenmod/theme/util/BootAnimationHelper.java +++ b/src/org/cyanogenmod/theme/util/BootAnimationHelper.java @@ -136,7 +136,7 @@ public class BootAnimationHelper { List<AnimationPart> animationParts = new ArrayList<AnimationPart>(); while ((line = reader.readLine()) != null) { String[] info = line.split(" "); - if (info.length == 4 && info[0].equals("p")) { + if (info.length == 4 && (info[0].equals("p") || info[0].equals("c"))) { int playCount = Integer.parseInt(info[1]); int pause = Integer.parseInt(info[2]); String name = info[3]; diff --git a/src/org/cyanogenmod/theme/widget/BootAniImageView.java b/src/org/cyanogenmod/theme/widget/BootAniImageView.java index 0eb0a05..4b16be3 100644 --- a/src/org/cyanogenmod/theme/widget/BootAniImageView.java +++ b/src/org/cyanogenmod/theme/widget/BootAniImageView.java @@ -80,11 +80,7 @@ public class BootAniImageView extends ImageView { return false; } - // pre-allocate bitmap buffers final BootAnimationHelper.AnimationPart part = mAnimationParts.get(0); - for (int i = 0; i < mBuffers.length; i++) { - mBuffers[i] = Bitmap.createBitmap(part.width, part.height, Bitmap.Config.RGB_565); - } mCurrentPart = 0; mCurrentPartPlayCount = part.playCount; mFrameDuration = part.frameRateMillis; @@ -95,28 +91,27 @@ public class BootAniImageView extends ImageView { } private void getNextFrame() { - synchronized (mBuffers[mWriteBufferIndex]) { - BitmapFactory.Options opts = new BitmapFactory.Options(); - opts.inBitmap = mBuffers[mWriteBufferIndex]; - opts.inPreferredConfig = Bitmap.Config.RGB_565; - final BootAnimationHelper.AnimationPart part = mAnimationParts.get(mCurrentPart); - try { - BitmapFactory.decodeStream(mBootAniZip.getInputStream(mBootAniZip.getEntry( - part.frames.get(mCurrentFrame++))), null, opts); - } catch (Exception e) { - Log.w(TAG, "Unable to get next frame", e); - } - mWriteBufferIndex = (mWriteBufferIndex + 1) % MAX_BUFFERS; - if (mCurrentFrame >= part.frames.size()) { - if (mCurrentPartPlayCount > 0) { - if (--mCurrentPartPlayCount == 0) { - mCurrentPart++; - mCurrentFrame = 0; - mCurrentPartPlayCount = mAnimationParts.get(mCurrentPart).playCount; - } - } else { + BitmapFactory.Options opts = new BitmapFactory.Options(); + opts.inBitmap = mBuffers[mWriteBufferIndex]; + opts.inPreferredConfig = Bitmap.Config.RGB_565; + final BootAnimationHelper.AnimationPart part = mAnimationParts.get(mCurrentPart); + try { + mBuffers[mWriteBufferIndex] = + BitmapFactory.decodeStream(mBootAniZip.getInputStream(mBootAniZip.getEntry( + part.frames.get(mCurrentFrame++))), null, opts); + } catch (Exception e) { + Log.w(TAG, "Unable to get next frame", e); + } + mWriteBufferIndex = (mWriteBufferIndex + 1) % MAX_BUFFERS; + if (mCurrentFrame >= part.frames.size()) { + if (mCurrentPartPlayCount > 0) { + if (--mCurrentPartPlayCount == 0) { + mCurrentPart++; mCurrentFrame = 0; + mCurrentPartPlayCount = mAnimationParts.get(mCurrentPart).playCount; } + } else { + mCurrentFrame = 0; } } } @@ -130,12 +125,10 @@ public class BootAniImageView extends ImageView { @Override public void run() { if (!mActive) return; - synchronized (mBuffers[mReadBufferIndex]) { - BootAniImageView.this.postDelayed(mUpdateAnimationRunnable, mFrameDuration); - BootAniImageView.this.post(mUpdateImageRunnable); - mReadBufferIndex = (mReadBufferIndex + 1) % MAX_BUFFERS; - getNextFrame(); - } + BootAniImageView.this.postDelayed(mUpdateAnimationRunnable, mFrameDuration); + BootAniImageView.this.post(mUpdateImageRunnable); + mReadBufferIndex = (mReadBufferIndex + 1) % MAX_BUFFERS; + getNextFrame(); } }; |