Search in sources :

Example 1 with VenuesAdapter

use of cz.destil.glasquare.adapter.VenuesAdapter in project glasquare by davidvavra.

the class VenueListActivity method searchVenues.

private void searchVenues(String ll) {
    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;
    }
}
Also used : Response(retrofit.client.Response) Callback(retrofit.Callback) VenuesAdapter(cz.destil.glasquare.adapter.VenuesAdapter) ExploreVenues(cz.destil.glasquare.api.ExploreVenues) RetrofitError(retrofit.RetrofitError)

Aggregations

VenuesAdapter (cz.destil.glasquare.adapter.VenuesAdapter)1 ExploreVenues (cz.destil.glasquare.api.ExploreVenues)1 Callback (retrofit.Callback)1 RetrofitError (retrofit.RetrofitError)1 Response (retrofit.client.Response)1