mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2024-12-16 18:29:26 +01:00
Recreate adapter when text color changes so it updates correctly
This commit is contained in:
parent
b98d9c9e42
commit
eee6565d72
@ -45,31 +45,33 @@ class TimerFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
view = (inflater.inflate(R.layout.fragment_timer, container, false) as ViewGroup).apply {
|
view = (inflater.inflate(R.layout.fragment_timer, container, false) as ViewGroup).apply {
|
||||||
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, timers_list, ::refreshTimers, ::openEditTimer)
|
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
|
|
||||||
timers_list.adapter = timerAdapter
|
|
||||||
timers_list.itemAnimator = DisabledItemChangeAnimator()
|
timers_list.itemAnimator = DisabledItemChangeAnimator()
|
||||||
|
|
||||||
timer_add.setOnClickListener {
|
timer_add.setOnClickListener {
|
||||||
activity?.run {
|
activity?.run {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
openEditTimer(createNewTimer())
|
openEditTimer(createNewTimer())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshTimers()
|
|
||||||
}
|
}
|
||||||
|
initAdapter()
|
||||||
|
refreshTimers()
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initAdapter() {
|
||||||
|
timerAdapter = TimerAdapter(requireActivity() as SimpleActivity, view.timers_list, ::refreshTimers, ::openEditTimer)
|
||||||
|
view.timers_list.adapter = timerAdapter
|
||||||
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
requireContext().updateTextColors(timer_fragment)
|
requireContext().updateTextColors(timer_fragment)
|
||||||
val configTextColor = requireContext().config.textColor
|
val configTextColor = requireContext().config.textColor
|
||||||
if (storedTextColor != configTextColor) {
|
if (storedTextColor != configTextColor) {
|
||||||
(view.timers_list.adapter as TimerAdapter).updateTextColor(configTextColor)
|
initAdapter()
|
||||||
|
timerAdapter.updateTextColor(configTextColor)
|
||||||
|
refreshTimers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user