Answer the question
In order to leave comments, you need to log in
How to call Callback() from Fragment for Retrofit?
How to call Callback() from Fragment to call Retrofit call interface?
In the fragment in onCreateView I wrote:
// Создаем адаптер с базовым адресом
RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(SOURCE).build();
// Создаём сервис
API api = restAdapter.create(API.class);
api.getCinema(API_TOKEN, new Callback() {
@Override
public void success(KinoModel kinoModel, Response response) {
// Получаем ввиде json и конвертируем
cinemas.add(new Cinema(kinoModel.getTitleRU()));
}
@Override
public void failure(RetrofitError error) {
Log.d("myLogs", "Failed!!!");
}
});
public interface API
{
@GET("/serial_updates.json")
void getCinema(@Query("api_token") String api_token, Callback response);
}
is not abstract and does not override abstract method success(Object,Response) in Callback
Answer the question
In order to leave comments, you need to log in
Callback is generic. You didn't parametrize it.new Callback<KinoModel>(){ ... }
in what format does retrofit get the result when the array updates???
tried to do so
@Expose
private List<Upd> updates;
public List<Upd> getUpdates()
{
return updates;
}
public class Upd {
@SerializedName("title_ru")
private String title_ru;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question