You can use the user interface. If you pass the interface as a parameter to the bookmark method, you can use it.
try something like:
public interface BookmarkCallback{ void onSuccess(boolean value); void onError(); }
your method should look like this:
public void bookmark(final BookmarkCallback callback){ Call<Response> call = service.bookmark(token, request); call.enqueue(new Callback<Response>() { @Override public void onResponse(Call<Response> call, retrofit2.Response<Response> response) { callback.onSuccess(true); } @Override public void onFailure(Call<Response call, Throwable t) { callback.onError(); } });
When you call this method, you need to pass one callback instance.
source share