diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt index fa06f454c..ca29d108c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Context.kt @@ -78,7 +78,7 @@ fun Context.updateListWidget() { } fun Context.scheduleAllEvents() { - val events = eventsDB.getEventsAtReboot(DateTime.now().seconds()) + val events = eventsDB.getEventsAtReboot(getNowSeconds()) events.forEach { scheduleNextEventReminder(it) } @@ -154,7 +154,7 @@ fun Context.getRepetitionText(seconds: Int) = when (seconds) { } fun Context.notifyRunningEvents() { - dbHelper.getRunningEvents().filter { it.getReminders().isNotEmpty() }.forEach { + eventsHelper.getRunningEvents().filter { it.getReminders().isNotEmpty() }.forEach { notifyEvent(it) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt index 4e624bc38..bdc06447c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/DBHelper.kt @@ -53,19 +53,6 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {} - fun getRunningEvents(): List { - val events = ArrayList() - val ts = getNowSeconds() - //val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_REPEAT_INTERVAL IS NULL AND $COL_START_TS != 0" - val selection = "$COL_START_TS <= ? AND $COL_END_TS >= ? AND $COL_START_TS != 0" - val selectionArgs = arrayOf(ts.toString(), ts.toString()) - val cursor = getEventsCursor(selection, selectionArgs) - events.addAll(fillEvents(cursor)) - - //events.addAll(getRepeatableEventsFor(ts, ts)) - return events - } - fun getEventsToExport(includePast: Boolean): ArrayList { val currTime = getNowSeconds().toString() var events = ArrayList() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt index 65ff2e186..7ee0646d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/helpers/EventsHelper.kt @@ -8,7 +8,6 @@ import com.simplemobiletools.calendar.pro.extensions.* import com.simplemobiletools.calendar.pro.models.Event import com.simplemobiletools.calendar.pro.models.EventRepetitionException import com.simplemobiletools.calendar.pro.models.EventType -import java.util.* class EventsHelper(val context: Context) { private val config = context.config @@ -405,4 +404,11 @@ class EventsHelper(val context: Context) { } return events } + + fun getRunningEvents(): List { + val ts = getNowSeconds() + val events = eventsDB.getOneTimeEventsFromTo(ts, ts).toMutableList() as ArrayList + events.addAll(getRepeatableEventsFor(ts, ts)) + return events + } }