move event time updating into a separate function
This commit is contained in:
parent
ffc6d3535e
commit
c0dd90d8fc
|
@ -170,6 +170,24 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
if (cursor != null) {
|
||||
final List<Event> newEvents = fillEvents(cursor);
|
||||
for (Event e : newEvents) {
|
||||
updateEventTimes(e, ts);
|
||||
}
|
||||
events.addAll(newEvents);
|
||||
}
|
||||
}
|
||||
|
||||
final String selection = COL_START_TS + " <= ? AND " + COL_END_TS + " >= ?";
|
||||
final String[] selectionArgs = {String.valueOf(toTS), String.valueOf(fromTS)};
|
||||
final Cursor cursor = getEventsCursor(selection, selectionArgs);
|
||||
if (cursor != null) {
|
||||
events.addAll(fillEvents(cursor));
|
||||
}
|
||||
|
||||
if (mCallback != null)
|
||||
mCallback.gotEvents(events);
|
||||
}
|
||||
|
||||
private void updateEventTimes(Event e, int ts) {
|
||||
final int periods = (ts - e.getStartTS()) / e.getRepeatInterval();
|
||||
DateTime currStart = new DateTime(e.getStartTS() * 1000L, DateTimeZone.getDefault());
|
||||
DateTime newStart;
|
||||
|
@ -186,20 +204,6 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||
e.setStartTS(newStartTS);
|
||||
e.setEndTS(newEndTS);
|
||||
}
|
||||
events.addAll(newEvents);
|
||||
}
|
||||
}
|
||||
|
||||
final String selection = COL_START_TS + " <= ? AND " + COL_END_TS + " >= ?";
|
||||
final String[] selectionArgs = {String.valueOf(toTS), String.valueOf(fromTS)};
|
||||
final Cursor cursor = getEventsCursor(selection, selectionArgs);
|
||||
if (cursor != null) {
|
||||
events.addAll(fillEvents(cursor));
|
||||
}
|
||||
|
||||
if (mCallback != null)
|
||||
mCallback.gotEvents(events);
|
||||
}
|
||||
|
||||
public List<Event> getEventsAtReboot() {
|
||||
List<Event> events = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue