in rides-android/src/main/java/com/uber/sdk/android/rides/internal/RideRequestButtonController.java [139:178]
private void loadTimeEstimate(
@NonNull final TimeDelegate delegate,
final float latitude,
final float longitude,
@Nullable final String productId) {
timeEstimateCall = ridesService.getPickupTimeEstimate(latitude, longitude, productId);
timeEstimateCall.enqueue(new Callback<TimeEstimatesResponse>() {
@Override
public void onResponse(Call<TimeEstimatesResponse> call, Response<TimeEstimatesResponse> response) {
final ApiError apiError = ErrorParser.parseError(response);
if (apiError != null) {
delegate.finishWithError(apiError);
return;
}
final List<TimeEstimate> estimates = response.body().getTimes();
if (estimates == null || estimates.size() < 1) {
delegate.finishWithError(createProductNoFoundError());
return;
}
final TimeEstimate timeEstimate =
(productId == null) ? estimates.get(0) : findTimeEstimate(productId, estimates);
if (timeEstimate == null) {
delegate.finishWithError(createProductNoFoundError());
return;
}
delegate.onTimeReceived(timeEstimate);
}
@Override
public void onFailure(Call<TimeEstimatesResponse> call, Throwable throwable) {
delegate.finishWithError(throwable);
}
});
}