diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-29 08:25:07 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-29 08:25:07 -0800 |
commit | 5217ddbb34b830978f414e5bec75571498178520 (patch) | |
tree | 95cbf0dcbc81217196b3ad3b6e012ef79df25be6 | |
parent | e34a99550b70f71ea490c5f17cf46e42d7ebcedd (diff) | |
download | dsub-5217ddbb34b830978f414e5bec75571498178520.tar.gz dsub-5217ddbb34b830978f414e5bec75571498178520.tar.bz2 dsub-5217ddbb34b830978f414e5bec75571498178520.zip |
Fix crash if existing drawable is null when creating layer
-rw-r--r-- | src/github/daneren2005/dsub/util/ImageLoader.java | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java index 41b4da03..9c87312a 100644 --- a/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/src/github/daneren2005/dsub/util/ImageLoader.java @@ -315,22 +315,25 @@ public class ImageLoader { TransitionDrawable tmp = (TransitionDrawable) existingDrawable; existingDrawable = tmp.getDrawable(tmp.getNumberOfLayers() - 1); } - - Drawable[] layers = new Drawable[] {existingDrawable, drawable}; - final TransitionDrawable transitionDrawable = new TransitionDrawable(layers); - imageView.setImageDrawable(transitionDrawable); - transitionDrawable.startTransition(250); - - // Get rid of transition drawable after transition occurs - handler.postDelayed(new Runnable() { - @Override - public void run() { - // Only execute if still on same transition drawable - if(imageView.getDrawable() == transitionDrawable) { - imageView.setImageDrawable(drawable); + if(existingDrawable != null && drawable != null) { + Drawable[] layers = new Drawable[]{existingDrawable, drawable}; + final TransitionDrawable transitionDrawable = new TransitionDrawable(layers); + imageView.setImageDrawable(transitionDrawable); + transitionDrawable.startTransition(250); + + // Get rid of transition drawable after transition occurs + handler.postDelayed(new Runnable() { + @Override + public void run() { + // Only execute if still on same transition drawable + if (imageView.getDrawable() == transitionDrawable) { + imageView.setImageDrawable(drawable); + } } - } - }, 500L); + }, 500L); + } else { + imageView.setImageDrawable(drawable); + } } else { imageView.setImageDrawable(drawable); } |