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

item from the list doesn't get updated at once #531

Closed
alouanemed opened this Issue Sep 7, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@alouanemed

alouanemed commented Sep 7, 2018

I have a list of items that belongs to a groupe. so I have 2 models : groupModel and groupItems.
Each groupItems has a Textview on which on clicked a dialog appears to give an input and then update the correspondant Item object from the list. After that I update the list with the new input and call requestModelBuild().

What I noticed is that the textview doesn't get get updated but it does when I scroll down and move back to that item.I don't do any netowrk call or database operation here.

From the activity I call controller.updateElement(CartItem), on this method I update groupItemsList list inside the controller and call requestModelBuild

   groupItemsList.forEach {
      HeaderModel_()
          .id(it.id)
          .ItemGroup(it)
          .addTo(this)

      val cartItemGroup = it
      var position = 0
      it.cartItems.forEach {
        CartItemModel_()
            .id(it.id)
            .cartItem(it)
            .position(position)
            .cartItemGroup(cartItemGroup)
            .onActionOnItemClicked(onActionOnItemClicked)
            .addTo(this)
        position++
      }
    }

Can hashcode solve this ? and is itgoing to be for groupe or groupe items? or there is another solution for this ? Thanks.

@elihart

This comment has been minimized.

Show comment
Hide comment
@elihart

elihart Sep 7, 2018

Contributor

yes it seems that you don't properly implement hashcode. does the item type for groupItemsList implement hashcode and equals correctly? how are your models implemented?

Contributor

elihart commented Sep 7, 2018

yes it seems that you don't properly implement hashcode. does the item type for groupItemsList implement hashcode and equals correctly? how are your models implemented?

@alouanemed

This comment has been minimized.

Show comment
Hide comment
@alouanemed

alouanemed Sep 7, 2018

I don't have hashcode on any of the used item types.


class GroupItemGroup(
    val total: Int,
    val id: Int,
    val companyName: String,
  var cartItems: List<CartItem>
)

My Model :

@EpoxyModelClass(layout = R.layout.group_item)
abstract class HeaderModel : DataBindingModel<ItemBinding>() {
  @EpoxyAttribute
  lateinit var itemGroup: ItemGroup

  override fun bind(binding: ItemBinding, context: Context) {
... bind views..
  }

  override fun unbind(binding: ItemBinding) {

  }
}

alouanemed commented Sep 7, 2018

I don't have hashcode on any of the used item types.


class GroupItemGroup(
    val total: Int,
    val id: Int,
    val companyName: String,
  var cartItems: List<CartItem>
)

My Model :

@EpoxyModelClass(layout = R.layout.group_item)
abstract class HeaderModel : DataBindingModel<ItemBinding>() {
  @EpoxyAttribute
  lateinit var itemGroup: ItemGroup

  override fun bind(binding: ItemBinding, context: Context) {
... bind views..
  }

  override fun unbind(binding: ItemBinding) {

  }
}
@elihart

This comment has been minimized.

Show comment
Hide comment
@elihart

elihart Sep 7, 2018

Contributor

well that's why, make it a data class. Have you read the wiki?

Contributor

elihart commented Sep 7, 2018

well that's why, make it a data class. Have you read the wiki?

@alouanemed

This comment has been minimized.

Show comment
Hide comment
@alouanemed

alouanemed Sep 10, 2018

Yes, I added hashcode to my entities, but the issue remains the same.

alouanemed commented Sep 10, 2018

Yes, I added hashcode to my entities, but the issue remains the same.

@elihart

This comment has been minimized.

Show comment
Hide comment
@elihart

elihart Sep 11, 2018

Contributor

did you add equals as well?

Have you set any breakpoints to trace this?

Contributor

elihart commented Sep 11, 2018

did you add equals as well?

Have you set any breakpoints to trace this?

@alouanemed alouanemed closed this Oct 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment