private void showFeedback() { final int text = (model.getValue() != null) ? R.string.noteUpdated : R.string.noteErased; Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void computeEnablements() { count.setEnabled(countType.getValue() != CountType.NOT_COUNTED); maxCount.setEnabled(countType.getValue() == CountType.RANGE); }
public void propertyChange (final @Nonnull PropertyChangeEvent event) { final String propertyName = event.getPropertyName(); if (PROP_VALUE.equals(propertyName)) { select(values, property.getValue(), spinner); } else if (PROP_ENABLED.equals(propertyName)) { spinner.setEnabled(property.isEnabled()); } // no PROP_VALID, a Spinner is always valid } });
public void propertyChange (final @Nonnull PropertyChangeEvent event) { final String propertyName = event.getPropertyName(); if (PROP_VALUE.equals(propertyName)) { checkBox.setChecked(property.getValue()); } else if (PROP_ENABLED.equals(propertyName)) { checkBox.setEnabled(property.isEnabled()); } // no PROP_VALID, a Checkbox is always valid } });
public void propertyChange (final @Nonnull PropertyChangeEvent event) { final String propertyName = event.getPropertyName(); if (PROP_VALUE.equals(propertyName)) { select(values, property.getValue(), radiobuttons); } else if (PROP_ENABLED.equals(propertyName)) { for (final RadioButton radioButton : radiobuttons) { radioButton.setEnabled(property.isEnabled()); } } // no PROP_VALID, RadioButtons are always valid } });
public void propertyChange (final @Nonnull PropertyChangeEvent event) { final String propertyName = event.getPropertyName(); if (PROP_VALUE.equals(propertyName)) { final String value = property.getValue(); if (!editText.getText().toString().equals(value)) // avoid loops { editText.setText(value); } } else if (PROP_ENABLED.equals(propertyName)) { editText.setEnabled(property.isEnabled()); } if (PROP_VALID.equals(propertyName)) { // editText.setText(property.getValue()); } } });
/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull /* package */ static Cardinality getCardinality (final @Nonnull CountAndGenderFormModel model) { switch (model.getCountType().getValue()) { case NOT_COUNTED: return Cardinality.UNDEFINED; case EXACT: final int simpleCardinality = Integer.parseInt(model.getCount().getValue()); return Cardinality.valueOf(simpleCardinality); case APPROXIMATED: final int approxCardinality = Integer.parseInt(model.getCount().getValue()); return Cardinality.approxValueOf(approxCardinality); case RANGE: final int lower = Integer.parseInt(model.getCount().getValue()); final int upper = Integer.parseInt(model.getMaxCount().getValue()); return Cardinality.rangeOf(lower, upper); } throw new RuntimeException("Unexpected value: " + model.getCountType().getValue()); } }
public void editNote() { final LayoutInflater inflater = LayoutInflater.from(context); final View view = inflater.inflate(R.layout.dialog_observation_note, null); final EditText etNote = (EditText)view.findViewById(R.id.etNote); etNote.setText(model.getValue()); new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_info) .setTitle(R.string.noteHeader) .setView(view) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick (final @Nonnull DialogInterface dialog, final int whichButton) { model.setValue(etNote.getText().toString().trim()); showFeedback(); } }) .setNegativeButton(android.R.string.no, null) .setNeutralButton(R.string.erase, new DialogInterface.OnClickListener() { public void onClick (final @Nonnull DialogInterface dialog, final int whichButton) { model.setValue(null); showFeedback(); } }) .create().show(); }
checkBox.setChecked(property.getValue()); checkBox.setEnabled(property.isEnabled());
editText.setText(property.getValue()); editText.setEnabled(property.isEnabled());
select(values, property.getValue(), spinner);
select(values, property.getValue(), radiobuttons);