1
Staff need to load when arriving at the end of the list, example I have 20 items, when arriving at the end of it, need to be loaded 20 more.
Currently my Fragment loading the ads is as follows below.
new AsyncHttpClient().get(Constantes.URL_WS_BASE + "anuncio/list", new JsonHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, JSONArray response) {
if(response != null) {
Type type = new TypeToken<List<Anuncio>>() {}.getType ();
anuncios = new Gson().fromJson(response.toString(), type);
AnuncioRecyclerAdapter adapter = new AnuncioRecyclerAdapter(anuncios);
rv.setAdapter(adapter);
} else {
Toast.makeText(getActivity(), "Houve um erro ao carregar a lista de anúncios.", Toast.LENGTH_LONG).show();
}
lytLoading.setVisibility(View.GONE);
}
@Override
public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
super.onFailure(statusCode, headers, responseString, throwable);
Toast.makeText(getActivity(), "Falha: " + responseString, Toast.LENGTH_LONG).show();
}
});
Take a look here: https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView
– viana
I didn’t get it that way, I’m having a really hard time doing this.
– Willian Passarelli
So man, but for example "anuncio/list" returns all the items?! Because if it returns everything doesn’t make much sense to have pagination. I usually do so "ad/list/10,0" returning 10 items from page 1, at the end of the list (on the media that uses scroll), I do a new search "ad/list/10,1" returning 10 more items from page 2;
– viana