diff options
-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); } |