-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
EventHook - Question/Example #418
Comments
@MFlisar in your case you want to go with the If you want to have a custom event being bound properly to the In If you need access to the item within the event you define you'll then need to check what is already done automatically for the //we get the adapterPosition from the viewHolder
int pos = fastAdapter.getHolderAdapterPosition(viewHolder);
//make sure the click was done on a valid item
if (pos != RecyclerView.NO_POSITION) {
fastAdapter.getItem(pos); //this will give you the proper item at the current position
} |
I think the naming is not very good, but I got it working now. Additionally I wrote following base class for myself, I think this will help others to understand the event hooks a little easier. Extended base class
Usage
I don't know what the |
This is just increasing the complexity of a simple 3 methods class. It should be enough to check the viewholder instance inside the onBind/onBindMany instead of creating a new method just for doing this. |
You would also increase the performance when you just avoid the initialization of the anonymous inner class here and use the EventHook object as an replacement. |
Was just an suggestion. For me the
With that in mind and with the custom event only providing a Still just a suggestion nothing more... |
When you have suggestions about the method names or any other breaking stuff that would improve the usability of the eventhooks you could write them here down and maybe we could add them to #294. |
You're right, a little documentation and you don't need that much methods. But I would suggest following:
Suggestion
Maybe the |
In most cases you don't need the position of the viewholder so you would have to add this manually when needed. You could add a pull request that just renames the methods with an documentation. Everything else is not needed for the default case. |
You mean getting the item is not necessary, don't you? Is there a case where it's save not to check the position against |
Its not necessary to do this in a specific method because you need to provide an own listener implementation anyway. |
I guess I can close this, as the documentation is added with this PR: https://github.com/mikepenz/FastAdapter/pull/425/files |
I guess you should always check for the NO_POSITION as soon as you access the getAdapterPosition, as it might return it |
I've created following event hook:
And following listener in my item:
I've following questions:
Switch
view of every item on myonBind
function, correct?onCheckedChanged
function? MymOnCheckedChangeListener
should inform the event hook, but how??The text was updated successfully, but these errors were encountered: