diff options
author | Allan Wang <me@allanwang.ca> | 2019-08-06 22:16:33 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-08-06 22:16:33 -0700 |
commit | 81d357ce0a17a5b11bfb17d3762540c2bd7f11be (patch) | |
tree | c8e452cdffef61b267b9ad2b06d2cd9af3848cdb /app/src/main/kotlin/com/pitchedapps/frost/services | |
parent | 281124b649304741dd1ad508b90bf056dba1192e (diff) | |
download | frost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.tar.gz frost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.tar.bz2 frost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.zip |
Reduce notification update frequency
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index bb5594fe..cab1311c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -43,6 +43,7 @@ import com.pitchedapps.frost.facebook.parsers.NotifParser import com.pitchedapps.frost.facebook.parsers.ParseNotification import com.pitchedapps.frost.glide.FrostGlide import com.pitchedapps.frost.glide.GlideApp +import com.pitchedapps.frost.settings.hasNotifications import com.pitchedapps.frost.utils.ARG_USER_ID import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs @@ -321,6 +322,12 @@ data class FrostNotification( NotificationManagerCompat.from(context).notify(tag, id, notif.build()) } +fun Context.scheduleNotificationsFromPrefs(): Boolean { + val shouldSchedule = Prefs.hasNotifications + return if (shouldSchedule) scheduleNotifications(Prefs.notificationFreq) + else scheduleNotifications(-1) +} + fun Context.scheduleNotifications(minutes: Long): Boolean = scheduleJob<NotificationService>(NOTIFICATION_PERIODIC_JOB, minutes) |