Search in sources :

Example 1 with EntryDeletedEvent

use of com.faltenreich.diaguard.shared.event.data.EntryDeletedEvent 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()));
    }
}
Also used : Entry(com.faltenreich.diaguard.shared.data.database.entity.Entry) EntryDeletedEvent(com.faltenreich.diaguard.shared.event.data.EntryDeletedEvent)

Example 2 with EntryDeletedEvent

use of com.faltenreich.diaguard.shared.event.data.EntryDeletedEvent in project Diaguard by Faltenreich.

the class LogSwipeCallback method onSwiped.

@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
    Object item = adapter.getItem(viewHolder.getAdapterPosition());
    if (item instanceof LogEntryListItem) {
        LogEntryListItem listItem = (LogEntryListItem) item;
        Entry entry = listItem.getEntry();
        EntryDao.getInstance().delete(entry);
        Events.post(new EntryDeletedEvent(entry, listItem.getEntryTags(), listItem.getFoodEatenList()));
    }
}
Also used : Entry(com.faltenreich.diaguard.shared.data.database.entity.Entry) LogEntryListItem(com.faltenreich.diaguard.feature.log.entry.LogEntryListItem) EntryDeletedEvent(com.faltenreich.diaguard.shared.event.data.EntryDeletedEvent)

Aggregations

Entry (com.faltenreich.diaguard.shared.data.database.entity.Entry)2 EntryDeletedEvent (com.faltenreich.diaguard.shared.event.data.EntryDeletedEvent)2 LogEntryListItem (com.faltenreich.diaguard.feature.log.entry.LogEntryListItem)1