I am using retrofit API to fetch data from my backend:
OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
.callTimeout(2, TimeUnit.MINUTES)
.connectTimeout(2, TimeUnit.MINUTES)
.readTimeout(3, TimeUnit.MINUTES)
.writeTimeout(3, TimeUnit.MINUTES);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(server_interface.JSONURL)
.addConverterFactory(ScalarsConverterFactory.create())
.client(httpClient.build())
.build();
server_interface api = retrofit.create(server_interface.class);
Call<String> call = api.fetch_details();
if (call != null) {
call.enqueue(new Callback<String>() {
//The user should be able to see a dialog that shows that
he/she has to wait for x minutes to get the data
@Override
public void onResponse(Call<String> call, Response<String> response) {
}
@Override
public void onFailure(@NonNull Call<String> call, Throwable t) {
}
}
}
I want to show the user that they have to wait for x minutes to see the response. How do I calculate that time?