use of com.aspsine.swipetoloadlayout.demo.model.SectionCharacters in project SwipeToLoadLayout by Aspsine.
the class GoogleStyleFragment method onLoadMore.
@Override
public void onLoadMore() {
GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {
@Override
public void onResponse(final SectionCharacters characters) {
// here, I use post delay to show more animation, you don't have to.
swipeToLoadLayout.postDelayed(new Runnable() {
@Override
public void run() {
if (mPageNum < 3) {
mPageNum++;
mAdapter.append(characters.getSections().subList(mPageNum, mPageNum + 1));
} else {
Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();
}
swipeToLoadLayout.setLoadingMore(false);
}
}, 2000);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
swipeToLoadLayout.setLoadingMore(false);
volleyError.printStackTrace();
}
});
App.getRequestQueue().add(request).setTag(TAG + "loadmore" + mType);
}
use of com.aspsine.swipetoloadlayout.demo.model.SectionCharacters in project SwipeToLoadLayout by Aspsine.
the class TwitterGridViewFragment method onLoadMore.
@Override
public void onLoadMore() {
GsonRequest request = new GsonRequest<SectionCharacters>(Constants.API.CHARACTERS, SectionCharacters.class, new Response.Listener<SectionCharacters>() {
@Override
public void onResponse(SectionCharacters characters) {
if (mPageNum < 3) {
mPageNum++;
mAdapter.append(characters.getSections().get(mPageNum).getCharacters());
} else {
Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();
}
swipeToLoadLayout.setLoadingMore(false);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
swipeToLoadLayout.setLoadingMore(false);
volleyError.printStackTrace();
}
});
App.getRequestQueue().add(request).setTag(TAG + "loadmore");
}
use of com.aspsine.swipetoloadlayout.demo.model.SectionCharacters in project SwipeToLoadLayout by Aspsine.
the class TwitterScrollViewFragment 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 sectionCharacters) {
List<Character> characters = sectionCharacters.getCharacters();
for (int i = 0; i < characters.size(); i++) {
String img = characters.get(i).getAvatar();
if (i < ivArray.length) {
Picasso.with(getActivity()).load(img).into(ivArray[i]);
}
}
swipeToLoadLayout.setRefreshing(false);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
swipeToLoadLayout.setRefreshing(false);
volleyError.printStackTrace();
}
});
App.getRequestQueue().add(request).setTag(TAG);
}
use of com.aspsine.swipetoloadlayout.demo.model.SectionCharacters in project SwipeToLoadLayout by Aspsine.
the class TwitterGridViewFragment 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().get(0).getCharacters());
swipeToLoadLayout.setRefreshing(false);
mPageNum = 0;
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
swipeToLoadLayout.setRefreshing(false);
volleyError.printStackTrace();
}
});
App.getRequestQueue().add(request).setTag(TAG + "refresh");
}
use of com.aspsine.swipetoloadlayout.demo.model.SectionCharacters 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