Repository: corona-warn-app/cwa-app-android
File: Corona-Warn-App/src/main/java/de/rki/coronawarnapp/statistics/ui/homecards/StatisticsHomeCard.kt (Kotlin)

Code before:

    private val statisticsCardAdapter by lazy { StatisticsCardAdapter() }

    override val viewBinding = lazy {
        HomeStatisticsScrollcontainerBinding.bind(itemView).apply {
            statisticsRecyclerview.apply {
                setHasFixedSize(false)
                adapter = statisticsCardAdapter
                layoutManager = statisticsLayoutManager
                itemAnimator = DefaultItemAnimator()
                addItemDecoration(
                    StatisticsCardPaddingDecorator(
                        startPadding = R.dimen.spacing_small,
                        cardDistance = R.dimen.spacing_tiny,
                        verticalPadding = R.dimen.spacing_tiny
                    )
                )
                addOnScrollListener(object : RecyclerView.OnScrollListener() {
                    override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
                        super.onScrolled(recyclerView, dx, dy)
                        recyclerView.postDelayed(
                            {
                                val visibleItem = statisticsLayoutManager.findFirstCompletelyVisibleItemPosition()
                                val viewHolder = recyclerView.findViewHolderForAdapterPosition(visibleItem)
                                viewHolder?.itemView?.requestFocus()
                                viewHolder?.itemView?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
                                viewHolder?.itemView?.announceForAccessibility(
                                    "$visibleItem of ${statisticsCardAdapter.itemCount}"
                                )
                            },
                            1000
                        )
                    }
                })
            }
            if (resources.isPhone()) {
                PagerSnapHelper().attachToRecyclerView(statisticsRecyclerview)
            }
        }
    }

    override val onBindData: HomeStatisticsScrollcontainerBinding.(
        item: Item,
        payloads: List<Any>
    ) -> Unit = { item, payloads ->
        val curItem = payloads.filterIsInstance<Item>().lastOrNull() ?: item

        savedStateKey = "stats:${curItem.stableId}"

        curItem.data.items.map {
            when (it) {

Review comment (suggestion):
these another KTX for `postDelayed` , could you please use it? it is more Kotlin friendly 
```kotlin
recyclerView.postDelayed(1_000L) {
 // Code 
}
```

Code after:

    private val statisticsCardAdapter by lazy { StatisticsCardAdapter() }

    override val viewBinding = lazy {
        HomeStatisticsScrollcontainerBinding.bind(itemView).apply {
            statisticsRecyclerview.apply {
                setHasFixedSize(false)
                adapter = statisticsCardAdapter
                layoutManager = statisticsLayoutManager
                itemAnimator = DefaultItemAnimator()
                addItemDecoration(
                    StatisticsCardPaddingDecorator(
                        startPadding = R.dimen.spacing_small,
                        cardDistance = R.dimen.spacing_tiny,
                        verticalPadding = R.dimen.spacing_tiny
                    )
                )
                addOnScrollListener(object : RecyclerView.OnScrollListener() {
                    override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
                        super.onScrolled(recyclerView, dx, dy)
                        val visibleItem = statisticsLayoutManager.findFirstCompletelyVisibleItemPosition()
                        val viewHolder = recyclerView.findViewHolderForAdapterPosition(visibleItem)
                        viewHolder?.itemView?.requestFocus()
                        viewHolder?.itemView?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
                    }
                })
            }
            if (resources.isPhone()) {
                PagerSnapHelper().attachToRecyclerView(statisticsRecyclerview)
            }
        }
    }

    override val onBindData: HomeStatisticsScrollcontainerBinding.(
        item: Item,
        payloads: List<Any>
    ) -> Unit = { item, payloads ->
        val curItem = payloads.filterIsInstance<Item>().lastOrNull() ?: item

        savedStateKey = "stats:${curItem.stableId}"

        curItem.data.items.map {
            when (it) {
                is GlobalStatsItem -> GlobalStatisticsCardItem(it, curItem.onClickListener)
                is AddStatsItem -> AddLocalStatisticsCardItem(it, curItem.onClickListener)
                is LocalStatsItem -> LocalStatisticsCardItem(it, curItem.onClickListener, curItem.onRemoveListener)
            }
        }.let {
            statisticsCardAdapter.update(it)
        }
    }