java - Display ProgressDialog from non-activity Volley class -


i trying display progressdialog while app getting data web service. call method in mapsactivity (main activity) when datacontroller done adding objects parsing web service.

in code nothing happens (i.e. no progressdialog appears) , i'm stuck on how let mapsactivity know objects have been created.

as can see i've tried make progressdialog appear

pd.show(context, "text", "text") 

mapsactivity.java

public class mapsactivity extends fragmentactivity {     private datacontroller controller = new datacontroller(mapsactivity.this);  @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_maps);         setupmapifneeded();          sharedpref = new sharedpreference(mapsactivity.this);         storedlikes = controller.readlike(sharedpref);         //this runs getlikedpos() in datacontroller          /lots of code.... 

datacontroller.java

public class datacontroller { // fields  public datacontroller(mapsactivity mapsactivity) {     this.context = mapsactivity; }  public void getlikedpos() {      this.url = geturl();      jsonobjectrequest jrequest = new jsonobjectrequest(request.method.get, url, null,             new response.listener<jsonobject>() {                  @override                 public void onresponse(jsonobject response) {                     try {                         progressdialog pd = progressdialog.show(context, "in progress", "loading");                         int success = response.getint("success");                          if (success == 1) {                             jsonarray ja = response.getjsonarray("spots");                              (int i=0; < ja.length(); i++) {                                 jsonobject spot = ja.getjsonobject(i);                                  location location = new location("");                                 location.setlatitude(spot.getdouble(like_lat));                                 location.setlongitude(spot.getdouble(like_long));                                  int id = spot.getint(like_id);                                  string time = spot.getstring(like_timestamp);                                 calendar parsedtime = convertdate(time);                                 likearr.add(new like(location, id, parsedtime));                             }                             system.out.println("size of likearr arraylist after parsing: " + likearr.size());                             pd.dismiss();                             //context.updatemap();   ??                         }                      } catch (jsonexception e) {                         e.printstacktrace();                         }                  }             }             , new response.errorlistener() {          @override         public void onerrorresponse(volleyerror error) {         }     }); 


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -