From 81d357ce0a17a5b11bfb17d3762540c2bd7f11be Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Aug 2019 22:16:33 -0700 Subject: Reduce notification update frequency --- .../kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt') 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(NOTIFICATION_PERIODIC_JOB, minutes) -- cgit v1.2.3