public Drawable get ( ) { final Drawable [ ] drawables = new Drawable [ ] { mPlaceHolder , new BitmapDrawable ( mContext . getResources ( ) , Bitmap . createBitmap ( 1 , 1 , Bitmap . Config . ARGB_8888 ) ) , } ; final TransitionDrawable transitionDrawable = new TransitionDrawable ( drawables ) ; into ( new Callback ( ) { @ Override public void onBitmapLoaded ( String path , Bitmap bitmap ) { Log . d ( TAG , "callback " + path + " called" ) ; if ( bitmap != null ) { Log . d ( TAG , "bitmap " + path + " loaded" ) ; Drawable drawable = drawables [ 1 ] ; if ( drawable != null && drawable instanceof BitmapDrawable ) { BitmapDrawable bitmapDrawable = ( BitmapDrawable ) drawables [ 1 ] ; try { Method method = BitmapDrawable . class . getDeclaredMethod ( "setBitmap" , Bitmap . class ) ; method . setAccessible ( true ) ; method . invoke ( bitmapDrawable , bitmap ) ; Log . d ( TAG , "bitmap " + path + " added to transition" ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } transitionDrawable . startTransition ( 500 ) ; Log . d ( TAG , "image " + path + " transition started" ) ; } } } ) ; return transitionDrawable ; }
Load the bitmap into a TransitionDrawable Starts the treatment when loaded execute a transition