MVVMTodo icon indicating copy to clipboard operation
MVVMTodo copied to clipboard

Thanks for series ! 👨🏻‍💻 here is quick suggestion

Open ch8n opened this issue 5 years ago • 4 comments

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)
 }

ch8n avatar Dec 02 '20 09:12 ch8n

Thank you very much for the tips 👍

codinginflow avatar Dec 04 '20 19:12 codinginflow

Is this repo open for contributions? I can open some PR or put some suggestions that you can use in the future projects?

ch8n avatar Dec 07 '20 16:12 ch8n

I don't want to change the code of this repo because it would break the tutorial but suggestions are more than welcome!

codinginflow avatar Dec 07 '20 18:12 codinginflow

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.

SeanKotlin avatar May 30 '21 17:05 SeanKotlin