get SP value and check if it is already set
This commit is contained in:
parent
67ed699ca5
commit
ef171dbccd
2 changed files with 5 additions and 4 deletions
|
@ -46,7 +46,8 @@ public class SWRadioButton extends SWItem {
|
||||||
layout.removeAllViews();
|
layout.removeAllViews();
|
||||||
String[] labels = context.getResources().getStringArray(labelsArray);
|
String[] labels = context.getResources().getStringArray(labelsArray);
|
||||||
String[] values = context.getResources().getStringArray(valuesArray);
|
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 = new RadioGroup(context);
|
||||||
radioGroup.clearCheck();
|
radioGroup.clearCheck();
|
||||||
|
@ -60,6 +61,8 @@ public class SWRadioButton extends SWItem {
|
||||||
RadioButton rdbtn = new RadioButton(context);
|
RadioButton rdbtn = new RadioButton(context);
|
||||||
rdbtn.setId((row * 2) + i);
|
rdbtn.setId((row * 2) + i);
|
||||||
rdbtn.setText(labels[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()]);
|
// log.debug("Button ["+labels[i]+"]="+rdbtn.getId()+" value is "+values[rdbtn.getId()]);
|
||||||
radioGroup.addView(rdbtn);
|
radioGroup.addView(rdbtn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,9 +180,7 @@ public class SetupWizardActivity extends AppCompatActivity {
|
||||||
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
radioGroupItems.getRadioGroup().setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||||
log.debug("Validate radio input:" +currentScreen.validator.isValid());
|
radioGroupItems.save(radioGroupItems.getCheckedValue());
|
||||||
radioGroupItems.save();
|
|
||||||
log.debug("Preference value after save is:"+ SP.getString(radioGroupItems.preferenceId, "unset"));
|
|
||||||
nextAllowed = currentScreen.validator.isValid();
|
nextAllowed = currentScreen.validator.isValid();
|
||||||
if(showPage == screens.size() - 1 && nextAllowed) {
|
if(showPage == screens.size() - 1 && nextAllowed) {
|
||||||
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
((Button) findViewById(R.id.finish_button)).setVisibility(View.VISIBLE);
|
||||||
|
|
Loading…
Reference in a new issue