android - Image not loading in google map marker using UiL -
i using universal-image-loader-1.9.5.jar
. trying display user image on marker. image not being displayed.
what have done .
uil initialization
imageloader = imageloader.getinstance(); defaultoptions = new displayimageoptions.builder() .showimageonloading(r.drawable.profile_image) // resource or drawable .showimageforemptyuri(r.drawable.profile_image) // resource or drawable .showimageonfail(r.drawable.profile_image) // resource or drawable .resetviewbeforeloading(false) // default .delaybeforeloading(1000) .cacheinmemory(false) // default .cacheondisk(false) // default .considerexifparams(false) // default .imagescaletype(imagescaletype.in_sample_power_of_2) // default .bitmapconfig(bitmap.config.argb_8888) // default .displayer(new simplebitmapdisplayer()) // default .handler(new handler()) // default .build(); file cachedir = storageutils.getcachedirectory(this); config = new imageloaderconfiguration.builder(this) .memorycacheextraoptions(480, 800) // default = device screen dimensions .diskcacheextraoptions(480, 800, null) .threadpoolsize(3) // default .threadpriority(thread.norm_priority - 2) // default .tasksprocessingorder(queueprocessingtype.fifo) // default .denycacheimagemultiplesizesinmemory() .memorycache(new lrumemorycache(2 * 1024 * 1024)) .memorycachesize(2 * 1024 * 1024) .memorycachesizepercentage(13) // default .diskcache(new unlimiteddiskcache(cachedir)) // default .diskcachesize(50 * 1024 * 1024) .diskcachefilecount(100) .diskcachefilenamegenerator(new hashcodefilenamegenerator()) // default .defaultdisplayimageoptions(displayimageoptions.createsimple()) // default .writedebuglogs() .build(); imageloader.init(config);
using infowindowadapter
googlemap.setinfowindowadapter(new mycustomadapterforitems()); public class mycustomadapterforitems implements infowindowadapter { private final view mycontentsview; mycustomadapterforitems() { mycontentsview = mainfragmentactivity.getlayoutinflater().inflate( r.layout.map_info_window_dialog, null); } @override public view getinfocontents(marker marker) { return null; } @override public view getinfowindow(marker marker) { try { jsonobject jsonmarker = new jsonobject(marker.getsnippet()); string name = jsonmarker.getstring("name"); double distance = jsonmarker.getdouble("distance"); string imagepath = jsonmarker.getstring("profile_pic_address"); string gender = jsonmarker.getstring("gender"); string birthdate = jsonmarker.getstring("birthdate"); age = hiapplication.getage(birthdate); textview tvname = ((textview) mycontentsview .findviewbyid(r.id.tvmapchatname)); textview tvage = ((textview) mycontentsview .findviewbyid(r.id.tvmapchatage)); textview tvdistance = ((textview) mycontentsview .findviewbyid(r.id.distance)); textview tvgender = (textview) mycontentsview.findviewbyid(r.id.tvchatgender); roundedimageview image = (roundedimageview) mycontentsview.findviewbyid(r.id.profile_pic); imageloader.displayimage(imagepath, image , defaultoptions , simpleloader); //image loading here tvname.settext(name); if(age == 0 ) tvage.settext(""); else tvage.settext(age+""); tvgender.settext(gender); tvdistance.settext(new decimalformat("##.##").format(distance)+ " km."); } catch (jsonexception e) { e.printstacktrace(); } return mycontentsview; } }
imageloadinglistener
private class simpleloader implements imageloadinglistener { @override public void onloadingcancelled(string arg0, view arg1) { log.d("d", "image cancelled"); } @override public void onloadingcomplete(string arg0, view view, bitmap bitmap) { log.d("d", "loading complete"); imageview imageview = (imageview) view; imageview.setimagebitmap(bitmap); } @override public void onloadingfailed(string arg0, view arg1, failreason arg2) { log.d("d", "image loading failed"); } @override public void onloadingstarted(string arg0, view arg1) { log.d("d", "image loading started"); } }
although logs show image loaded . here logs .
01-21 02:38:13.561: d/d(7832): image loading started 01-21 02:38:13.567: d/imageloader(7832): delay 1000 ms before loading... [http://192.168.1.9:8080/chatme_userimages/ttestttt@gmail.com.jpg_100x100] 01-21 02:38:14.568: d/imageloader(7832): start display image task [http://192.168.1.9:8080/chatme_userimages/ttestttt@gmail.com.jpg_100x100] 01-21 02:38:14.569: d/imageloader(7832): load image network [http://192.168.1.9:8080/chatme_userimages/ttestttt@gmail.com.jpg_100x100] 01-21 02:38:14.653: d/imageloader(7832): display image in imageaware (loaded network) [http://192.168.1.9:8080/chatme_userimages/ttestttt@gmail.com.jpg_100x100] 01-21 02:38:14.653: d/d(7832): loading complete
but default drawb r.drawable.profile_image
showing time. can tell me , missing here ? whats wrong code ?
*you should create custom xml layout file , inflate in method getinfocontents(marker arg0)
your image prepared not getting loaded on marker think.
try this
@override public view getinfocontents(marker arg0) { // getting view layout file info_window_layout view v = getlayoutinflater().inflate(r.layout.info_window_layout, null); // getting position marker latlng latlng = arg0.getposition(); // getting reference textview set latitude textview tvlat = (textview) v.findviewbyid(r.id.tv_lat); // getting reference textview set longitude textview tvlng = (textview) v.findviewbyid(r.id.tv_lng); // setting latitude tvlat.settext("latitude:" + latlng.latitude); // setting longitude tvlng.settext("longitude:"+ latlng.longitude); // returning view containing infowindow contents return v; } });
Comments
Post a Comment