Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a OnPageChangeListener to the SliderLayout #100

Merged
merged 4 commits into from
May 8, 2015
Merged

Added a OnPageChangeListener to the SliderLayout #100

merged 4 commits into from
May 8, 2015

Conversation

massimobio
Copy link
Contributor

I implemented the ArrayList of listeners in ViewPagerEx as you recommended and used the item count in the InfinitePager to calculate the page number.
I also implemented the listener in the demo with a simple log.

massimobio added 2 commits May 6, 2015 10:30
The bundle for the textSliderView was never created so the Toast would crash in the onSliderClick method when trying to retrieve the "extra" from the null bundle
@massimobio
Copy link
Contributor Author

I made another small fix and the commit showed up here.
I was going to do a separate pull requests but I guess I can only do one a the time and all my commits show up here.
Thanks for being patient.

@daimajia
Copy link
Owner

daimajia commented May 6, 2015

Great job! I think there also need a method to removeListener(OnPageChangeListener listener), because if we start to use multiple listener design, we must need both remove and add method. For some situation, remove method is really useful when developing.

@daimajia
Copy link
Owner

daimajia commented May 6, 2015

@zhouqiangWang Please check this closed PR 's comment to know why we need an ArrayList to manage listener. #98

@massimobio
Copy link
Contributor Author

Yes makes sense, but how would a user know that behind the scenes we implemented the multiple listeners?
Usually you would set the listener to null to remove it, but it wouldn't work in our case, so should we throw an exception with a helpful error message?

@daimajia
Copy link
Owner

daimajia commented May 7, 2015

@massimobio I think the easiest way to make user know there is an arraylist managing their Listener is to change the name from setOnPageChangeListener to addOnPageChangeListener just like Android's ViewTreeObserver class.

It's the right way to indicate and handle multiple listener
@massimobio
Copy link
Contributor Author

Very good point. I updated my pull request.

@daimajia
Copy link
Owner

daimajia commented May 7, 2015

@massimobio One more thing, the method name setOnPageChange is not appropriate, cause set method always manipulate object variable, i think the best name should be triggerOnPageChangeEvent just like Android rules. https://developer.android.com/reference/android/hardware/TriggerEventListener.html

Using trigger prefix is much easy to understand this method when developer at first glance.

@massimobio
Copy link
Contributor Author

Just boarding a long flight. Will take care of it tomorrow. Thank you for your insightful input.
Question regarding comments: I see the ViewPagerEx has java doc formatted comments but SliderLayout not as much. Is that intentional?

@daimajia
Copy link
Owner

daimajia commented May 7, 2015

Have a good sleep. It's not very urgent.
We should make any pull request to be perfect, because every line of your code will be seen by other developers, every line of your code may affect millions users, especially when we are making a library.

The ViewPagerEx is the source code of ViewPager actually. The comments are all added by google's developer. SliderLayout should have clear comments. This is an early library I made, I didn't think too much on this. It now seems not right.

@massimobio
Copy link
Contributor Author

@daimajia I absolutely agree with you. Building a library is very much different that coding for your own app, and should follow widely agreed upon conventions as much as possible.

daimajia added a commit that referenced this pull request May 8, 2015
Added a OnPageChangeListener to the SliderLayout
@daimajia daimajia merged commit 28bf41e into daimajia:master May 8, 2015
@daimajia
Copy link
Owner

daimajia commented May 8, 2015

@massimobio Great! Thanks for your working on this project. How about to be a collaborator of this project?

@massimobio
Copy link
Contributor Author

@daimajia sure, if you think I can be helpful. I'll try my best.
How do you decide when to bump the release version?
I see that the latest release in github is 1.0.9 while gradle is up to 1.1.2

@daimajia
Copy link
Owner

daimajia commented May 8, 2015

@massimobio
Cool, I have added you to the list of collaborators. Welcome to join this project.

Actually the version is still 1.0.9, v1.1.2 is gradle version instead of the library version. https://github.com/daimajia/AndroidImageSlider/blob/master/library/build.gradle#L11

I'll publish a new release this weekend. :-D

@massimobio
Copy link
Contributor Author

Great, I'll answer and close the related issues to this pull.
Interesting about Gradle version differing from the release version. So using the 1.1.2 Gradle dependency on a project actually gives you version 1.0.9 of the library?
I was reading your other thread asking for collaborators. The Process explanations says to work on the fix/feature on a separate branch and then doing a pull request.
For this pull request I worked on the master branch on my fork and then made a pull request.
Is that fine or does the process change now that I'm a contributor?

@massimobio massimobio mentioned this pull request May 8, 2015
@daimajia
Copy link
Owner

daimajia commented May 9, 2015

@massimobio Your workflow is also right ( working on your own branch and then send pull request), just make sure that collaborators never push code to master branch.

I checked the config file again. The version should be v1.1.2, instead of v1.0.9
https://github.com/daimajia/AndroidImageSlider/blob/master/library/gradle-mvn-push.gradle#L50

@massimobio
Copy link
Contributor Author

@daimajia Is there a way to have the latest commit of the library compile as a dependency in grade while we wait for the next official release?
Or, is the only way to include the library manually into my project?

@daimajia
Copy link
Owner

@massimobio I have successfully push v1.1.5 to maven center. Have a try. :-D

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

Successfully merging this pull request may close these issues.

2 participants