Potential Bind Issue (bug?) in AutoGenerated Models
See original GitHub issueGreetings!
First off, just wanted to say that Epoxy is awesome. Hands down, without question, one of the best libraries I’ve ever used within the Android ecosystem, period. Ok, enough gushing!
So I’m reaching out with what I think might be an issue with the autogenerated models’ bind call with a previous model. I’m not totally sure I’m right here, so please excuse my ignorance! :
I’ve got a model being bound to a controller. That model is AutoGenerated from a custom view’s annotations. At runtime, an instance will have an id “user_id_1”. When something changes on a related bit of data, I recreate that model with the same id (“user_id_1”), and set some properties on it. At runtime, during the rebind with current and previous data, they have these properties:
During bind() call with previousModel:
assignedAttributes_epoxyGeneratedModel = {5, 8, 10, 11}
[that.]assignedAttributes_epoxyGeneratedModel = {1, 2, 5, 8, 10, 11, 12, 13}
This means that the call to
if (assignedAttributes_epoxyGeneratedModel.equals(that.assignedAttributes_epoxyGeneratedModel))
… will be false. Cool, makes sense; our BitSets are different, so check which thing you need to bind.
However, we then hit:
else {
if (assignedAttributes_epoxyGeneratedModel.get(5) && !that.assignedAttributes_epoxyGeneratedModel.get(5)) {
object.setUserImage(userImage_UserDisplayParams);
}
else if (assignedAttributes_epoxyGeneratedModel.get(6) && !that.assignedAttributes_epoxyGeneratedModel.get(6)) {
object.setEnlargedImage(enlargedImage_Params);
}
else if (assignedAttributes_epoxyGeneratedModel.get(7) && !that.assignedAttributes_epoxyGeneratedModel.get(7)) {
object.setStandardImage(standardImage_Params);
}
else {
object.setStandardImage((Params) null);
}
}
The issue here is that, in both cases, 5
is a set bit for both. However, that value, which is a new object ‘UserDisplayParams’ has actually changed, which means I need that value to be rebound! What happens in this case is the final group call is made to setStandardImage
, which ends up blowing the changed image away.
My custom view is annotated this way:
@ModelProp(group = "image")
public void setUserImage(@Nullable UserDisplayParams displayParams) { // ... }
@ModelProp(group = "image")
public void setEnlargedImage(@Nullable Params displayParams) { // ... }
@ModelProp(group = "image")
public void setStandardImage(@Nullable Params params) { // ... }
If I had to guess, I’d say I’m probably doing something wrong. Perhaps I should be attaching a unique id to the modelID each time?
I really appreciate your time with this, and thanks again for the awesome tool! Looking forward to the tut-tut for breaking something 😅
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
2.7.3 is out with the fix.
Great, thanks for looking, really appreciate the feedback! PR is merged, I’ll have a release out soon.