Search code examples
androidandroid-recyclerviewconcatenationadapternotifydatasetchanged

With ConcatAdapter RecyclerView began flickering


I'm implemented additional webview before my previous list (string data and ImageView) and concatenate them with ConcatAdapter.

Now i have previous adapter (list of data), additional new one (webview), and adapter ConcatAdapter.

But any clicking, and any use of notifyDataSetChanged looks like refreshing all UI. I tried

((SimpleItemAnimator) recyclerViewList.getItemAnimator()).setSupportsChangeAnimations(false);

but no help with it. What could help with UI blinking?

The list of data on the fist adapter has string data and ImageView and mostly flickering ImageView. Before webview ImageView works fine.


Solution

  • A lot of hours but very simple solution:

    ConcatAdapter.Config config = new ConcatAdapter.Config.Builder()
         .setStableIdMode(ConcatAdapter.Config.StableIdMode.SHARED_STABLE_IDS).build();
    adapter1.setHasStableIds(true);
    adapter2.setHasStableIds(true);
    concatAdapter = new ConcatAdapter(config, adapter1, adapter2);