Created
June 9, 2021 04:56
-
-
Save ngima/679637bc4c200b96ac3a3b0b9ed6bc73 to your computer and use it in GitHub Desktop.
Android Live Templates
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
//radapter | |
class $adapter$ : androidx.recyclerview.widget.RecyclerView.Adapter<$adapter$.ViewHolder>() { | |
var data: MutableList<$model$> = mutableListOf() | |
set(value) { | |
field = value | |
notifyDataSetChanged() | |
} | |
override fun onCreateViewHolder(parent: android.view.ViewGroup, viewType: Int): ViewHolder = | |
ViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.$item_layout_id$, parent, false)) | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(data[position]) | |
override fun getItemCount() = data.size | |
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | |
fun bind(item: $model$) = with(itemView) { | |
// TODO: Bind the data with View | |
} | |
} | |
} |
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
//sback | |
com.google.android.material.snackbar.Snackbar.make($parentlayout$, "$message$", Snackbar.LENGTH_LONG) | |
.show() | |
//snackaction | |
com.google.android.material.snackbar.Snackbar.make($parentlayout$, "$message$", Snackbar.LENGTH_LONG) | |
.setAction("$actionname$", {view-> | |
} | |
.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment