Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewPager Circular with less than 4 views

I am trying to implement an infinite Carousel using the ViewPager component. I based on the one created by Antonyt but there is a problem using less than 4 views. As the view is already in place. Must be a way to trick the Viewpager to draw the same view/page in different places.

like image 787
Dayerman Avatar asked Nov 25 '22 10:11

Dayerman


1 Answers

I ran into the same problem, couldn't find the solution myself. But i guess it is impossible to do by using only 1-4 views. What the problem is that all the views (for 1-4 images in repetition) will be instantiated at once(or atleast in a very short interval) this interferes with the image loading process because the prev load hasn't finished, so the prev one returns a damaged view. You may handle this something like this though.

1) right after instantiation, use handler with delay of 100-200ms to flip through views setCurrentItem() again and again(around 10 times) in either direction, this way the original 4 will be out of range(if you have off screen page limit, which i hope you have beacause of infinte nature of your code) and will be created one by one later on.

2) Use multiple buffer objects,

1 image-8 buffers

2 images-4 buffers for each

3 images-2 buffers for each... something like this.

neither is an ideal solution but both worked for me but. I would like to know what you tried too.

like image 78
Shakti Avatar answered Dec 11 '22 02:12

Shakti