Robert Menke
03/18/2022, 9:56 PMcontentType
parameter for items
that I can understand. Let’s say I have a LazyColumn
where each item is a FooItem
. What am I supposed to be supplying to contentType
?
fun items(
count: Int,
key: ((index: Int) -> Any)? = null,
contentType: (index: Int) -> Any? = { null },
itemContent: @Composable LazyItemScope.(index: Int) -> Unit
) {
error("The method is not implemented")
}
Desmond Teo
03/19/2022, 4:28 AMa factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.somewhat similar to RecyclerView adapter’s
getItemViewType
, where it uses the view type to determine the type of ViewHolder for each item, I’m guessing you can return a different value for each type of composable you are calling for the items. If all the items are using the same composable, then it shouldn’t matter.Paul Woitaschek
03/19/2022, 9:15 AMRobert Menke
03/19/2022, 1:11 PMAndrey Kulikov
03/20/2022, 1:50 AMStylianos Gakis
08/05/2022, 3:32 PMtype
it makes me think that if I have two different items with both the same type, a String
(say “asd” and “asdf”) then it’d be considered the same. But I imagine it doesn’t actually look at the Type
but it does an .equals check between them?Andrey Kulikov
08/05/2022, 3:34 PMStylianos Gakis
08/05/2022, 3:52 PM.equals()
as I assumed. I only mentioned that the docs, specifically the text
* @param contentType a factory of the content types for the item. The item compositions of
* the same type could be reused more efficiently. Note that null is a valid type and items of such
* type will be considered compatible.
Did make me think for a second that it is may be referring to the type of object which is returned there with all the mentions of the word “type” in there. But that is most likely me doing a bad interpretation of what is being said.
Out of pure curiosity, where is the source code where that check is done, I’ve tried traversing cs.android.com and I could not find anything blob thinking upside down The one I am interested in shows “This method is not implemented” so I am not sure how I could take a look myself.Andrey Kulikov
08/05/2022, 5:26 PM