Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 952
Pruthviraj Avatar asked Jul 25 '16 12:07

Pruthviraj


1 Answers

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);
like image 121
Sakiboy Avatar answered Nov 10 '22 00:11

Sakiboy