C'è un modo per sapere quando è terminata la mia chiamata di retrofit? Mi piace sapere quando tutti i dati sono ricevuti in modo che il codice possa passare, come iniziare un'altra attività o utilizzare i dati della prima chiamata per fare un secondo?Come sapere quando una chiamata di aggiornamento è terminata
Ps: sto utilizzando una richiesta asincrona (.enqueue).
Edit:
getContact(){
//Get a contact List from the server
Call<List<ModelContact>> callM = contactInterface.createRContact(listContact);
callM.enqueue(new Callback<List<ModelContact>>() {
@Override
public void onResponse(Response<List<ModelContact>> response, Retrofit retrofit) {
// Fetch the List from Response and save it on the local database
}
@Override
public void onFailure(Throwable t) {
Log.i("TAG", "Error: " + t.getMessage());
}
});
//Gets a object containing some configurations
Call<Configs> callC = contactInterface.getConfigs(Configs);
callC.enqueue(new Callback<Configs>() {
@Override
public void onResponse(Response<Configs> response, Retrofit retrofit) {
// Fetch the Configs object and save it on the database
}
@Override
public void onFailure(Throwable t) {
Log.i("TAG", "Error: " + t.getMessage());
}
});
//Here I need to start a new activity after the calls
Intent loginact = new Intent(TokenActivity.this, LoginActivity.class);
startActivity(loginact);
}
è possibile fornire un delegato per accodare (aka ascoltatore). – Blackbelt
Dove posso trovare un esempio di codice, l'ho creato e non ho trovato nulla ... – Rafael
perché non pubblichi il tuo tentativo? – Blackbelt