store the repetition interval in db

This commit is contained in:
tibbi 2016-09-10 23:43:58 +02:00
parent 58066fc949
commit 58f252f180
1 changed files with 14 additions and 2 deletions

View File

@ -81,9 +81,13 @@ public class DBHelper extends SQLiteOpenHelper {
}
public void insert(Event event) {
final ContentValues values = fillContentValues(event);
long id = mDb.insert(MAIN_TABLE_NAME, null, values);
final ContentValues eventValues = fillContentValues(event);
long id = mDb.insert(MAIN_TABLE_NAME, null, eventValues);
event.setId((int) id);
if (event.getRepeatInterval() != 0) {
final ContentValues metaValues = fillMetaValues(event);
mDb.insert(META_TABLE_NAME, null, metaValues);
}
if (mCallback != null)
mCallback.eventInserted(event);
@ -109,6 +113,14 @@ public class DBHelper extends SQLiteOpenHelper {
return values;
}
private ContentValues fillMetaValues(Event event) {
final ContentValues values = new ContentValues();
values.put(COL_EVENT_ID, event.getId());
values.put(COL_REPEAT_START, event.getRepeatInterval());
values.put(COL_REPEAT_INTERVAL, event.getRepeatInterval());
return values;
}
public void deleteEvents(String[] ids) {
final String args = TextUtils.join(", ", ids);
final String selection = COL_ID + " IN (" + args + ")";