New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abstract class implementation Call<T> #1059
Comments
You need to add a |
Here's an example: public final class AppCall<T> implements Call<T> {
private final Call<T> delegate;
public AppCall(Call<T> delegate) {
this.delegate = delegate;
}
private void handleResponseBody(T body) {
// TODO whatever
}
@Override public Response<T> execute() throws IOException {
Response<T> response = delegate.execute();
if (response.isSuccess()) {
handleResponseBody(response.body());
}
return response;
}
@Override public void enqueue(final Callback<T> callback) {
delegate.enqueue(new Callback<T>() {
@Override public void onResponse(Response<T> response) {
if (response.isSuccess()) {
handleResponseBody(response.body());
}
callback.onResponse(response);
}
@Override public void onFailure(Throwable t) {
callback.onFailure(t);
}
});
}
@Override public void cancel() {
delegate.cancel();
}
@Override public Call<T> clone() {
return new AppCall<>(delegate.clone());
}
} Note the clone method and the fact that it also clones the |
Thank you! |
I tried to do the same thing, but I get this error:
and then
this is a piece of my code
what am I doing wrong? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is more of a question because I may be doing this wrong, but I have created a custom class because I wanted to add a few methods that are not part of Call (such as a tag so I can cancel the request from anywhere in my apps). Maybe there is a better approach to this, but my code follows and I receive the following error:
Error:(1822, 10) error: clone() in Object cannot implement clone() in Call
attempting to assign weaker access privileges; was public
where T is a type-variable:
T extends Object declared in interface Call
abstract class RemoteJSONServiceCall implements Call {
AMFParameters amfParameters = null;
}
private RemoteJSONServiceCall createRetrofitCall(final AMFParameters params) {
if (Connectivity.isConnected(visnetawrap)) {
RemoteJSONServiceCall newCall = amfService.amfcall(params);
newCall.amfParameters = params;
callsList.add(newCall);
return amfService.amfcall(params);
}
return null;
}
The text was updated successfully, but these errors were encountered: