Skip to content

Instantly share code, notes, and snippets.

Last active December 7, 2020 04:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Dmuasya/e60a0eac0e0af3ee47edea95eda172bd to your computer and use it in GitHub Desktop.
package com.dennis.doublepull.adapter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.dennis.doublepull.R
class ScrollAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return if (viewType == TYPE_HEADER) {
.inflate(R.layout.header, parent, false))
} else ScrollViewHolder(LayoutInflater.from(parent.context)
.inflate(R.layout.item, parent, false))
override fun getItemViewType(position: Int): Int {
return if (position == 0) {
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
// do nothing
override fun getItemCount(): Int {
private inner class ScrollViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
private inner class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
companion object {
private const val TYPE_NORMAL = 1000
private const val TYPE_HEADER = 2000
private const val DEFAULT_SIZE = 31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment