Search in sources :

Example 1 with PartyDocumentCallback

use of oscar.riksdagskollen.Utilities.Callbacks.PartyDocumentCallback in project Riksdagskollen by OAndell.

the class PartyListFragment method loadNextPage.

/**
 * Load the next page and add it to the adapter when downloaded and parsed.
 * Hides the loading view.
 */
private void loadNextPage() {
    setLoading(true);
    RikdagskollenApp.getInstance().getRiksdagenAPIManager().getDocumentsForParty(party, pageToLoad, new PartyDocumentCallback() {

        @Override
        public void onDocumentsFetched(List<PartyDocument> documents) {
            loadingView.setVisibility(View.GONE);
            documentList.addAll(documents);
            partyListAdapter.notifyDataSetChanged();
            setLoading(false);
        }

        @Override
        public void onFail(VolleyError error) {
            setLoading(false);
            pageToLoad--;
        }
    });
    pageToLoad++;
}
Also used : VolleyError(com.android.volley.VolleyError) PartyDocument(oscar.riksdagskollen.Utilities.JSONModels.PartyDocument) PartyDocumentCallback(oscar.riksdagskollen.Utilities.Callbacks.PartyDocumentCallback)

Aggregations

VolleyError (com.android.volley.VolleyError)1 PartyDocumentCallback (oscar.riksdagskollen.Utilities.Callbacks.PartyDocumentCallback)1 PartyDocument (oscar.riksdagskollen.Utilities.JSONModels.PartyDocument)1