@Test public void testImageViewTarget() { ImageViewCrossFadeAnimation anim = new ImageViewCrossFadeAnimation(); ImageView imageView = Mockito.mock(ImageView.class); boolean setsDirectly = anim.animate(imageView, new ColorDrawable(Color.BLUE), Mirage.Source.DISK); Assert.assertTrue(setsDirectly); Mockito.verify(imageView, Mockito.times(1)).getDrawable(); }
@Override public boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source) { if (source == Mirage.Source.MEMORY) return false; Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable == null) { currentDrawable = new ColorDrawable(Color.TRANSPARENT); } Drawable[] fades = new Drawable[2]; fades[0] = currentDrawable; fades[1] = targetDrawable; TransitionDrawable transitionDrawable = new TransitionDrawable(fades); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(duration); return true; }
ImageViewCrossFadeAnimation implements MirageAnimation<ImageView> { @Override public boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source) { if (source == Mirage.Source.MEMORY) return false; Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable == null) { currentDrawable = new ColorDrawable(Color.TRANSPARENT); } Drawable[] fades = new Drawable[2]; fades[0] = currentDrawable; fades[1] = targetDrawable; TransitionDrawable transitionDrawable = new TransitionDrawable(fades); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(duration); return true; } }
ImageViewCrossFadeAnimation implements MirageAnimation<ImageView> { @Override public boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source) { if (source == Mirage.Source.MEMORY) return false; Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable == null) { currentDrawable = new ColorDrawable(Color.TRANSPARENT); } Drawable[] fades = new Drawable[2]; fades[0] = currentDrawable; fades[1] = targetDrawable; TransitionDrawable transitionDrawable = new TransitionDrawable(fades); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(duration); return true; } ImageViewCrossFadeAnimation();  ImageViewCrossFadeAnimation(int duration); }
ImageViewCrossFadeAnimation implements MirageAnimation<ImageView> { @Override public boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source) { if (source == Mirage.Source.MEMORY) return false; Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable == null) { currentDrawable = new ColorDrawable(Color.TRANSPARENT); } Drawable[] fades = new Drawable[2]; fades[0] = currentDrawable; fades[1] = targetDrawable; TransitionDrawable transitionDrawable = new TransitionDrawable(fades); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(duration); return true; } ImageViewCrossFadeAnimation();  ImageViewCrossFadeAnimation(int duration); @Override boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source); }
ImageViewCrossFadeAnimation implements MirageAnimation<ImageView> { @Override public boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source) { if (source == Mirage.Source.MEMORY) return false; Drawable currentDrawable = imageView.getDrawable(); if (currentDrawable == null) { currentDrawable = new ColorDrawable(Color.TRANSPARENT); } Drawable[] fades = new Drawable[2]; fades[0] = currentDrawable; fades[1] = targetDrawable; TransitionDrawable transitionDrawable = new TransitionDrawable(fades); transitionDrawable.setCrossFadeEnabled(true); imageView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(duration); return true; } ImageViewCrossFadeAnimation();  ImageViewCrossFadeAnimation(int duration); @Override boolean animate(ImageView imageView, Drawable targetDrawable, Mirage.Source source);  }