Skip to content

Commit

Permalink
Add Infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinea committed May 28, 2014
1 parent 6780c03 commit d4588eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Binary file removed libs/android-support-v4.jar
Binary file not shown.
1 change: 1 addition & 0 deletions src/cn/trinea/android/demo/AutoScrollViewPagerDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void onCreate(Bundle savedInstanceState) {

viewPager.setInterval(2000);
viewPager.startAutoScroll();
viewPager.setCurrentItem(Integer.MAX_VALUE / 2 - Integer.MAX_VALUE / 2 % imageIdList.size());

// the more properties whose you can set
// // set whether stop auto scroll when touching, default is true
Expand Down
7 changes: 5 additions & 2 deletions src/cn/trinea/android/demo/adapter/ImagePagerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@ public class ImagePagerAdapter extends PagerAdapter {
private Context context;
private List<Integer> imageIdList;

private int size;

public ImagePagerAdapter(Context context, List<Integer> imageIdList) {
this.context = context;
this.imageIdList = imageIdList;
this.size = ListUtils.getSize(imageIdList);
}

@Override
public int getCount() {
return ListUtils.getSize(imageIdList);
return Integer.MAX_VALUE;// ListUtils.getSize(imageIdList);
}

@Override
Expand All @@ -43,7 +46,7 @@ public boolean isViewFromObject(View view, Object object) {
@Override
public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView = new ImageView(context);
imageView.setImageResource(imageIdList.get(position));
imageView.setImageResource(imageIdList.get(position % size));
((ViewPager)container).addView(imageView, 0);
return imageView;
}
Expand Down

0 comments on commit d4588eb

Please sign in to comment.