Guest User

Untitled

a guest
Jan 19th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView,
  2. state: RecyclerView.State?) {
  3. val position = parent.getChildAdapterPosition(view)
  4. val adapter = parent.adapter
  5. if (adapter is EpoxyControllerAdapter) {
  6. val model = adapter.getModelAtPosition(position)
  7. //if you are using Epoxy's annotations
  8. when (model::class.java.superclass) {
  9. PhotoModel::class.java -> outRect.set(5, 5, 5, 5)
  10. CollectionModel::class.java -> outRect.set(10, 10, 10, 10)
  11. else -> outRect.setEmpty()
  12. }
  13. //if you are not using Epoxy's annotations
  14. /*when (model::class) {
  15. PhotoModel::class -> outRect.set(5, 5, 5, 5)
  16. CollectionModel::class-> outRect.set(10, 10, 10, 10)
  17. else -> outRect.setEmpty()
  18. }*/
  19. } else {
  20. outRect.setEmpty()
  21. }
  22. }
Add Comment
Please, Sign In to add comment