MVVMTodo
MVVMTodo copied to clipboard
Thanks for series ! 👨🏻💻 here is quick suggestion
Hi, @codinginflow Nice tutorial series,
Just a suggestion you can reduce some nesting using this with than apply
class TasksViewHolder(private val binding: ItemTaskBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(task: Task) {
binding.apply {
checkBoxCompleted.isChecked = task.completed
textViewName.text = task.name
textViewName.paint.isStrikeThruText = task.completed
labelPriority.isVisible = task.important
}
}
}
class TasksViewHolder(private val binding: ItemTaskBinding) : RecyclerView.ViewHolder(binding.root) {
fun bind(task: Task) = with(binding) {
checkBoxCompleted.isChecked = task.completed
textViewName.text = task.name
textViewName.paint.isStrikeThruText = task.completed
labelPriority.isVisible = task.important
}
}
[Edit1]
Nested scoped extension chaining is are considered not a good practice, checkout some awesome kotlin tips be from Huyen talk KotlinConf 2019 youtube.com/watch?v=YeqGfKmJM_g
//TaskFragment
binding.apply {
recyclerViewTasks.apply {
adapter = taskAdapter
layoutManager = LinearLayoutManager(requireContext())
setHasFixedSize(true)
}
}
to
//TaskFragment
binding.recyclerViewTasks.apply {
adapter = taskAdapter
layoutManager = LinearLayoutManager(requireContext())
setHasFixedSize(true)
}
Thank you very much for the tips 👍
Is this repo open for contributions? I can open some PR or put some suggestions that you can use in the future projects?
I don't want to change the code of this repo because it would break the tutorial but suggestions are more than welcome!
Hi CodingInFlow,
Very happy to learn from your excellent tutorial part by part. Now, I have faced some error after added Hiton dagger in your Video 4.
the error code:: as follow
Execution failed for task ':app:kaptDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.InvocationTargetException (no error message)
- Try: Run with --stacktrace option to get the stack trace. Run with --scan to get full insights.