Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
sealed class DataItem {
abstract val id
data class Header(var item: T)) {
ovveride val id = 1
} : : DataItem()
data class Product(var item : R) {
ovveride val id =2
} : DataItem()
}
When all of items are the same for instance from Product type, adapter.currentList is the size as expected :
adapter.submitList(products)
Log.d(TAG, adapter.currentList.size.toString()) // Result is 33
It prints size of products which are submitted. For instance 33.
Now imagine first I submit a header in onCreateView of Fragment :
adapter.submitList(header)
Log.d(TAG, adapter.currentList.size.toString()). //Result is 1
And then from a api response I submit my products
adapter.submitList(header + products)
Now the current list of Adapter is just one ( adapter.currentList.size = 1). Seems that submitList works async
Then if I add a delay it works as expected and size is 34 :
CoroutineScope(Dispatchers.Main).launch {
adapter.submitList(header + products)
delay(2000)
Log.d(TAG, adapter.currentList.size.toString()). //Result is 34
}
Why submitList is async in this case when we have a different header and not all item the same?