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

Pass view attach/detach events to the Item #297

Merged

Conversation

AllanHasegawa
Copy link
Contributor

I have an Item that requires to know if it's attached or not to the window to know when to start/stop animations and UI updates.

The simplest solution is to override the RecyclerView::Adapter::onViewAttachedToWindow (and the detach equivalent) method and pass it to the Item.

What are your thoughts on this? If this seems reasonable, it would be nice to have it in the library.

Copy link
Owner

@lisawray lisawray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had thought of doing this too -- thanks!

@@ -466,6 +466,22 @@ public void onItemMoved(@NonNull Group group, int fromPosition, int toPosition)
notifyItemMoved(groupAdapterPosition + fromPosition, groupAdapterPosition + toPosition);
}

@Override
public void onViewAttachedToWindow(@NonNull VH holder) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great, but could you please move these functions to be just under the onFailedToRecycleView one so that we can group the RecyclerView.Adapter overloads in one place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. They should be in the correct position now.

Copy link
Collaborator

@ValCanBuild ValCanBuild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.I'll squash before merging

@ValCanBuild ValCanBuild merged commit a01a47a into lisawray:master Oct 8, 2019
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.

3 participants