android - Display a Progress bar in a custom adapter while downloading with volley -


i display progressbar in custom adapter while downloading!

there adapter class

public class imageadapter extends baseadapter {      @override     public view getview(int position, view convertview, viewgroup parent) {         final viewholder holder;         if (convertview == null) {             holder = new viewholder();             convertview = ((activity) context).getlayoutinflater().inflate(layoutresourceid, parent, false);             holder.pictureview = (galerieimageview) convertview.findviewbyid(r.id.galerieview);             holder.progressbar = (progressbar) convertview.findviewbyid(r.id.progressbargalerie);             holder.progressbar.setvisibility(view.visible);             holder.progressbar.setindeterminate(true);             convertview.settag(holder);         } else {             holder = (viewholder) convertview.gettag();         }           imageloader imageloader = imagecachemanager.getinstance().getimageloader();         if (arraylist.get(position).getturl() != null) {             log.i("lien", "" + arraylist.get(position).getturl());             holder.pictureview.setimageurl(arraylist.get(position).getturl(), imageloader);             holder.pictureview.setvisibility(view.visible);              holder.pictureview.setdefaultimageresid(r.drawable.ico_loading);             holder.pictureview.seterrorimageresid(r.drawable.ico_error);             holder.pictureview.setlayoutparams(new relativelayout.layoutparams(imagewidth, imagewidth));             holder.pictureview                     .setresponseobserver(new galerieimageview.responseobserver() {                         @override                         public void onerror() {                             holder.progressbar.setvisibility(view.gone);                         }                          @override                         public void onsuccess() {                             holder.progressbar.setvisibility(view.gone);                          }                     });         } else {             //holder.pictureview.setvisibility(view.gone);         }         return convertview;     } } 

my custom networkview observer (galeryimageview) based on this stackoverflow answer. i'm unable display progress bar.

i doing this. wrapped progress bar in method on calling activity/fragment, not adapter itself. like:

public void startprogressbar() {     dialog = new progressdialog(this);     dialog.setindeterminate(true);     dialog.setcancelable(false);     dialog.setmessage("messgae");     dialog.show(); } 

dialog class member.

now when call volley, next call startprogressbar - , cancel dialog onreponse , onerror.

so becomes

dovolleycommand(url); startprogressbar(); 

in response handlers:

if (dialog != null && dialog.isshowing()) {      dialog.dismiss(); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -