reschedule all notifications at reboot as needed

This commit is contained in:
tibbi 2016-09-13 22:24:34 +02:00
parent 1d65ad305e
commit 6c783bead1
2 changed files with 4 additions and 3 deletions

View File

@ -243,13 +243,14 @@ public class DBHelper extends SQLiteOpenHelper {
public List<Event> getEventsAtReboot() {
List<Event> events = new ArrayList<>();
final String selection = COL_START_TS + " > ? AND " + COL_REMINDER_MINUTES + " != ?";
final String[] selectionArgs = {String.valueOf(DateTime.now().getMillis() / 1000), "-1"};
final String selection = COL_REMINDER_MINUTES + " != -1 AND (" + COL_START_TS + " > ? OR " + COL_REPEAT_INTERVAL + " != 0)";
final String[] selectionArgs = {String.valueOf(DateTime.now().getMillis() / 1000)};
final Cursor cursor = getEventsCursor(selection, selectionArgs);
if (cursor != null) {
events = fillEvents(cursor);
}
return events;
}

View File

@ -16,7 +16,7 @@ public class BootCompletedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent arg1) {
final List<Event> events = DBHelper.newInstance(context, null).getEventsAtReboot();
for (Event event : events) {
Utils.scheduleNotification(context, event);
Utils.scheduleNextEvent(context, event);
}
}
}