Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thanks for series ! πŸ‘¨πŸ»β€πŸ’» here is quick suggestion #1

Open
ch8n opened this issue Dec 2, 2020 · 4 comments

Comments

@ch8n
Copy link

ch8n commented Dec 2, 2020

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)
 }
@codinginflow
Copy link
Owner

Thank you very much for the tips πŸ‘

@ch8n
Copy link
Author

ch8n commented Dec 7, 2020

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

@codinginflow
Copy link
Owner

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

comye1 added a commit to comye1/MVVMTodo that referenced this issue Apr 29, 2021
comye1 added a commit to comye1/MVVMTodo that referenced this issue Apr 29, 2021
comye1 added a commit to comye1/MVVMTodo that referenced this issue Apr 29, 2021
comye1 added a commit to comye1/MVVMTodo that referenced this issue Apr 29, 2021
comye1 added a commit to comye1/MVVMTodo that referenced this issue Apr 29, 2021
@SeanKotlin
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants