im trying to simulate a progress of the retrofit's call, so before of execute the call i start the progress in this way:
public void runSimulateProgress(final CustomDialogLoad d){
new Thread(new Runnable() {
@Override
public void run() {
if (d != null){
int progress = 0;
while (d.getProgress() < 99){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
progress = progress+10;
d.setProgress(progress);
}
}
}
}).start();
}
The CustomDialogLoad is a Dialog with a progress and TextView.
So, when the call ends, i want to set progress to 100, but the progressBar doesn't change, i have tried to make any change of progress in a manual way but the progressBar doesn't want to update.
Here's the code of retrofit's call
dialogProgress.runSimulateProgress(dialogProgress);
final SaveRutaVisitaService saveRutaVisitaService = restAdapter.create(SaveRutaVisitaService.class);
saveRutaVisitaService.saveRutaVisita(multipartTypedOutput, new Callback<Response>() {
@Override
public void success(Response result, Response response) {
dialogProgress.setProgress(100)
} @Override
public void failure(RetrofitError retrofitError) {
dialogProgress.setProgress(100)}
}
I tried to make real progress based on this question
Android Retrofit - onProgressUpdate for showing Progress Notification
but doesn't work to me with multiPart
I appreciate any help
regards
EDIT: i added the "post" to update the progress but still not working
public void setProgress(final int p){
mRingProgressBar.post(new Runnable() {
@Override
public void run() {
mRingProgressBar.setProgress(p);
}
});
}
that method is inside of CustomDialogLoad class