Skip to content

Commit

Permalink
Fix the wallpaper changer behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Oct 23, 2022
1 parent d4c2de1 commit 2f81ff4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,7 @@ fun SettingsPage(
prefKey = Preferences.wallpaperChangerKey,
title = stringResource(R.string.wallpaper_changer)
) {
if (it) {
WorkerHelper.enqueue(context, true)
} else {
WorkerHelper.cancel(context)
}
WorkerHelper.enqueue(context, true)
}
ListPreference(
prefKey = Preferences.wallpaperChangerIntervalKey,
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/bnyro/wallpaper/util/WorkerHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ object WorkerHelper {
private const val JOB_NAME = "WallpaperChanger"

fun enqueue(context: Context, verbose: Boolean = false) {
if (!Preferences.getBoolean(Preferences.wallpaperChangerKey, false)) {
cancel(context)
return
}

val job = PeriodicWorkRequestBuilder<BackgroundWorker>(
Preferences.getString(
Preferences.wallpaperChangerIntervalKey,
Expand Down

0 comments on commit 2f81ff4

Please sign in to comment.