Skip to content

Instantly share code, notes, and snippets.

@OmarKRostom
Last active March 17, 2021 04:17
Show Gist options
  • Save OmarKRostom/f3c9beda0338c7ee2fc6c7178f884fea to your computer and use it in GitHub Desktop.
Save OmarKRostom/f3c9beda0338c7ee2fc6c7178f884fea to your computer and use it in GitHub Desktop.
Third step creating an arc layout manager
private fun fill(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
detachAndScrapAttachedViews(recycler ?: return)
for (itemIndex in 0 until itemCount) {
val view = recycler.getViewForPosition(itemIndex)
addView(view)
val viewWidth = pxFromDp(context, ITEM_WIDTH)
val viewHeight = pxFromDp(context, ITEM_HEIGHT)
measureChildWithMargins(view ?: return, viewWidth.toInt(), viewHeight.toInt())
}
recycler.scrapList.toList().forEach {
recycler.recycleView(it.itemView)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment