Example usage for com.google.gwt.search.client LocalResult getStreetAddress

List of usage examples for com.google.gwt.search.client LocalResult getStreetAddress

Introduction

In this page you can find the example usage for com.google.gwt.search.client LocalResult getStreetAddress.

Prototype

public native String getStreetAddress() ;

Source Link

Document

Return the street address and number for the given result.

Usage

From source file:com.google.mobile.trippy.web.client.db.DefaultSearchService.java

License:Apache License

/**
 * Add a results of one page to total results
 *///from w  w  w .  j a  va 2  s  .c o m
private void addGoogleResultsToList(final String queryString, final HasLatLngBounds bounds,
        List<SearchItem> searchItemList, final JsArray<LocalResult> results) {

    final long sizeOffset = searchItemList.size();
    if (results != null && results.length() > 0) {
        int maxResultToDisplay = Math.min(results.length(), MAX_GOOGLE_SEARCH_RESULTS);
        for (int i = 0; i < maxResultToDisplay; ++i) {
            final LocalResult result = results.get(i);
            final SearchItem item = new SearchItem();
            item.setId(getItemCacheKey(SearchType.GOOGLE.toString(), queryString, bounds, sizeOffset + i));
            item.setName(result.getTitleNoFormatting());
            item.setAddress(result.getStreetAddress() + " " + result.getCity());

            final JsArray<LocalResult.PhoneNumber> phn = result.getPhoneNumbers();
            final ArrayList<String> phoneNumbers = new ArrayList<String>();
            if (phn != null) {
                for (int j = 0; j < phn.length(); j++) {
                    phoneNumbers.add(phn.get(j).getNumber().toString());
                }
                item.setPhoneNumbers(phoneNumbers);
            }

            item.setLatitude(result.getLat());
            item.setLongitude(result.getLng());
            item.setUrl(getMobileUrl(result.getUrl()));
            item.setType(SearchType.GOOGLE);

            searchItemList.add(item);
        }
    }
}