I scroll through the official documentation of Retrofit and decided to implement something like this in my project, so that the user always has the option to cancel the download file and everything would work correctly. Implement appropriate methods, where the failure to prescribe the following:
service.upload1(file1, str, stringMap, new Callback<ImageUpload>() {
@Override
public void success(final ImageUpload imageUpload, Response response) {
mRecyclerView.post(new Runnable() {
@Override
public void run() {
...
});
}
@Override
public void failure(RetrofitError error) {
if (error.isCanceled()) {
Log.e(TAG, "request is cancelled");
} else {
Log.e(TAG, "other larger issue, i.e. no network connection?");
}
}
But underlines in red isCanceled in failure method. I do not understand what's the problem, because this method we initially proposed class Call(perhaps because swears at me instead of class Call is RetrofitError?) Please tell me how to fix. I use retrofit 1.9, and i don't need go on retrofit 2.