question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Potential Bind Issue (bug?) in AutoGenerated Models

See original GitHub issue

Greetings!

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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
elihartcommented, Nov 21, 2017

2.7.3 is out with the fix.

1reaction
elihartcommented, Nov 21, 2017

Great, thanks for looking, really appreciate the feedback! PR is merged, I’ll have a release out soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Possible compiler bug: Error #7977 when using auto-generated ...
TYPE(FOO) FUNCTION FOO_FCN() BIND(C) RESULT(BAR) IMPLICIT NONE BAR.A = 1 BAR.B = 2 RETURN END FUNCTION SUBROUTINE SOMETHING() IMPLICIT NONE INTERFACE.
Read more >
Data Binding class not generated - Stack Overflow
Your binding class and new variables in layout will not be generated if your build fails. So first Make project by Ctrl +...
Read more >
[DAC] permission denied with auto generated channel socket ...
I can produce this bug on build with another way libvirt-1.2.8-16.el7.x86_64 1. make sure user and group with default in qemu.conf user =...
Read more >
Cisco Firepower Release Notes, Version 6.6 - Security
For your convenience, this document lists open and resolved bugs. Important. Bug lists are auto-generated once and are not subsequently updated.
Read more >
Data Binding in Android: A tutorial with examples
This pattern is important for many Android designs, including model view ViewModel (MVVM), which is currently one of the most common Android ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found