Currently, if I change the Section's State via
// Current State is FAILED.
watchlistSection.setState(Section.State.LOADING);
sectionAdapter.notifyItemChangedInSection(watchlistSection, 0);
It will cause unwanted animation. Although I had tried to turn off animation via
RecyclerView.ItemAnimator itemAnimator = this.recyclerView.getItemAnimator();
if (itemAnimator instanceof SimpleItemAnimator) {
((SimpleItemAnimator)itemAnimator).setSupportsChangeAnimations(false);
}
It doesn't help much. As you can see in the video, when the View changed from
a sad cloud face to progress bar
, there's unwanted flickering effect.
https://youtu.be/x-X-SXs0Acc - Using setSupportsChangeAnimations(false)
Note, if I use the following code, there's still a unwanted flickering effect. But, this time, the flickering effect is different from previous
RecyclerView.ItemAnimator itemAnimator = this.recyclerView.getItemAnimator();
if (itemAnimator instanceof SimpleItemAnimator) {
((SimpleItemAnimator)itemAnimator).setSupportsChangeAnimations(true);
}
https://youtu.be/m4jLfhUpjQc - setSupportsChangeAnimations(true)
I can completely eliminated the unwanted flickering effect, by removing SimpleItemAnimation. However, this will cause other problem. Some, some item in the recycler view, I need to perform swipe-to-delete and drag-n-move UX effect. Without SimpleItemAnimation, I can't achieve such effect.
this.recyclerView.setItemAnimator(null);
https://youtu.be/MyZlqPCeS7s - this.recyclerView.setItemAnimator(null)
Any idea how I can avoid unwanted animation/ flickering effect during notifyItemChangedInSection, without removing SimpleItemAnimation
? I expect setSupportsChangeAnimations(false)
will work, but it doesn't.