I apologize for the bad title because i have difficult to find the correct way to describe my issue. So i will try to achieve it by a code:
class CompetitionDetailsViewHolder() : RecyclerViewHolder(binding.root) {
fun bind(competitionDetailsData: CompetitionDetailsData) {
binding.apply {
val topItemSections = sectionsMap?.get(true)?.take(2) ?: emptyList()
setSectionVisibility(topItemSections) {.....}
....
....
}
}
private fun setSectionVisibility(
sections: List<GeneralCompetitionDetailsSection>,
block: (sections: List<GeneralCompetitionDetailsSection>, isVisible: Boolean) -> Unit)
{
block(sections, sections.isNotEmpty())
}
}
I can't understand how the code: setSectionVisibility(topItemSections) {.....} works? The issue i see here is: binding.apply gets a lambda expression. inside the lambda expression the keyword this refers to binding object, therefore i can't understand how the method setSectionVisibility which belongs to CompetitionDetailsViewHolder class can be called by implicit this (which as i already say refers to binding object)?