use of org.odk.collect.android.formentry.ODKView in project collect by opendatakit.
the class FormEntryActivity method onNumberPickerValueSelected.
@Override
public void onNumberPickerValueSelected(int widgetId, int value) {
if (currentView != null) {
for (QuestionWidget qw : ((ODKView) currentView).getWidgets()) {
if (qw instanceof RangePickerIntegerWidget && widgetId == qw.getId()) {
((RangePickerIntegerWidget) qw).setNumberPickerValue(value);
widgetValueChanged(qw);
return;
} else if (qw instanceof RangePickerDecimalWidget && widgetId == qw.getId()) {
((RangePickerDecimalWidget) qw).setNumberPickerValue(value);
widgetValueChanged(qw);
return;
}
}
}
}
use of org.odk.collect.android.formentry.ODKView in project collect by opendatakit.
the class FormEntryActivity method widgetValueChanged.
@Override
public void widgetValueChanged(QuestionWidget changedWidget) {
FormController formController = getFormController();
if (formController == null) {
// TODO: As usual, no idea if/how this is possible.
return;
}
if (formController.indexIsInFieldList()) {
// Some widgets may call widgetValueChanged from a non-main thread but odkView can only be modified from the main thread
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
updateFieldListQuestions(changedWidget.getFormEntryPrompt().getIndex());
odkView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (!odkView.isDisplayed(changedWidget)) {
odkView.scrollTo(changedWidget);
}
odkView.removeOnLayoutChangeListener(this);
}
});
} catch (RepeatsInFieldListException e) {
createErrorDialog(e.getMessage(), false);
} catch (Exception | Error e) {
Timber.e(e);
createErrorDialog(getString(R.string.update_widgets_error), true);
}
}
});
}
}
Aggregations