android - How to set Image from another api using Retrofit 1.9 in recyclerview -
i using retrofit 1.9 fetch data rest api show in recyclerview. far geting necessary information user. want show image of users on recyclerview. user information have 1 api. "https://sample.app.com/api/user". in api not have image field. collect user image have api "https://sample.app.com/api/profileimage/"+mail.i trying add image using 'com.squareup.picasso:picasso:2.5.2' . after running program , cannot see thing on recyclerview.
here model class user. mention no impage filed there in json file.
user api
[ { "_id": "588797978", "dn": "cndfgdfgdfg", "sn": "das", "title": "title", "givenname": "tom", "whenchanged": "20170623093215.0z", "company": "company limited", "name": "soutrik das", "mail": "mail@com.de", "mobile": "+123456", "updated_at": "2016-12-09t13:37:55.721z" }, ... ]
my model class is
public class colleaguemodel { public string _id, dn, givenname, whenchanged, name, mail, updatedat, sn, title, department, company, mobile; .............. }
i ma giving portion of adpater class
@override public void onbindviewholder(colleagueholder holder, int position) { final colleaguemodel currentcolleague = mcolleague.get(position); picasso.with(holder.itemview.getcontext()); holder.colleaguename.settext(currentcolleague.name); holder.companyname.settext(currentcolleague.company); holder.jobtitle.settext(currentcolleague.title); picasso.with(holder.itemview.getcontext()).load( constants.http.photo_url + currentcolleague.mail).into(holder.colleaguepicture); holder.cardview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent i=new intent(context,detailmycolleague.class); i.addflags(intent.flag_activity_new_task); i.putextra(/* here want send image*/ ) i.putextra("name",currentcolleague.name); i.putextra("title",currentcolleague.title); i.putextra("company",currentcolleague.company); i.putextra("mobile",currentcolleague.mobile); i.putextra("mail",currentcolleague.mail); i.putextra("department",currentcolleague.department); context.startactivity(i); } });
base url
public class constants { public static final class http { public static final string base_url = "https://sample.app.com"; public static final string photo_url = base_url + "/api/profileimage/"; } public static final class database{ } }
a portion of detail activity
intent intent = getintent(); //receive data name = intent.getextras().getstring("name"); int profileimage = intent.getintextra("image", 0); string title = intent.getextras().getstring("title"); string company = intent.getextras().getstring("company"); mobile = intent.getextras().getstring("mobile"); string mail = intent.getextras().getstring("mail"); string dept = intent.getextras().getstring("department"); //bind data _profilepic.setimageresource(profileimage); _profilename.settext(name); _colleaguename.settext(name); _mobile.settext(mobile); _mobile.setonclicklistener(this); _email.settext(mail); _email.setonclicklistener(this); _company.settext(company); _department.settext(dept); _jobrole.settext(title);
api service
public interface colleagueapiservice { @get("/api/users") void getcolleague(callback<string> flowers); }
holder class
@override public int getitemcount() { return mcolleague.size(); } public class colleagueholder extends recyclerview.viewholder{ public cardview cardview; public imageview colleaguepicture; public textview colleaguename; public textview companyname; public textview jobtitle; public colleagueholder(view itemview) { super(itemview); colleaguepicture= itemview.findviewbyid(r.id.colleague_picture); colleaguename= itemview.findviewbyid(r.id.colleague_name); companyname= itemview.findviewbyid(r.id.company_name); jobtitle= itemview.findviewbyid(r.id.job_title); cardview= itemview.findviewbyid(r.id.cardview_user); } }
how can add image in recyclerview using picasso.
log cat
08-20 11:57:03.798 1581-2750/? i/activitymanager: start u0 {cmp=demo.app.com.bluapp_client_and/.activity.mycolleague.mycolleaguespage} uid 10164 on display 0 08-20 11:57:03.869 29300-29304/demo.app.com.bluapp_client_and i/art: partial code cache collection, code=54kb, data=55kb 08-20 11:57:03.871 29300-29304/demo.app.com.bluapp_client_and i/art: after code cache collection, code=45kb, data=50kb 08-20 11:57:03.871 29300-29304/demo.app.com.bluapp_client_and i/art: increasing code cache capacity 256kb 08-20 11:57:03.882 29300-29332/demo.app.com.bluapp_client_and d/egl_emulation: eglmakecurrent: 0xa4c164a0: ver 2 0 (tinfo 0xa49536c0) 08-20 11:57:03.970 29300-29300/demo.app.com.bluapp_client_and d/controller: error :: com.google.gson.jsonsyntaxexception: com.google.gson.stream.malformedjsonexception: use jsonreader.setlenient(true) accept malformed json @ line 1 column 12 path $ 08-20 11:57:03.970 1581-1601/? i/activitymanager: displayed demo.app.com.bluapp_client_and/.activity.mycolleague.mycolleaguespage: +168ms 08-20 11:57:04.355 1581-1797/? i/windowmanager: destroying surface surface(name=demo.app.com.bluapp_client_and/demo.app.com.bluapp_client_and.activity.main.mainoptionpage) called com.android.server.wm.windowstateanimator.destroysurface:2014 com.android.server.wm.windowstateanimator.destroysurfacelocked:881 com.android.server.wm.windowstate.destroyorsavesurface:2073 com.android.server.wm.appwindowtoken.destroysurfaces:363 com.android.server.wm.appwindowtoken.notifyappstopped:389 com.android.server.wm
pass image url detail page
holder.cardview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent i=new intent(context,detailmycolleague.class); i.addflags(intent.flag_activity_new_task); i.putextra("image_url",constants.http.photo_url + currentcolleague.mail); i.putextra("name",currentcolleague.name); i.putextra("title",currentcolleague.title); i.putextra("company",currentcolleague.company); i.putextra("mobile",currentcolleague.mobile); i.putextra("mail",currentcolleague.mail); i.putextra("department",currentcolleague.department); context.startactivity(i); } });
and image
intent intent = getintent(); //receive data name = intent.getextras().getstring("name"); string profileimage = intent.getextras().getstring("image_url"); string title = intent.getextras().getstring("title"); string company = intent.getextras().getstring("company"); mobile = intent.getextras().getstring("mobile"); string mail = intent.getextras().getstring("mail"); string dept = intent.getextras().getstring("department"); //bind data picasso.with(this).load(profileimage).into(_profilepic); // _profilepic.setimageresource(profileimage); _profilename.settext(name); _colleaguename.settext(name); _mobile.settext(mobile); _mobile.setonclicklistener(this); _email.settext(mail); _email.setonclicklistener(this); _company.settext(company); _department.settext(dept); _jobrole.settext(title);
Comments
Post a Comment