https://kotlinlang.org logo
#android
Title
# android
s

Sandesh Baliga

06/14/2020, 1:08 PM
I'm using a ListAdapter for one of my projects. And i noticed that submitting a large list of items adapter.submitList(200+ items), is blocking the UI thread. Diffutil calculation was supposed to happen in background thread according to documentation. I'm confused what's happening. Am I missing something?
s

Subhrajyoti Sen

06/14/2020, 2:18 PM
Can you share your implementation of the DiffUtil? Maybe something's going wrong there and the recyclerview has to update all 200+ items
👍 1
s

Sandesh Baliga

06/15/2020, 12:31 PM
j

Joost Klitsie

06/15/2020, 1:59 PM
Perhaps it is your RecyclerView within a NestedScrollView? I never really use it, but you should check if your items are all drawn, or only the visible ones
s

Sandesh Baliga

06/15/2020, 2:03 PM
Ya it's in nestedscolview but with nestedscollinhEnabled set to false, also after the lag is done, I'm able to scroll smoothly over the entire list of items. I'm guessing something going wrong while drawing UI. Not really sure what's that
j

Joost Klitsie

06/15/2020, 2:04 PM
can you check how many of the 100 views are drawn the first time?
s

Sandesh Baliga

06/15/2020, 2:12 PM
It's like, after submitList, it lags like 5-10 seconds, then suddenly all items are drawn. Entire list
j

Joost Klitsie

06/15/2020, 2:12 PM
I think that is the issue
💯 1
recyclerview should only draw the visible views
not the entire list
so perhaps your listView expands the whole height
instead of the viewport only
what might be because of the nesting
s

Sandesh Baliga

06/15/2020, 2:13 PM
Maybe because it's inside nestedrecycleeview.
j

Joost Klitsie

06/15/2020, 2:13 PM
yep, so you should check that out
s

Sandesh Baliga

06/15/2020, 2:14 PM
Is that actual behaviour? When a recyclerview is inside nestedrecycleeview with nested scrolll false, does it actually draw entire view?
j

Joost Klitsie

06/15/2020, 2:14 PM
I am not sure about it
s

Sandesh Baliga

06/15/2020, 2:14 PM
Ya probably. Checking it right away
Moving out of recyclerview
j

Joost Klitsie

06/15/2020, 2:14 PM
also I am not sure which flags to use within to avoid that
also you have the recyclerview nested within a linearlayout as well
s

Sandesh Baliga

06/15/2020, 2:14 PM
Nestedscrollview*
@Joost Klitsie damn bro that's the issue. I moved
I moved recyclerview out of nestedscrollview
And it's working fine now. Seems like recyclerview features aren't available inside nestedscrollview if nestedscollinhEnabled=false. Need to confirm on this though.
Outside of nestedscrollview, it's behaving normally. Thanks much man. I was not suspecting on nestedscrollview itself.
👍 1