Reputation: 6075
All calls and callbacks work fine. I just have an issue where I clone and retry a call within the callback (with the same callback) due to a http error code.
public static abstract class MyCallback<T> implements Callback<T> {
@Override
public void onResponse(Call<T> call, retrofit2.Response<T> response) {
Timber.d("is this the main thread %b", Looper.myLooper() == Looper.getMainLooper());
if (response.isSuccessful()) {
//success handling
} else {
if (response.code() == 406) {
// remedy reason for failure
call.clone().enqueue(MyCallback.this);
}
}
}
@Override
public void onFailure(Call<T> call, Throwable t) {
Timber.e("onFailure %s", t.getMessage());
}
}
This gives:
is this the main thread true
is this the main thread false
is this the main thread false
is this the main thread false
is this the main thread false
[looping]
I played around with other/new callbacks, starting a new call, etc. Only when I clone the call the callback is invoked off the main thread. The actual problem that arises is, that I can't change the UI after the successfully retried call.
Using Retrofit 2.0.1
Upvotes: 1
Views: 369
Reputation: 6075
This turned out to be a bug in retrofit. Jake Wharton just created a PR for this:
https://github.com/square/retrofit/issues/1716
Upvotes: 1