fix CareDialog rotation

This commit is contained in:
Milos Kozak 2020-03-04 22:51:50 +01:00
parent c30674036d
commit a8e8659e18

View file

@ -54,6 +54,8 @@ class CareDialog : DialogFragmentWithDate() {
super.onSaveInstanceState(savedInstanceState)
savedInstanceState.putDouble("actions_care_bg", actions_care_bg.value)
savedInstanceState.putDouble("actions_care_duration", actions_care_duration.value)
savedInstanceState.putInt("event", event)
savedInstanceState.putInt("options", options.ordinal)
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
@ -65,6 +67,11 @@ class CareDialog : DialogFragmentWithDate() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
savedInstanceState?.let {
event = savedInstanceState.getInt("event", R.string.error)
options = EventType.values()[savedInstanceState.getInt("options", 0)]
}
actions_care_icon.setImageResource(when (options) {
EventType.BGCHECK -> R.drawable.icon_cp_bgcheck
EventType.SENSOR_INSERT -> R.drawable.icon_cp_cgm_insert