Untitled

mail@pastecode.io avatar
unknown
kotlin
a year ago
819 B
1
Indexable
Never
    private fun getShiftData(){
        profileViewModel.getAllShiftPlan().observe(viewLifecycleOwner){
            it?.let {
                for (data in it){
                    shiftHourArrayList.add(data.hour)
                }

                val startHour = shiftHourArrayList.firstOrNull()?.split(":")?.getOrNull(0)?.toInt() ?: 0
                val endHour = shiftHourArrayList.lastOrNull()?.split(":")?.getOrNull(0)?.toInt() ?: 0

                val totalHour = endHour-startHour

                binding.calendarHourTextView.text = "${totalHour}h / ${shiftHourArrayList.first()} - ${shiftHourArrayList.last()}"
                binding.calendarFragmentShiftTitleHourTextView.text = "${totalHour}h / ${shiftHourArrayList.first()} - ${shiftHourArrayList.last()}"
            }

        }
    }