use of com.faltenreich.diaguard.shared.data.database.entity.Entry in project Diaguard by Faltenreich.
the class EntryEditFragment method showTimePicker.
private void showTimePicker() {
Entry entry = viewModel.getEntry();
TimePickerFragment.newInstance(entry.getDate(), (view, hourOfDay, minute) -> {
DateTime dateTime = viewModel.getEntry().getDate().withHourOfDay(hourOfDay).withMinuteOfHour(minute);
viewModel.getEntry().setDate(dateTime);
invalidateDateTime();
}).show(getChildFragmentManager());
}
use of com.faltenreich.diaguard.shared.data.database.entity.Entry in project Diaguard by Faltenreich.
the class EntryEditFragment method showDatePicker.
private void showDatePicker() {
Entry entry = viewModel.getEntry();
DatePickerFragment.newInstance(entry.getDate(), dateTime -> {
if (dateTime != null) {
LocalTime time = viewModel.getEntry().getDate() != null ? viewModel.getEntry().getDate().toLocalTime() : LocalTime.now();
dateTime = dateTime.withTime(time);
viewModel.getEntry().setDate(dateTime);
invalidateDateTime();
}
}).show(getChildFragmentManager());
}
use of com.faltenreich.diaguard.shared.data.database.entity.Entry in project Diaguard by Faltenreich.
the class EntryEditFragment method deleteEntry.
private void deleteEntry() {
Entry entry = viewModel.getEntry();
if (entry != null) {
EntryDao.getInstance().delete(entry);
finish();
Events.unregister(this);
Events.post(new EntryDeletedEvent(entry, viewModel.getEntryTags(), getFoodEaten()));
}
}
use of com.faltenreich.diaguard.shared.data.database.entity.Entry in project Diaguard by Faltenreich.
the class EntryEditViewModel method createEntry.
private void createEntry() {
entry = new Entry();
entry.setDate(dateTime);
if (category != null) {
Measurement measurement = ObjectFactory.createFromClass(category.toClass());
measurement.setEntry(entry);
entry.getMeasurementCache().add(measurement);
}
}
use of com.faltenreich.diaguard.shared.data.database.entity.Entry in project Diaguard by Faltenreich.
the class CalculatorFragment method storeValues.
private void storeValues(float mgDl, float carbohydrates, float bolus, float correction) {
DateTime now = DateTime.now();
Entry entry = new Entry();
entry.setDate(now);
EntryDao.getInstance().createOrUpdate(entry);
BloodSugar bloodSugar = new BloodSugar();
bloodSugar.setMgDl(mgDl);
bloodSugar.setEntry(entry);
MeasurementDao.getInstance(BloodSugar.class).createOrUpdate(bloodSugar);
List<FoodEaten> foodEatenList = new ArrayList<>();
if (carbohydrates > 0) {
FoodInputView foodInputView = getBinding().foodInputView;
foodEatenList.addAll(foodInputView.getFoodEatenList());
meal.setCarbohydrates(foodInputView.getInputCarbohydrates());
meal.setEntry(entry);
MeasurementDao.getInstance(Meal.class).createOrUpdate(meal);
for (FoodEaten foodEaten : foodEatenList) {
if (foodEaten.getAmountInGrams() > 0) {
foodEaten.setMeal(meal);
FoodEatenDao.getInstance().createOrUpdate(foodEaten);
}
}
}
if (bolus > 0 || correction > 0) {
Insulin insulin = new Insulin();
insulin.setBolus(bolus);
insulin.setCorrection(correction);
insulin.setEntry(entry);
MeasurementDao.getInstance(Insulin.class).createOrUpdate(insulin);
}
Events.post(new EntryAddedEvent(entry, null, foodEatenList));
openEntry(entry);
clearInput();
update();
}
Aggregations