public static ImageListener getImageListener ( final ImageView view , final int defaultImageResId , final int errorImageResId ) { return new ImageListener ( ) { @ Override public void onError ( JusError error ) { if ( errorImageResId != 0 ) { view . setImageResource ( errorImageResId ) ; } } @ Override public void onResponse ( ImageContainer response , boolean isImmediate ) { if ( response . getBitmap ( ) != null ) { view . setImageBitmap ( response . getBitmap ( ) ) ; } else if ( defaultImageResId != 0 ) { view . setImageResource ( defaultImageResId ) ; } } } ; }
The default implementation of ImageListener which handles basic functionality of showing a default image until the network response is received at which point it will switch to either the actual image or the error image .