2

I am facing the issue that my adapter blinks when adapter.notifyDataSetChanged() or adapter.notifyItemRangeChanged(0,recyclerView.getChildCount()) is called. I have tried so many solutions like setHasStableIds(true) and overiding the getItemId() to return id but it doesn't help me.

if (page == 1) {
    homeAdapter = new HomeAdapter(getActivity(), homeBeanList, Home.
    this, Home.
    this, Home.
    this, profile_pic, Home.
    this, Home.
    this, page);
    loaderDiloag.dismissDiloag();
    recyclerView.setAdapter(homeAdapter);
    recyclerView.setNestedScrollingEnabled(false);
} else {
    if (homeAdapter != null) {
        try {
            loaderDiloag.dismissDiloag();
            recyclerView.setNestedScrollingEnabled(false);
            homeAdapter.notifyItemRangeChanged(0, recyclerView.getChildCount());
        } catch (Exception e) {
            Log.e("error", e.toString() + "");
        }
    } else {
        try {
            homeAdapter = new HomeAdapter(getActivity(), homeBeanList, Home.
            this, Home.
            this, Home.
            this, profile_pic, Home.
            this, Home.
            this, page);
            loaderDiloag.dismissDiloag();
            recyclerView.setAdapter(homeAdapter);
            recyclerView.setNestedScrollingEnabled(false);
            homeAdapter.notifyDataSetChanged();
        } catch (Exception e) {
            Log.e("error", e.toString() + "");
        }
    }
Anisuzzaman Babla
  • 6,510
  • 7
  • 36
  • 53
Hitesh
  • 21
  • 2
  • Did you resolve this issue? I'm facing this problem, also tried everything but without luck – Limun Jun 27 '23 at 14:14

1 Answers1

1

Try this

private void removeBlinkAnimationWhenNewItemAdded(){
        ((SimpleItemAnimator)recyclerView).setSupportsChangeAnimations(false)
}
Abdurakhmon
  • 2,813
  • 5
  • 20
  • 41