hospitalListClient.getHospitalDistances(params).enqueue(new Callback<DistanceResult>() {
@Override
public void onResponse(@NonNull Call<DistanceResult> call, @NonNull Response<DistanceResult> response) {
distanceResult = response.body();
if(distanceResult != null){
ArrayList<DistanceDuration> distanceDurations = distanceResult.getRows().get(0).getElements();
if(distanceDurations == null)
return;
for(int i=0; i<distanceDurations.size(); i++){
DistanceDuration d = distanceDurations.get(i);
// Log.d(TAG, "onResponse: distance"+d.getDistance().getText());
// Log.d(TAG, "onResponse: duration"+d.getDuration().getText());
placeList.places.get(i).setDistance(d.getDistance().getValue());
placeList.places.get(i).setDistanceString(d.getDistance().getText());
placeList.places.get(i).setTimeMinutes(d.getDuration().getValue());
placeList.places.get(i).setTimeString(d.getDuration().getText());
}
}
else{
Toast.makeText(ctx, "Unable to fetch data from the server. Please try again later",Toast.LENGTH_SHORT).show();
}
}
```