Closed JasonHezz closed 6 years ago
you can get the model at the position and use the model class to determine this.
If you give me more details I can try to be more specific.
Thanks it works.Here is a snippet for others who want to custom decoration
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView,
state: RecyclerView.State?) {
val position = parent.getChildAdapterPosition(view)
val adapter = parent.adapter
if (adapter is EpoxyControllerAdapter) {
val model = adapter.getModelAtPosition(position)
//if you are using Epoxy's annotations
when (model::class.java.superclass) {
PhotoModel::class.java -> outRect.set(5, 5, 5, 5)
CollectionModel::class.java -> outRect.set(10, 10, 10, 10)
else -> outRect.setEmpty()
}
//if you are not using Epoxy's annotations
/*when (model::class) {
PhotoModel::class -> outRect.set(5, 5, 5, 5)
CollectionModel::class-> outRect.set(10, 10, 10, 10)
else -> outRect.setEmpty()
}*/
} else {
outRect.setEmpty()
}
}
Looks good, glad you got it.
you should be able to do PhotoModel_::class
as well instead of going to the super class
Using this approach I only see the divider for a brief period during the animation, then it's gone. Any idea of what might be happening @elihart ? Or any other way to add dividers to some models, but not all? Thanks
After searching issues and wiki,I can't find a way to work out.In normal way, I use recyclerview.getViewType to define, but how can I implent it in Epoxy?