android - Image is not loading from web inside viewHolder's ImageView -


i trying make swipeable card app tinder. have used sample.

it working fine when getting images drawable resources, viewholder.cardimage not getting set when setting image web in it.

viewholder.cardimage not appearing @ all, although flingcontainer's events calling when called functions onbutton click.

not getting cue going wrong.

following code:

public class matchesfragmentplay extends fragment implements flingcardlistener.actiondowninterface {  private static final string tag = "matchesfragmentplay";  public static final string[] names = new string[] { "emily rose", "cherry", "anderson", "laius" }; public static final int[] ages = new int[] {20, 22, 25, 18 }; public static final int[] ratings = new int[] {8, 7, 7, 6 }; public static final integer[] images = { r.drawable.lady, r.drawable.lady2, r.drawable.lady3, r.drawable.lady4 }; public static final integer[] likes = { 0, 0, 0, 0 }; public static final integer[] dots = { r.id.rating_dot_one, r.id.rating_dot_two, r.id.rating_dot_three, r.id.rating_dot_four,         r.id.rating_dot_five, r.id.rating_dot_six, r.id.rating_dot_seven, r.id.rating_dot_eight,         r.id.rating_dot_nine, r.id.rating_dot_ten};  private callback networkcallback; private static string responseobj; private bitmap bitmap = null;  // new public static myappadapter myappadapter; public static viewholder viewholder; private arraylist<usermatchesplay> al; private swipeflingadapterview flingcontainer;  public static usermatchesplay obj;  public imageview matchesplaybackground; public textview matchesplayusername, matchesplayupgradetopremium; circleimageview matchesplaydislike, matchesplaylike;  @override public view oncreateview(layoutinflater inflater, @nullable viewgroup container,                          @nullable bundle savedinstancestate) {     view view  = inflater.inflate(r.layout.fragment_matches_play, container, false);      return view; }  @override public void onviewcreated(view view, @nullable bundle savedinstancestate) {     super.onviewcreated(view, savedinstancestate);      bundle inbundle = getactivity().getintent().getextras();     string fb_id = inbundle.get("fb_id").tostring();     log.d(tag, "fb_id: "+fb_id);     string name = inbundle.get("name").tostring();     string surname = inbundle.get("surname").tostring();     string imageurl = inbundle.get("imageurl").tostring();      flingcontainer = (swipeflingadapterview) view.findviewbyid(r.id.matches_play_frame);     matchesplaybackground = (imageview)view.findviewbyid(r.id.matches_play_background);     matchesplayusername = (textview) view.findviewbyid(r.id.matches_play_user_name);     matchesplayupgradetopremium = (textview) view.findviewbyid(r.id.matches_play_upgradetopremium);     matchesplaydislike = (circleimageview)view.findviewbyid(r.id.matches_play_dislike);     matchesplaylike = (circleimageview)view.findviewbyid(r.id.matches_play_like);      string premiumtext="for rating upgrade premium";     spannablestring content = new spannablestring(premiumtext);     content.setspan(new underlinespan(), 0, premiumtext.length(), 0);     matchesplayupgradetopremium.settext(content);      matchesplaydislike.setimageresource(r.drawable.dislike_enable);     matchesplaydislike.setbordercolor(color.parsecolor("#ffd1d5d9"));     matchesplaydislike.setborderwidth(5);     matchesplaylike.setimageresource(r.drawable.like_enable);     matchesplaylike.setbordercolor(color.parsecolor("#ffd1d5d9"));     matchesplaylike.setborderwidth(5);      matchesplaydislike.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             left();         }     });      matchesplaylike.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             right();         }     });      al = new arraylist<>();      networkcallback = new callback() {         @override         public void onprogress() {}          @override         public void onresult(string result) {             responseobj = result;             log.i(tag, "responsedata: "+responseobj);             jsonparser jsonparser = new jsonparser();             jsonelement element = jsonparser.parse(responseobj);             jsonobject usersobj, userobj;             jsonarray usersarray;             try {                 usersobj = new jsonobject(element.tostring());                 usersarray = usersobj.getjsonarray("users");                  (int i=0; i<usersarray.length(); i++){                      userobj = usersarray.getjsonobject(i);                      string [] _images = {userobj.getstring("img_path_1"), userobj.getstring("img_path_2"), userobj.getstring("img_path_3"), userobj.getstring("img_path_4"), userobj.getstring("img_path_5"), userobj.getstring("img_path_6")};                     al.add(new usermatchesplay(userobj.getstring("uid"), userobj.getstring("name"), userobj.getstring("age"), userobj.getstring("rate"), userobj.getstring("img_path_1"), "0"));                 }                 log.i(tag, "arraylist (size): "+al.size());                  myappadapter = new myappadapter(al, getactivity());                 flingcontainer.setadapter(myappadapter);                 myappadapter.notifydatasetchanged();                 flingcontainer.setflinglistener(new swipeflingadapterview.onflinglistener() {                     @override                     public void removefirstobjectinadapter() {                      }                      @override                     public void onleftcardexit(object dataobject) {                         al.remove(0);                         myappadapter.notifydatasetchanged();                         toast.maketext(getactivity(), "left swipe ", toast.length_short).show();                         //do on left!                         //you have access original object.                         //if want use cast (string) dataobject                      }                      @override                     public void onrightcardexit(object dataobject) {                          al.remove(0);                         myappadapter.notifydatasetchanged();                         toast.maketext(getactivity(), "right swipe ", toast.length_short).show();                     }                      @override                     public void onadapterabouttoempty(int itemsinadapter) {                      }                      @override                     public void onscroll(float scrollprogresspercent) {                          view view = flingcontainer.getselectedview();                      }                 });                  flingcontainer.setonitemclicklistener(new swipeflingadapterview.onitemclicklistener() {                     @override                     public void onitemclicked(int itemposition, object dataobject) {                          view view = flingcontainer.getselectedview();                         toast.maketext(getactivity(), "clicked: "+itemposition+" "+string.valueof(dataobject),toast.length_short).show();                          usermatchesplay usermatchesplay = obj;                         intent intent = new intent(getactivity(), profileactivity.class);                         intent.putextra("user_matches_play_obj", usermatchesplay);                         startactivity(intent);                          myappadapter.notifydatasetchanged();                     }                 });              } catch (jsonexception e) {                 e.printstacktrace();             }          }          @override         public void oncancel() {             // todo auto-generated method stub          }     };      httpasynctask asynctask = new httpasynctask(getactivity(), networkcallback, null, null, "get");     asynctask.execute(config.get_users_by_lat_lng+fb_id);  }   @override public void onactiondownperform() {     log.e("action", "bingo"); }  public void right() {     flingcontainer.gettopcardlistener().selectright(); }  public void left() {     flingcontainer.gettopcardlistener().selectleft(); }  public static class viewholder {      public imageview cardimage;     public framelayout background_frame; }  public class myappadapter extends baseadapter {      public list<usermatchesplay> parkinglist;     public context context;      private myappadapter(list<usermatchesplay> apps, context context) {         this.parkinglist = apps;         this.context = context;     }       @override     public int getcount() {         return parkinglist.size();     }      @override     public object getitem(int position) {         return position;     }      @override     public long getitemid(int position) {         return position;     }      @targetapi(build.version_codes.jelly_bean)     @override     public view getview(final int position, view convertview, viewgroup parent) {          view rowview = convertview;          if (rowview == null) {             system.out.println("rootview null");             layoutinflater inflater = getactivity().getlayoutinflater();             rowview = inflater.inflate(r.layout.match_play_image_item, parent, false);              viewholder = new viewholder();             viewholder.background_frame = (framelayout) rowview.findviewbyid(r.id.matches_play_item_frame);             viewholder.cardimage = (imageview) rowview.findviewbyid(r.id.cardimage);             rowview.settag(viewholder);          } else {             system.out.println("rootview not null");             viewholder = (viewholder) convertview.gettag();         }          string text = parkinglist.get(0).getname()+" ("+parkinglist.get(0).getage()+" years)";         system.out.println("text: "+text);         matchesplayusername.settext(text);          log.d(tag, (viewholder.cardimage == null)+ " img_path: "+config.img_link_1+parkinglist.get(position).getimage());          new downloadimage(viewholder.cardimage).execute(config.img_link_1+parkinglist.get(position).getimage());          glide.with(getactivity()).load(config.img_link_1+parkinglist.get(position).getimage()).into(viewholder.cardimage);          return rowview;     } }} 


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -