simplyify defaulting to hypo tt.

This commit is contained in:
Johannes Mockenhaupt 2018-07-01 18:51:56 +02:00
parent 5df054a999
commit 290effcd7c
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -126,6 +126,13 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
startEatingSoonTTCheckbox = view.findViewById(R.id.newcarbs_eating_soon_tt);
startEatingSoonTTCheckbox.setOnCheckedChangeListener(this);
startHypoTTCheckbox = view.findViewById(R.id.newcarbs_hypo_tt);
BgReading bgReading = DatabaseHelper.actualBg();
if (bgReading != null && bgReading.value < 72) {
startHypoTTCheckbox.setChecked(true);
// see #onCheckedChanged
startHypoTTCheckbox.setOnClickListener(this);
}
startHypoTTCheckbox.setOnCheckedChangeListener(this);
editTime = view.findViewById(R.id.newcarbs_time);
@ -155,13 +162,6 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
notesLayout.setVisibility(SP.getBoolean(R.string.key_show_notes_entry_dialogs, false) ? View.VISIBLE : View.GONE);
notesEdit = view.findViewById(R.id.newcarbs_notes);
BgReading bgReading = DatabaseHelper.actualBg();
if (bgReading != null && bgReading.value < 72) {
startHypoTTCheckbox.setOnCheckedChangeListener(null);
startHypoTTCheckbox.setChecked(true);
startHypoTTCheckbox.setOnClickListener(this);
}
setCancelable(true);
getDialog().setCanceledOnTouchOutside(false);
return view;
@ -230,13 +230,13 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// Logic to disable a selected radio when pressed. When a checked radio
// is pressed, no CheckChanged event is trigger, so register a Click event
// Logic to disable a selected radio when pressed: when a checked radio
// is pressed, no CheckChanged event is triggered, so register a Click event
// when checking a radio. Since Click events come after CheckChanged events,
// the Click event is triggered immediately after this. Thus, set toggingTT
// the Click event is triggered immediately after this. Thus, set togglingTT
// var to true, so that the first Click event fired after this is ignored.
// Radios remove themselves from Click events once unchecked.
// Since radios are not in a group, manually update their state.
// Since radios are not in a group, their state is manually updated here.
switch (buttonView.getId()) {
case R.id.newcarbs_activity_tt:
togglingTT = true;