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

Add EpoxyModel#prebind hook #1225

Merged
merged 3 commits into from
Aug 27, 2021
Merged

Add EpoxyModel#prebind hook #1225

merged 3 commits into from
Aug 27, 2021

Conversation

pterhx
Copy link
Contributor

@pterhx pterhx commented Aug 24, 2021

This adds a hook that is called before bind (EpoxyModel#prebind) which lets subclasses capture view state before any changes are made, allowing us to create transition animations.

@elihart

This adds a hook that is called before bind, which lets us capture view
state before any changes are made.
@@ -60,6 +60,14 @@ public void bind(@SuppressWarnings("rawtypes") EpoxyModel model,
((GeneratedModel) model).handlePreBind(this, objectToBind(), position);
}

if (previouslyBoundModel != null) {
// noinspection unchecked
model.prebind(objectToBind(), previouslyBoundModel);
Copy link
Contributor

Choose a reason for hiding this comment

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

add a test please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

* process, and follows the same general conditions for all
* recyclerview change payloads.
*/
public void prebind(@NonNull T view, @NonNull EpoxyModel<?> previouslyBoundModel) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I prefer a single prebind function with a nullable previous model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Copy link
Contributor

@elihart elihart left a comment

Choose a reason for hiding this comment

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

thanks, lgtm

@elihart elihart merged commit 1bba7ce into airbnb:master Aug 27, 2021
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