Пример #1
0
  @Override
  protected void loadData() {
    showProgress(R.string.loading);
    final String ll = LocationUtils.getLatLon();
    if (ll == null) {
      showError(R.string.no_location);
      return;
    }

    Callback<ExploreVenues.ExploreVenuesResponse> callback =
        new Callback<ExploreVenues.ExploreVenuesResponse>() {
          @Override
          public void success(
              ExploreVenues.ExploreVenuesResponse exploreVenuesResponse, Response response) {
            if (exploreVenuesResponse.getVenues().size() == 0) {
              showError(R.string.no_venues_found);
            } else {
              showContent(
                  new VenuesAdapter(exploreVenuesResponse.getVenues()),
                  new CardSelectedListener() {
                    @Override
                    public void onCardSelected(Object item) {
                      mSelectedVenue = (ExploreVenues.Venue) item;
                      openOptionsMenu();
                    }
                  });
            }
          }

          @Override
          public void failure(RetrofitError retrofitError) {
            showError(R.string.error_please_try_again);
            DebugLog.e(retrofitError);
          }
        };

    int type = getIntent().getIntExtra(EXTRA_TYPE, TYPE_EXPLORE);
    switch (type) {
      case TYPE_EXPLORE:
        Api.get().create(ExploreVenues.class).best(ll, callback);
        break;
      case TYPE_SEARCH:
        String query = getIntent().getStringExtra(EXTRA_QUERY);
        Api.get().create(ExploreVenues.class).search(ll, query, callback);
        break;
    }
  }