Search in sources :

Example 11 with EntryTag

use of com.faltenreich.diaguard.shared.data.database.entity.EntryTag in project Diaguard by Faltenreich.

the class BaseFragment method onEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(final EntryDeletedEvent event) {
    if (getView() == null) {
        return;
    }
    ViewUtils.showSnackbar(getView(), getString(R.string.entry_deleted), v -> {
        Entry entry = event.context;
        EntryDao.getInstance().createOrUpdate(entry);
        for (Measurement measurement : entry.getMeasurementCache()) {
            measurement.setEntry(entry);
            // noinspection unchecked
            MeasurementDao.getInstance(measurement.getClass()).createOrUpdate(measurement);
        }
        for (EntryTag entryTag : event.entryTags) {
            entryTag.setEntry(entry);
            EntryTagDao.getInstance().createOrUpdate(entryTag);
        }
        Events.post(new EntryAddedEvent(entry, event.entryTags, event.foodEatenList));
    });
}
Also used : Measurement(com.faltenreich.diaguard.shared.data.database.entity.Measurement) Entry(com.faltenreich.diaguard.shared.data.database.entity.Entry) EntryTag(com.faltenreich.diaguard.shared.data.database.entity.EntryTag) EntryAddedEvent(com.faltenreich.diaguard.shared.event.data.EntryAddedEvent) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

EntryTag (com.faltenreich.diaguard.shared.data.database.entity.EntryTag)11 Entry (com.faltenreich.diaguard.shared.data.database.entity.Entry)8 Measurement (com.faltenreich.diaguard.shared.data.database.entity.Measurement)8 Tag (com.faltenreich.diaguard.shared.data.database.entity.Tag)8 FoodEaten (com.faltenreich.diaguard.shared.data.database.entity.FoodEaten)7 ArrayList (java.util.ArrayList)6 Category (com.faltenreich.diaguard.shared.data.database.entity.Category)5 Meal (com.faltenreich.diaguard.shared.data.database.entity.Meal)5 ChipView (com.faltenreich.diaguard.shared.view.chip.ChipView)3 DateTime (org.joda.time.DateTime)3 View (android.view.View)2 ImageView (android.widget.ImageView)2 BloodSugar (com.faltenreich.diaguard.shared.data.database.entity.BloodSugar)2 Food (com.faltenreich.diaguard.shared.data.database.entity.Food)2 EntryAddedEvent (com.faltenreich.diaguard.shared.event.data.EntryAddedEvent)2 Context (android.content.Context)1 LayoutInflater (android.view.LayoutInflater)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1