mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add a helper function for counting event reminders
This commit is contained in:
@@ -68,7 +68,7 @@ private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Context.scheduleNotification(event: Event) {
|
fun Context.scheduleNotification(event: Event) {
|
||||||
if (event.reminder1Minutes == REMINDER_OFF && event.reminder2Minutes == REMINDER_OFF && event.reminder3Minutes == REMINDER_OFF)
|
if (event.getRemindersCount() == 0)
|
||||||
return
|
return
|
||||||
|
|
||||||
scheduleNextEvent(event)
|
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
|
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.DBHelper
|
||||||
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
import com.simplemobiletools.calendar.helpers.EVENT_ID
|
||||||
import com.simplemobiletools.calendar.helpers.Formatter
|
import com.simplemobiletools.calendar.helpers.Formatter
|
||||||
import com.simplemobiletools.calendar.helpers.REMINDER_OFF
|
|
||||||
import com.simplemobiletools.calendar.models.Event
|
import com.simplemobiletools.calendar.models.Event
|
||||||
|
|
||||||
class NotificationReceiver : BroadcastReceiver() {
|
class NotificationReceiver : BroadcastReceiver() {
|
||||||
@@ -27,7 +26,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
return
|
return
|
||||||
|
|
||||||
val event = DBHelper(context).getEvent(id)
|
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
|
return
|
||||||
|
|
||||||
val pendingIntent = getPendingIntent(context, event)
|
val pendingIntent = getPendingIntent(context, event)
|
||||||
|
Reference in New Issue
Block a user