From ef171dbccdf0ba9e512dcaa0fc99e4b9709042d2 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Thu, 26 Apr 2018 16:13:08 +0300 Subject: [PATCH] get SP value and check if it is already set --- .../nightscout/androidaps/startupwizard/SWRadioButton.java | 5 ++++- .../androidaps/startupwizard/SetupWizardActivity.java | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java index eea12eabf5..173595538c 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SWRadioButton.java @@ -46,7 +46,8 @@ public class SWRadioButton extends SWItem { layout.removeAllViews(); String[] labels = context.getResources().getStringArray(labelsArray); String[] values = context.getResources().getStringArray(valuesArray); - + // Get if there is already value in SP + String previousValue = SP.getString(preferenceId, "unset"); radioGroup = new RadioGroup(context); radioGroup.clearCheck(); @@ -60,6 +61,8 @@ public class SWRadioButton extends SWItem { RadioButton rdbtn = new RadioButton(context); rdbtn.setId((row * 2) + i); rdbtn.setText(labels[i]); + if(previousValue.equals(values[i])) + rdbtn.setChecked(true); // log.debug("Button ["+labels[i]+"]="+rdbtn.getId()+" value is "+values[rdbtn.getId()]); radioGroup.addView(rdbtn); } diff --git a/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java b/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java index e695f87148..90421fa667 100644 --- a/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/startupwizard/SetupWizardActivity.java @@ -180,9 +180,7 @@ public class SetupWizardActivity extends AppCompatActivity { radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { - log.debug("Validate radio input:" +currentScreen.validator.isValid()); - radioGroupItems.save(); - log.debug("Preference value after save is:"+ SP.getString(radioGroupItems.preferenceId, "unset")); + radioGroupItems.save(radioGroupItems.getCheckedValue()); nextAllowed = currentScreen.validator.isValid(); if(showPage == screens.size() - 1 && nextAllowed) { ((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);