use of com.aspsine.swipetoloadlayout.demo.adapter.LoopViewPagerAdapter in project SwipeToLoadLayout by Aspsine.
the class TwitterListViewFragment method onRefresh.
@Override
public void onRefresh() {
GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {
@Override
public void onResponse(SectionCharacters characters) {
mAdapter.setList(characters.getSections());
if (viewPager.getAdapter() == null) {
mPagerAdapter = new LoopViewPagerAdapter(viewPager, indicators);
viewPager.setAdapter(mPagerAdapter);
viewPager.addOnPageChangeListener(mPagerAdapter);
mPagerAdapter.setList(characters.getCharacters());
viewPager.setBackgroundDrawable(getResources().getDrawable(R.mipmap.bg_viewpager));
} else {
mPagerAdapter = (LoopViewPagerAdapter) viewPager.getAdapter();
mPagerAdapter.setList(characters.getCharacters());
}
swipeToLoadLayout.setRefreshing(false);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
swipeToLoadLayout.setRefreshing(false);
volleyError.printStackTrace();
}
});
App.getRequestQueue().add(request).setTag(TAG);
}
Aggregations