Last active
November 14, 2020 17:26
-
-
Save 1jGabriel/fa728bf03780aad28cb7b3fa519f3643 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
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end | |
import androidx.recyclerview.widget.RecyclerView | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import android.view.View.OnClickListener | |
import androidx.recyclerview.widget.DiffUtil | |
import androidx.recyclerview.widget.ListAdapter | |
class ${NAME}( | |
private val click: () -> Unit | |
) : ListAdapter<${Model_Class}, ${NAME}.${ViewHolder_Class}>( | |
${Model_Class}DC() | |
) { | |
override fun onCreateViewHolder( | |
parent: ViewGroup, | |
viewType: Int | |
) = ${ViewHolder_Class}( | |
${Binding_view}.inflate( | |
LayoutInflater.from( | |
parent.context | |
), | |
parent, | |
false | |
), | |
action | |
) | |
override fun onBindViewHolder( | |
holder: ${ViewHolder_Class}, | |
position: Int | |
) = holder.bind( | |
getItem(position) | |
) | |
inner class ${ViewHolder_Class}( | |
itemView: ${Binding_view}, | |
private val action: () -> Unit | |
) : RecyclerView.ViewHolder(itemView.root) { | |
fun bind(item: ${Model_Class}) { | |
with(itemView) { | |
// TODO: Bind the data with View | |
} | |
} | |
} | |
} | |
private class ${Model_Class}DC : DiffUtil.ItemCallback<${Model_Class}>() { | |
override fun areItemsTheSame( | |
oldItem: ${Model_Class}, | |
newItem: ${Model_Class} | |
): Boolean { | |
TODO( | |
"not implemented" | |
) | |
} | |
override fun areContentsTheSame( | |
oldItem: ${Model_Class}, | |
newItem: ${Model_Class} | |
): Boolean { | |
TODO( | |
"not implemented" | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment