I am using the ion library to download the json object response from php web services. I am using it this way :
Ion.with(getActivity())
.load("http://amd.com/loginService.php")
.progressBar(progressBar).progress(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
int mProgress = (int) (100 * downloaded / total);
progressBar.setProgress(mProgress);
}
})
.setMultipartParameter("fb_id", id)
.setMultipartParameter("fb_token", AccessToken.getCurrentAccessToken().toString())
.asJsonObject()
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (result == null) {
Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show();
progressBar.setVisibility(View.GONE);
} else {
Log.v("IonResult", result.toString());
progressBar.setVisibility(View.GONE);
}
}
});
Now I want to ask two questions:
How can I show the "please wait" and the progress bar in a good manner? The progress bar should appear and then disappear when the response of server has been achieved.
How to parse the json which I am getting in response? I have logged my results like this
Log.v("IonResult", result.toString());
and I can see the response, but how can I use it and parse it and get the items I want?
Please help, I know it is a basic question, but as I am beginner in Android, please help me improve. Thanks.