android - Universal Image Loader - Use same image in multiple views -
i'm using universal image loader load images backend display user images in list; however, if icon shows multiple times, universal image loader doesn't fill out views.
- [user image 1] - no image
- [user image 1] - no image
- [user image 2] - fine
- [user image 2] - no image
- [user image 3] - fine
- [user image 1] - fine
and on screen:
- [user image 1] - fine
- [user image 1] - no image
i'm using cacheinmemory , cacheondisk, seemed improve it. before displaying in 1 of views, instead of most, need of them work.
displayimageoptions defaultoptions = new displayimageoptions.builder() .cacheinmemory( true ) .cacheondisk( true ) .build(); imageloaderconfiguration config = new imageloaderconfiguration.builder( ) .threadpoolsize( 3 ) .defaultdisplayimageoptions( defaultoptions ) .build(); imageloader.getinstance().init( config );
i'm not using listview task, i'm using scrollview , inflating custom layout.
private view createsmallactivity( layoutinflater inflater, final event activity ) { final view view; view = inflater.inflate( r.layout.activity_posted_small, null ); ... // owner's image. if( activity.ownerimageurl != null ) { loader.loadimage( getactivity(), activity.ownerimageurl, r.drawable.postedactivitysmall_imageprofileempty, ( imageview ) view.findviewbyid( r.id.profileimage ) ); } return view; } // loader.loadimage // setting targetsize, , masking image resource. public static void loadimage( context context, string url, int resource, imageview view ) { drawable d = context.getresources().getdrawable( resource ); int h = d.getintrinsicheight(); int w = d.getintrinsicwidth(); imagesize targetsize = new imagesize( w, h ); imageloader.getinstance().loadimage( url, targetsize, new maskimageloader( context, view, resource ) ); }
any idea on how can improve universal image loader ensure views correctly filled out?
thanks help!
it's because universal image loader cancel previous requests same url (used id). prevent behaviour, replace
imageloader.getinstance().loadimage( url, targetsize, new maskimageloader( context, view, resource ) );
by
imageloader.getinstance().displayimage(url, new nonviewaware(new imagesize(w, h), viewscaletype.crop), new maskimageloader(context, view, resource));
Comments
Post a Comment