mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-01-27 17:09:19 +01:00
add a helper function for counting event reminders
This commit is contained in:
parent
c5bb4bb001
commit
2f784cf56a
@ -68,7 +68,7 @@ private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
||||
}
|
||||
|
||||
fun Context.scheduleNotification(event: Event) {
|
||||
if (event.reminder1Minutes == REMINDER_OFF && event.reminder2Minutes == REMINDER_OFF && event.reminder3Minutes == REMINDER_OFF)
|
||||
if (event.getRemindersCount() == 0)
|
||||
return
|
||||
|
||||
scheduleNextEvent(event)
|
||||
|
@ -30,4 +30,15 @@ data class Event(var id: Int = 0, var startTS: Int = 0, var endTS: Int = 0, var
|
||||
}
|
||||
|
||||
val isAllDay = flags and FLAG_ALL_DAY != 0
|
||||
|
||||
fun getRemindersCount(): Int {
|
||||
var cnt = 0
|
||||
if (reminder1Minutes != REMINDER_OFF)
|
||||
cnt++
|
||||
if (reminder2Minutes != REMINDER_OFF)
|
||||
cnt++
|
||||
if (reminder3Minutes != REMINDER_OFF)
|
||||
cnt++
|
||||
return cnt
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ import com.simplemobiletools.calendar.extensions.updateListWidget
|
||||
import com.simplemobiletools.calendar.helpers.DBHelper
|
||||
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
||||
import com.simplemobiletools.calendar.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.helpers.REMINDER_OFF
|
||||
import com.simplemobiletools.calendar.models.Event
|
||||
|
||||
class NotificationReceiver : BroadcastReceiver() {
|
||||
@ -27,7 +26,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
||||
return
|
||||
|
||||
val event = DBHelper(context).getEvent(id)
|
||||
if (event == null || (event.reminder1Minutes == REMINDER_OFF && event.reminder2Minutes == REMINDER_OFF && event.reminder3Minutes == REMINDER_OFF))
|
||||
if (event == null || event.getRemindersCount() == 0)
|
||||
return
|
||||
|
||||
val pendingIntent = getPendingIntent(context, event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user