androidx.RecyclerView ListAdapter very slow

11
March 16, 2019, at 09:20 AM

I am using the ListAdapter with RecyclerView and under certain circumstances the app becomes extremely slow -- it freezes for 10 seconds with a list of 1000 items.

The circumstances are, that at first I submit a list with 1000 items (at first submit its fast as expected) and then I submit the same list again, but sorted differently.

By debugging a lot, I finally found out, that the ListAdapter triggers a notifyItemRangeChanged(0, 999), so basically for the complete list. I read elsewhere (here and here), that one should not do this, because it makes the RecyclerView slow -- which apparently is true -- however, I cannot influence the behaviour of the ListAdapter.

Does anyone have a solution for that? I don't want to remove ListAdapter again, because for most other usecases it is fast and handy, doing various animations etc. automatically.

EDIT - some code

There is nothing fancy about the code, basically it's like that:

RecyclerView mListView;
EnryListAdapter mEntryListAdapter; // <-- extends ListAdapter<Entry, VH>
...
    mEntryListAdapter = new EntryListAdapter();
    mListView.setAdapter(mEntryListAdapter);
    mListView.setLayoutManager(new LinearLayoutManager(this));
    mListView.setHasFixedSize(true);
    ((DefaultItemAnimator) mListView.getItemAnimator()).setSupportsChangeAnimations(false);
    List<Entry> entryList = getEntryList(); // <-- list with 1000 entries
    mEntryListAdapter.submitList(entryList); // <-- first submit is fast
    entryList = getDifferentlySortedEntryList(); // <-- list with same entries, sorted differently
    mEntryListAdapter.submitList(entryList); // <-- freezes app for over 10 seconds
READ ALSO
Detect TV on Android

Detect TV on Android

I need to disable Admob ads if user uses app on some device based on Android or other TV box device with mobile Android which is connected to the TV, for example X92, H96, Beelink GT1I found a way to determine Android TV device and disabled ads for these devices

25
MySQL - divide results of count function into columns derived from a separate column

MySQL - divide results of count function into columns derived from a separate column

I recently posted this within a different page of Stack Exchange but believe this to be the more appropriate place for it

32
Spring boot JPA @Query with like and in

Spring boot JPA @Query with like and in

I'm trying to make a method in Repository that will be able to give me list of users, But didn't return a valueThis is my method public interface ProductRepository extends JpaRepository { @Query(value = "select * from mmall_product m where m

44
Stored procedure to get data in MySQL which I can&#39;t get through Eloquent quickly

Stored procedure to get data in MySQL which I can't get through Eloquent quickly

I have a table called device which is related to another one called pos and these two are related using a many-to-many relationshipThe thing is I need to query all the devices that are installed (pos) but then I have to query what's the previous device...

37