infiniteviewpager icon indicating copy to clipboard operation
infiniteviewpager copied to clipboard

Allow user to specify an end page

Open Wavesonics opened this issue 11 years ago • 9 comments

It would be very helpful to allow users of the lib to be able to specify if a particular page is the last page in that direction.

My use case is I want to have infinite paging to the right, but not be able to go back to the left beyond a certain point.

I may actually take a crack at adding this my self, any tips on where to look in code to implement something like this?

Wavesonics avatar Nov 18 '13 05:11 Wavesonics

That should not be too difficult to implement. I would add two more methods setMaxValue(T value) and setMinValue(T value) in the InfiniteAdapter Class. And if your current indicator value is either of those two values the pager should stop. But that's just an idea. I haven't thought it through ;) I will start implementing this feature tonight.

cheers

hayribakici avatar Nov 18 '13 09:11 hayribakici

Awesome! That would be a huge help!

Wavesonics avatar Nov 19 '13 04:11 Wavesonics

Have you implemented this feature yet, hayribakici? I was working on the very same feature and I stumbled into this issue page. I was curious if the work is already done. Or I could contribute my work otherwise. :)

The basic idea is to have a left or right bound of T type. If it is bounded and has reached to a left or right bound, then do not allow users to move beyond the bound. To achieve this behaviour, the indicator needs to be Comparable<T> rather than T because we want to compare the current indicator against the left or right bound value to determine when to stop. I also had to handle special cases where users can set the current indicator which may end up on the exact left or right bound.

I'm just finishing up my work so it could be ready in a couple of days.

SP

seulkiro avatar Feb 04 '14 06:02 seulkiro

hi, I started to implement it without the Comparable interface, but couldn't finish it up. I would like to keep it without the comparable interface due to the Date or Time class in android, which they do not implement. However you are more than welcome to contribute. You can do a pull request and maybe we can sort things out and do it without the comparable interface after all.

hayribakici avatar Feb 04 '14 14:02 hayribakici

I wasn't aware that the Date or Time class in android doesn't implement the comparable interface. I'm new to java and android. I guess one could still use it with milliseconds value if it provides such a function. Having said that, it can be done without the comparable interface. I'm thinking the string representation of min/max indicators. I'm going to give this a try. Or do you have any suggestions?

seulkiro avatar Feb 05 '14 23:02 seulkiro

Hi, sorry for my late reply. I can publish my brach with which you can check out and see how far I've come to. But it would be interesting to know if people are using the infiniteviewpager with an indicator of the comparable interface. cheers

hayribakici avatar Feb 18 '14 06:02 hayribakici

@Wavesonics @seulkiro @hayribakici Anyone made any progress adding bounds? I would be interested in this feature as well!

henrykvdb avatar Dec 17 '16 21:12 henrykvdb

@henrykvdb there is a branch feature/max_min_value, however I was thinking what the use case would be, when setting a maximum or minimum value? Then it would not be an infiniteViewPager, but a regular ViewPager. Therefore in my opinion, it doesn't make sense to build such a constraint.

hayribakici avatar Dec 17 '16 21:12 hayribakici

@hayribakici I don't see how setting a lower OR upper bound would not make it an infiniteViewPager, as there would still be infinite pages. You only get a regular ViewPager when you add an upper and lower bound at the same time.

henrykvdb avatar Dec 18 '16 19:12 henrykvdb