-
Notifications
You must be signed in to change notification settings - Fork 729
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
Conversation
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a test please
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, lgtm
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