Created
July 19, 2019 13:31
-
-
Save kishansinhparmar/f5a263e063af303c59c9a933c9290d62 to your computer and use it in GitHub Desktop.
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
class $CLASS_NAME$Adapter(private var list: MutableList<$DT$>) : | |
RecyclerView.Adapter<$CLASS_NAME$Adapter.$CLASS_NAME$ViewHolder>() { | |
override fun getItemCount() = list.size | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): $CLASS_NAME$ViewHolder { | |
return $CLASS_NAME$ViewHolder( | |
LayoutInflater.from(parent.context).inflate( | |
R.layout.$LAYOUT_NAME$, | |
parent, | |
false | |
) | |
) | |
} | |
override fun onBindViewHolder(holder: $CLASS_NAME$ViewHolder, position: Int) { | |
list[holder.adapterPosition] | |
holder.onBind(holder.adapterPosition) | |
} | |
class $CLASS_NAME$ViewHolder(view: View) : RecyclerView.ViewHolder(view) { | |
view.iChooseLan_imCountry | |
fun onBind(position: Int){ | |
itemView.setOnClickListener { | |
} | |
} | |
} | |
fun insert(newItem: $DT$) { | |
list.add(newItem) | |
notifyItemInserted(list.size + 1) | |
} | |
fun remove(position: Int) { | |
list.removeAt(position) | |
notifyItemRemoved(position) | |
} | |
fun removeAll() { | |
list.removeAll { true } | |
notifyDataSetChanged() | |
} | |
fun update(position: Int, updated: $DT$) { | |
list[position] = updated | |
notifyItemChanged(position) | |
} | |
fun getMyList(): MutableList<$DT$> { | |
return list | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment