EditQuickWizardDialog -> jetpack #2

This commit is contained in:
Milos Kozak 2021-02-02 20:25:15 +01:00
parent 99185f3d1f
commit e7d58a8f84
2 changed files with 9 additions and 9 deletions

View file

@ -21,8 +21,6 @@ import info.nightscout.androidaps.utils.extensions.setEnableForChildren
import info.nightscout.androidaps.utils.extensions.setSelection import info.nightscout.androidaps.utils.extensions.setSelection
import info.nightscout.androidaps.utils.wizard.QuickWizard import info.nightscout.androidaps.utils.wizard.QuickWizard
import info.nightscout.androidaps.utils.wizard.QuickWizardEntry import info.nightscout.androidaps.utils.wizard.QuickWizardEntry
import kotlinx.android.synthetic.main.okcancel.*
import kotlinx.android.synthetic.main.overview_editquickwizard_dialog.*
import org.json.JSONException import org.json.JSONException
import javax.inject.Inject import javax.inject.Inject
@ -59,7 +57,7 @@ class EditQuickWizardDialog : DaggerDialogFragment(), View.OnClickListener {
position = bundle.getInt("position", -1) position = bundle.getInt("position", -1)
} }
val entry = if (position == -1) quickWizard.newEmptyItem() else quickWizard[position] val entry = if (position == -1) quickWizard.newEmptyItem() else quickWizard[position]
ok.setOnClickListener { binding.okcancel.ok.setOnClickListener {
try { try {
entry.storage.put("buttonText", binding.buttonEdit.text.toString()) entry.storage.put("buttonText", binding.buttonEdit.text.toString())
entry.storage.put("carbs", SafeParse.stringToInt(binding.carbsEdit.text.toString())) entry.storage.put("carbs", SafeParse.stringToInt(binding.carbsEdit.text.toString()))
@ -80,12 +78,12 @@ class EditQuickWizardDialog : DaggerDialogFragment(), View.OnClickListener {
rxBus.send(EventQuickWizardChange()) rxBus.send(EventQuickWizardChange())
dismiss() dismiss()
} }
cancel.setOnClickListener { dismiss() } binding.okcancel.cancel.setOnClickListener { dismiss() }
// create an OnTimeSetListener // create an OnTimeSetListener
val fromTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute -> val fromTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
fromSeconds = (T.hours(hour.toLong()).secs() + T.mins(minute.toLong()).secs()).toInt() fromSeconds = (T.hours(hour.toLong()).secs() + T.mins(minute.toLong()).secs()).toInt()
from.text = dateUtil.timeString(DateUtil.toDate(fromSeconds)) binding.from.text = dateUtil.timeString(DateUtil.toDate(fromSeconds))
} }
binding.from.setOnClickListener { binding.from.setOnClickListener {
@ -98,7 +96,7 @@ class EditQuickWizardDialog : DaggerDialogFragment(), View.OnClickListener {
} }
} }
fromSeconds = entry.validFrom() fromSeconds = entry.validFrom()
from.text = dateUtil.timeString(DateUtil.toDate(fromSeconds)) binding.from.text = dateUtil.timeString(DateUtil.toDate(fromSeconds))
val toTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute -> val toTimeSetListener = TimePickerDialog.OnTimeSetListener { _, hour, minute ->
toSeconds = (T.hours(hour.toLong()).secs() + T.mins(minute.toLong()).secs()).toInt() toSeconds = (T.hours(hour.toLong()).secs() + T.mins(minute.toLong()).secs()).toInt()
@ -128,8 +126,8 @@ class EditQuickWizardDialog : DaggerDialogFragment(), View.OnClickListener {
binding.useSuperBolus.setSelection(entry.useSuperBolus()) binding.useSuperBolus.setSelection(entry.useSuperBolus())
binding.useTempTarget.setSelection(entry.useTempTarget()) binding.useTempTarget.setSelection(entry.useTempTarget())
use_cob_yes.setOnClickListener(this) binding.useCobYes.setOnClickListener(this)
use_cob_no.setOnClickListener(this) binding.useCobNo.setOnClickListener(this)
processCob() processCob()
} }

View file

@ -302,7 +302,9 @@
</RadioGroup> </RadioGroup>
<include layout="@layout/okcancel" /> <include
android:id="@+id/okcancel"
layout="@layout/okcancel" />
</LinearLayout> </LinearLayout>