Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Allow user to specify an end page #4

Open
Wavesonics opened this issue Nov 18, 2013 · 9 comments
Open

Allow user to specify an end page #4

Wavesonics opened this issue Nov 18, 2013 · 9 comments
Assignees

Comments

@Wavesonics
Copy link

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?

@hayribakici
Copy link
Owner

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

@ghost ghost assigned hayribakici Nov 18, 2013
@Wavesonics
Copy link
Author

Awesome! That would be a huge help!

@seulkiro
Copy link

seulkiro commented Feb 4, 2014

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 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

@hayribakici
Copy link
Owner

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.

@seulkiro
Copy link

seulkiro commented Feb 5, 2014

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?

@hayribakici
Copy link
Owner

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

@henrykvdb
Copy link

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

@hayribakici
Copy link
Owner

@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.

@henrykvdb
Copy link

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants