Hello, I have a question: Based on state [NONE, PA...
# codereview
k
Hello, I have a question: Based on state [NONE, PAUSED, RUNNING], I need to enable and disable the 4 buttons [StartTime, StartBreak, EndBreak, EndTime], in fragment. So what is the best way to handle it? Shared the current code below: NOTE: All the 4 button should be visible all the time, but based on state, we need to disable button click and set the alpha so it looks disable. --------------------------------------- 1. NONE:
Copy code
binding.startTimeButton.apply {
            isEnabled = true
            alpha = 1f
        }
        binding.startBreakButton.apply {
            isEnabled = false
            alpha = 0.5F
        }
        binding.endBreakButton.apply {
            isEnabled = false
            alpha = 0.5f
        }
        binding.endTimeButton.apply {
            isEnabled = false
            alpha = 0.5f
        }
2. PAUSED
Copy code
binding.startTimeButton.apply {
            isEnabled = false
            alpha = 0.5f
        }
        binding.startBreakButton.apply {
            isEnabled = false
            alpha = 0.5f
        }

        binding.endBreakButton.apply {
            isEnabled = true
            alpha = 1f
        }
        binding.endTimeButton.apply {
            isEnabled = true
            alpha = 1f
        }
3. RUNNING
Copy code
binding.startTimeButton.apply {
            isEnabled = false
            alpha = 0.5f
        }
        binding.startBreakButton.apply {
            isEnabled = true
            alpha = 1f
        }
        binding.endBreakButton.apply {
            isEnabled = false
            alpha = 0.5f
        }
        binding.endTimeButton.apply {
            isEnabled = true
            alpha = 1f
        }