@Override protected Group<Tip> doInBackground(Void... params) { try { Foursquared foursquared = (Foursquared) mActivity.getApplication(); Foursquare foursquare = foursquared.getFoursquare(); Location loc = foursquared.getLastKnownLocation(); if (loc == null) { try { Thread.sleep(3000); } catch (InterruptedException ex) { } loc = foursquared.getLastKnownLocation(); if (loc == null) { throw new FoursquareException("Your location could not be determined!"); } } return foursquare.tips( LocationUtils.createFoursquareLocation(loc), mUserId, "nearby", mRecentOnly ? "recent" : "popular", 30); } catch (Exception e) { mReason = e; } return null; }
public Group<Group<Venue>> search() throws FoursquareException, LocationException, IOException { Foursquare foursquare = ((Foursquared) getApplication()).getFoursquare(); Location location = ((Foursquared) getApplication()).getLastKnownLocationOrThrow(); Group<Group<Venue>> groups = foursquare.venues( LocationUtils.createFoursquareLocation(location), mSearchHolder.query, 30); for (int i = 0; i < groups.size(); i++) { Collections.sort(groups.get(i), Comparators.getVenueDistanceComparator()); } return groups; }