Skip to content

Instantly share code, notes, and snippets.

@StlTenny
Created June 14, 2012 15:07
Show Gist options
  • Save StlTenny/2930898 to your computer and use it in GitHub Desktop.
Save StlTenny/2930898 to your computer and use it in GitHub Desktop.
RestService ProgressDialog Example
RestService restServiceG;
//Create the progress dialog and show it, before running your restService request
Final ProgressDialog dialog = new ProgressDialog(mContext);
dialog.setMessage("Please wait.. Retrieving");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.show();
//Create your rest service request, load the parameters, and execute
restServiceG = new RestService(mHandlerGet, this, "http://192.168.1.27:3000/bars/"); //Create new rest service for get
restServiceG.addParam("lat", "40764917"); //Add params to request
restServiceG.addParam("lng", "-73983130");
restServiceG.addParam("range", "10");
restService.execute(RestService.GET);
//Simultaneously create your handler that will be called once the request is finished
//In this case, hide the previous progress dialog box.
private final Handler mHandlerGet = new Handler(){
@Override
public void handleMessage(Message msg){
resolveQuery(result);
dialog.hide();
};
//Method to manipulate your result here.
resolveQuery(String Result){
//Do whatever you want with your query result here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment