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

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

Introduction

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

Prototype

public native String getCity() ;

Source Link

Document

Returns the city name for the 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  ww.  java  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);
        }
    }
}