I am uploading some files with retrofit2. Using post method. while uploading i want to show a progress bar.
below I am showing a snipper , for a non multipart request to show how I am using the retrofit.
HashMap<String, String> map = new HashMap<>();
map.put("post_id", id);
String header = "";
if (MethodClass.isStudent()){
header = "bearer "+PreferenceFile.getStudent().getResult().getToken();
}
if (!NetWorkChecker.check(getContext()))
return;
CustomProgressbar.showProgressBar(getContext(), false);
ApiInterface apiInterface = ApiClient.getClient().create(ApiInterface.class);
Call<PostDetailsResponse> callMethod = apiInterface.STUDENT_PostDetailsResponse(header,MethodClass.Json_rpc_format_hashmap(map));
callMethod.enqueue(new Callback<PostDetailsResponse>() {
@Override
public void onResponse(Call<PostDetailsResponse> call, Response<PostDetailsResponse> response) {
CustomProgressbar.hideProgressBar();
if (MethodClass.hasError(getActivity(), response.body().getError())){
UpdateData(response.body().getResult());
}
}
@Override
public void onFailure(Call<PostDetailsResponse> call, Throwable t) {
CustomProgressbar.hideProgressBar();
}
});
Now instead of the custom progress bar, I want to show a progress in percent from 0 to 100; Ihave search a lot in statckoverflow but everyone is suggesting to show a dummmy progressbar with intermideate situation. but I want to show in percent. Please help .