Skip to content

Instantly share code, notes, and snippets.

@baggednismo
Created May 1, 2020 13:03
Show Gist options
  • Save baggednismo/9bed0d2167e336fb024e1c2528a1b588 to your computer and use it in GitHub Desktop.
Save baggednismo/9bed0d2167e336fb024e1c2528a1b588 to your computer and use it in GitHub Desktop.
class ParentItemsViewHolder(inflater: LayoutInflater, parent: ViewGroup, itemListener: ItemListener) :
RecyclerView.ViewHolder(inflater.inflate(R.layout.card_parent_item, parent, false)) {
private var itemListener: ItemListener? = null
private var cardTitle: TextView? = null
private var recyclerItem: RecyclerView? = null
init {
cardTitle = itemView.findViewById(R.id.app_title)
recyclerItem = itemView.findViewById(R.id.id_card_child_items)
this.itemListener = itemListener
}
fun bind(card: ParentItemModel) {
cardTitle?.setText("App: ${card.app_package}")
recyclerItem?.apply {
layoutManager = LinearLayoutManager(context)
val itemDecoration = DividerItemDecoration(context, LinearLayoutManager.VERTICAL)
itemDecoration.setDrawable(context.getDrawable(R.drawable.divider_thin)!!)
addItemDecoration(itemDecoration)
adapter = ChildItemsAdapter(card.errors, itemListener!!)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment