private void loadPriceEstimate()

in rides-android/src/main/java/com/uber/sdk/android/rides/internal/RideRequestButtonController.java [180:225]


    private void loadPriceEstimate(
            final float startLatitude,
            final float startLongitude,
            final float endLatitude,
            final float endLongitude,
            final @Nullable String productId,
            final TimePriceDelegate delegate) {

        priceEstimateCall = ridesService.getPriceEstimates(startLatitude, startLongitude,
                endLatitude, endLongitude);

        priceEstimateCall.enqueue(new Callback<PriceEstimatesResponse>() {
            @Override
            public void onResponse(
                    Call<PriceEstimatesResponse> call,
                    Response<PriceEstimatesResponse> response) {

                ApiError apiError = ErrorParser.parseError(response);
                if (apiError != null) {
                    delegate.finishWithError(apiError);
                    return;
                }

                final List<PriceEstimate> estimates = response.body().getPrices();
                if (estimates == null || estimates.size() < 1) {
                    delegate.finishWithError(createProductNoFoundError());
                    return;
                }

                final PriceEstimate priceEstimate =
                        (productId == null) ? estimates.get(0) : findPriceEstimate(productId, estimates);

                if (priceEstimate == null) {
                    delegate.finishWithError(createProductNoFoundError());
                    return;
                }

                delegate.onPriceReceived(priceEstimate);
            }

            @Override
            public void onFailure(Call<PriceEstimatesResponse> call, Throwable throwable) {
                delegate.finishWithError(throwable);
            }
        });
    }