This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
holder.itemView.setOnClickListener { | |
// handle the click here if you need it | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun removeItems(myUpdatedList: List<Any>) { | |
this.dataParameters = ArrayList<Any>(myUpdatedList) | |
notifyDataSetChanged() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun getItemId(position: Int): Long { | |
return myList[position].hashCode().toLong() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { | |
val itemView: View | |
return if (viewType == CHILD_TYPE) { | |
itemView = LayoutInflater.from(parent.context).inflate(R.layout.child_type_layout, parent, false) | |
ListItemViewHolder(itemView) | |
} else { | |
itemView = LayoutInflater.from(parent.context).inflate(R.layout.section_type_layout, parent, false) | |
ListSectionViewHolder(itemView) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun getItemViewType(position: Int): Int { | |
return if (myList[position] is sectionObject) { | |
CHILD_TYPE | |
} else { | |
SECTION_TYPE | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val myAdapter = MyAdapter(dataList) | |
myAdapter.setHasStableIds(true) | |
myRecyclerView.apply { | |
layoutManager = LinearLayoutManager(this) | |
adapter = myAdapter | |
adapter.notifyDataSetChanged() | |
} |