Updating RecyclerView item ProgressBar without calling notifyItemChanged(int) on adapter
Asked Answered
T

1

7

I am trying to update a progressBar which is the part of one of the RecyclerView items. I know I can do it in two ways,

Method 1: By refreshing the item row by calling notifyItemChanged(position)

Method 2: By accessing the view using the method findViewByPosition() on LayoutMananger object.

But unluckily none of them are working in my case.

If I use the first one, the whole item will get repainted, the background color of the recyclerview is gray and the item is white, so the user can notice the whole item refresh.

If I try the second one, I will end up with problems while scrolling.

I want to update progress just like WhatsApp does. Thanks in advance

Tercentenary answered 25/7, 2016 at 12:38 Comment(2)
I have the same problem. I tried to store ViewHolder and update it on progress update, but it doesn't work.Merrymerryandrew
@Vusal, look at my answer below, it'll fix the problem your facing.Sasaki
S
21

If I use the first one, the whole item will get repainted, the background color of the recyclerview is gray and the item is white, so the user can notice the whole item refresh.

I ran into this issue as well. To fix it you need to turn off the default item change animations. Once you turn off the item change animations your recyclerView item will update without any flashing/jumping, allowing you to use notifyItemChanged(int) without any problems.

Turn off the default item change animations like so:

((SimpleItemAnimator) myRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
Sasaki answered 12/1, 2017 at 5:33 Comment(1)
@AmirZiarati, I completely agree with your comment ;)Sasaki

© 2022 - 2024 — McMap. All rights reserved.