Commit 5cf8ed23 authored by Eliézer de Oliveira's avatar Eliézer de Oliveira

added function to verify if type view is header

parent b802f3dc
......@@ -8,6 +8,7 @@ import android.view.View
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import chat.rocket.android.chatrooms.adapter.RoomsAdapter
/**
* Adds a default or custom divider to specific item views from the adapter's data set.
......@@ -56,6 +57,9 @@ class DividerItemDecoration() : RecyclerView.ItemDecoration() {
if (isLastView(child, parent))
continue
if (isViewTypeHeader(child, parent))
continue
val params = child.layoutParams as RecyclerView.LayoutParams
val bottom = child.bottom + params.bottomMargin
......@@ -70,4 +74,9 @@ class DividerItemDecoration() : RecyclerView.ItemDecoration() {
val position = parent.getChildAdapterPosition(view)
return position == parent.adapter?.itemCount?.minus(1) ?: false
}
private fun isViewTypeHeader(view: View, parent: RecyclerView): Boolean {
val position = parent.getChildViewHolder(view).itemViewType
return position == RoomsAdapter.VIEW_TYPE_HEADER
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment