addisonElliott / SegmentedButton

Segmented Control/Button with animation for Android API 16+
Apache License 2.0
148 stars 39 forks source link

[Feature Request] Handle buttons visibility #13

Closed le-comte-encieux closed 4 years ago

le-comte-encieux commented 5 years ago

Hello, Can we have the possibility to have the current selected button as first parameter of setOnPositionChangedListener so we can use it more reliably than the position if we hide some buttons.

If i had the android developement level to do it correctly I would do it myself and pull request it but I am new to android developpement. Yet I Tried but it's obviously bugged (you can see what i'm requesting in the atached file)

SegmentedButton.zip

addisonElliott commented 5 years ago

I just checked the source code, and I don't see a way to get the last position of the buttons from the listener. Thus, your feature request is a valid point.

However, the reason I did not include the previous position of the button when the selection is changed is because I failed to see a valid use case for it. Can you explain why you need this functionality and why you think it's beneficial to the repository?

This an easy fix to make, and I see two possible ways of fixing. First, moving the listener call to before the new position is updated, that way this.position() will return the last position. Second, actually add a new parameter to the listener for the previous position. Not sure which method I prefer.

Since this is an easy fix to make, I'm going to leave it for someone else to do. It doesn't take much knowledge into Android development in order to make the change. It's mostly understanding Java code and I think it'll be a good first issue for someone to complete.

addisonElliott commented 4 years ago

I still don't see a useful use case for this feature. Until justification is provided, I don't think this is worth the time or effort.