@Override public void searchPositionByCoordinates(final LatLng coordinates) { if (!connectionManager.isOnline()) { addressView.showConnectionProblemsDialog(); } else { addressView.showProgressDialog(); getAddressNameByCoordinatesUseCase.execute( coordinates, MAX_BY_COORD, new GetAddressUseCase.Callback() { @Override public void onAddressLoaded(final AddressCollection addressCollection) { addressView.hideProgressDialog(); if (addressCollection.getAddressList().isEmpty()) { addressView.showNoMatchesMessage(); } else { addressView.showPositionByCoordinates(addressCollection.getAddressList().get(0)); } } @Override public void onError(final String errorMessage) { addressView.hideProgressDialog(); addressView.showCallError(errorMessage); } }); } }
@Override public void searchPositionByName(final String locationName) { if (!connectionManager.isOnline()) { addressView.showConnectionProblemsDialog(); } else { addressView.showProgressDialog(); getAddressCoordinatesByNameUseCase.execute( locationName, MAX_BY_NAME, new GetAddressUseCase.Callback() { @Override public void onAddressLoaded(final AddressCollection addressCollection) { addressView.hideProgressDialog(); if (addressCollection.getAddressList().isEmpty()) { addressView.showNoMatchesMessage(); } else if (addressCollection.getAddressList().size() == 1) { addressView.showPositionByName(addressCollection.getAddressList().get(0)); } else { addressView.showAddressSelectionDialog(addressCollection.getAddressList()); } } @Override public void onError(final String errorMessage) { addressView.hideProgressDialog(); addressView.showCallError(errorMessage); } }); } }