Skip to content

Instantly share code, notes, and snippets.

@jifferon
Last active August 29, 2017 20:22
Show Gist options
  • Save jifferon/3fce9b376359cc9787f0162c7bf0d195 to your computer and use it in GitHub Desktop.
Save jifferon/3fce9b376359cc9787f0162c7bf0d195 to your computer and use it in GitHub Desktop.
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseHolder {
val inflater = LayoutInflater.from(parent.context)
val itemView: View
val dataHolder: BaseHolder = when(viewType) {
Type.NORMAL.value -> {
itemView = inflater.inflate(normalCellLayout, parent, false)
NormalGoodHolder(itemView, callback)
}
Type.SALE.value -> {
itemView = inflater.inflate(saleCellLayout, parent, false)
SaleGoodHolder(itemView, callback)
}
else -> {
throw IllegalStateException("Something went horribly wrong")
}
}
return dataHolder
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment