ChatKit icon indicating copy to clipboard operation
ChatKit copied to clipboard

MessagesListAdapter scrolling bug

Open tzigdon opened this issue 5 years ago • 2 comments

Hello,

I develop an app with group chats and I just found a bug in the MessagesListAdapter. I disable the visibility of the bubble for some messages which are system messages (like when a user leaves the group, I display "user has left the group" message). I do so in the incoming message view holder, and here is the code:


if (messageUser.getId().equals(SYSTEM_MESSAGE_USER))
{
          bubble.setBackgroundColor(groupChatUser.getTransparentColor());
          time.setVisibility(View.GONE);
          String currText = text.getText().toString();
          text.setText(INFORMATION_SIGN + currText);
}
  

the problem is that when scrolling through the messages, some other messages have their bubble disappear also, which is a known problem in RecyclerView. the solution is here: https://www.solutionspirit.com/on-scrolling-recyclerview-change-values/

EDIT: So I copied the library to my project in order to try this solution (had to change the MessagesListAdapter): https://www.solutionspirit.com/on-scrolling-recyclerview-change-values/

And it didn't work, wrong messages on the list still updates when scrolling Any help would be appreciated

EDIT2: I solved this problem by adding else to my if and setting the views back to normal

for example: lets say I want to set the bubble visibility to gone for system messages but for other users I want it to be visible:

if (messageUser.getId().equals(SYSTEM_MESSAGE_USER))
{
          bubble.setVisibility(View.GONE)
}
else
{
         bubble.setVisibility(View.VISIBLE)
}

I cannot assume it will be the default for other users Hope you understood what I was trying to say

tzigdon avatar Aug 05 '19 07:08 tzigdon

Hey @tzigdon I believe you should use the custom holder type for this to resolve the problem

troy379 avatar Aug 05 '19 08:08 troy379

Hey @tzigdon I believe you should use the custom holder type for this to resolve the problem

thanks for the quick reply, I do use the holder, the problem is in the adapter (MessagesListAdapter) which (correct me if I'm wrong) I cannot replace

tzigdon avatar Aug 05 '19 08:08 tzigdon