mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-04 09:17:29 +01:00
Calendar Sync: Make greendao .update() work by adding a PK id :/
This commit is contained in:
parent
f7ca1fc76c
commit
df0e77f368
@ -273,6 +273,7 @@ public class GBDaoGenerator {
|
||||
|
||||
private static void addCalendarSyncState(Schema schema, Entity device) {
|
||||
Entity calendarSyncState = addEntity(schema, "CalendarSyncState");
|
||||
calendarSyncState.addIdProperty();
|
||||
Property deviceId = calendarSyncState.addLongProperty("deviceId").notNull().getProperty();
|
||||
Property calendarEntryId = calendarSyncState.addLongProperty("calendarEntryId").notNull().getProperty();
|
||||
Index indexUnique = new Index();
|
||||
|
@ -183,11 +183,13 @@ public class CalendarReceiver extends BroadcastReceiver {
|
||||
EventSyncState es = eventState.get(i);
|
||||
int syncState = es.getState();
|
||||
if (syncState == EventState.NOT_SYNCED || syncState == EventState.NEEDS_UPDATE) {
|
||||
CalendarEvents.CalendarEvent calendarEvent = es.getEvent();
|
||||
CalendarEventSpec calendarEventSpec = new CalendarEventSpec();
|
||||
calendarEventSpec.title = es.getEvent().getTitle();
|
||||
calendarEventSpec.id = i;
|
||||
calendarEventSpec.timestamp = es.getEvent().getBeginSeconds();
|
||||
calendarEventSpec.description = es.getEvent().getDescription();
|
||||
calendarEventSpec.title = calendarEvent.getTitle();
|
||||
calendarEventSpec.timestamp = calendarEvent.getBeginSeconds();
|
||||
//calendarEventSpec.durationInSeconds = calendarEvent.getDurationSeconds(); //FIXME: leads to problems right now
|
||||
calendarEventSpec.description = calendarEvent.getDescription();
|
||||
calendarEventSpec.type = CalendarEventSpec.TYPE_UNKNOWN;
|
||||
if (syncState == EventState.NEEDS_UPDATE) {
|
||||
GBApplication.deviceService().onDeleteCalendarEvent(CalendarEventSpec.TYPE_UNKNOWN, i);
|
||||
@ -196,7 +198,7 @@ public class CalendarReceiver extends BroadcastReceiver {
|
||||
es.setState(EventState.SYNCED);
|
||||
eventState.put(i, es);
|
||||
// update db
|
||||
session.insertOrReplace(new CalendarSyncState(deviceId, i, EventState.SYNCED));
|
||||
session.insertOrReplace(new CalendarSyncState(null, deviceId, i, EventState.SYNCED));
|
||||
} else if (syncState == EventState.NEEDS_DELETE) {
|
||||
GBApplication.deviceService().onDeleteCalendarEvent(CalendarEventSpec.TYPE_UNKNOWN, i);
|
||||
eventState.remove(i);
|
||||
|
Loading…
Reference in New Issue
Block a user