use of com.faltenreich.diaguard.feature.entry.edit.measurement.MeasurementView in project Diaguard by Faltenreich.
the class EntryEditFragment method inputIsValid.
private boolean inputIsValid() {
boolean inputIsValid = true;
List<Measurement> measurements = viewModel.getMeasurements();
if (measurements.isEmpty()) {
// Allow entries with no measurements but with a note or tag
if (StringUtils.isBlank(viewModel.getEntry().getNote()) && tagListView.getChildCount() == 0) {
ViewUtils.showSnackbar(root, getString(R.string.validator_value_none));
inputIsValid = false;
}
} else {
for (int index = 0; index < measurementContainer.getChildCount(); index++) {
View view = measurementContainer.getChildAt(index);
if (view instanceof MeasurementView<?>) {
MeasurementView<?> measurementView = (MeasurementView<?>) view;
if (!measurementView.getInputView().isValid()) {
inputIsValid = false;
}
}
}
}
return inputIsValid;
}
use of com.faltenreich.diaguard.feature.entry.edit.measurement.MeasurementView in project Diaguard by Faltenreich.
the class EntryEditFragment method getFoodEaten.
private List<FoodEaten> getFoodEaten() {
for (int index = 0; index < measurementContainer.getChildCount(); index++) {
View view = measurementContainer.getChildAt(index);
if (view instanceof MeasurementView) {
MeasurementView<?> measurementView = ((MeasurementView<?>) view);
Measurement measurement = measurementView.getMeasurement();
if (measurement instanceof Meal) {
List<FoodEaten> foodEatenList = new ArrayList<>();
for (FoodEaten foodEaten : ((Meal) measurement).getFoodEatenCache()) {
if (foodEaten.isValid()) {
foodEatenList.add(foodEaten);
}
}
return foodEatenList;
}
}
}
return new ArrayList<>();
}
Aggregations