android - UIL update cached images -
i want display facebook profile picture using url whenever user changes profile picture, library doesn't update cached image.
my uil version 1.9.3, display options:
new displayimageoptions.builder() .showimageonloading(android.r.color.white) .cacheinmemory(true) .cacheondisk(true) .considerexifparams(true) .build();
so how should check if image in url changed? or maybe know library have feature?
thanks!
uil has multithread image loading (async or sync). see library features on github.
you enable caching on disc (device's file system or sd card) .cacheondisk(true)
. library loads image cache. disable disc caching .cacheondisk(false)
, write following code in activity:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ... displayimageoptions displayoptions = new displayimageoptions.builder() .showimageonloading(r.drawable.ic_preview) .showimageforemptyuri(r.drawable.ic_preview) .showimageonfail(r.drawable.ic_preview) .cacheinmemory(true) .cacheondisc(false) .considerexifparams(true) .build(); imageloaderconfiguration config = new imageloaderconfiguration.builder(this) .writedebuglogs() .defaultdisplayimageoptions(displayoptions) .build(); imageloader imageloader = imageloader.getinstance(); imageloader.init(config); animatefirstdisplaylistener animate = new animatefirstdisplaylistener(); imageloader.displayimage(yourimageurl, useriv, animate); ... } public static class animatefirstdisplaylistener extends simpleimageloadinglistener { static final list<string> displayedimages = collections.synchronizedlist(new linkedlist<string>()); @override public void onloadingcomplete(string imageuri, view view, bitmap loadedimage) { if (loadedimage != null) { imageview imageview = (imageview) view; boolean firstdisplay = !displayedimages.contains(imageuri); if (firstdisplay) { fadeinbitmapdisplayer.animate(imageview, 500); displayedimages.add(imageuri); } } } }
Comments
Post a Comment