Refactored wallpaper changer code

This commit is contained in:
Anthonyy232 committed 2024-08-16 16:23:57 -07:00
1 parent 92563b84ec
commit 624c9c3dbb
2 files changed
-10

No files matched your search

@@ -205,11 +205,9 @@ class HomeWallpaperService: Service() {
setHome && setLock && scheduleSeparately -> {
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
if (wallpaper == null) {
// Reshuffle the wallpapers and pick the first one
val newWallpapers = homeAlbum.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpapers.firstOrNull()
if (wallpaper == null) {
// Delete invalid album if no valid wallpaper
selectedRepository.cascadeDeleteAlbum(homeAlbum.album.initialAlbumName)
onDestroy()
return
@@ -289,11 +287,9 @@ class HomeWallpaperService: Service() {
setHome && setLock && !scheduleSeparately -> {
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
if (wallpaper == null) {
// Reshuffle the wallpapers and pick the first one
val newWallpapers = homeAlbum.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpapers.firstOrNull()
if (wallpaper == null) {
// Delete invalid album if no valid wallpaper
selectedRepository.cascadeDeleteAlbum(homeAlbum.album.initialAlbumName)
onDestroy()
return
@@ -381,11 +377,9 @@ class HomeWallpaperService: Service() {
setHome -> {
var wallpaper = homeAlbum.album.homeWallpapersInQueue.firstOrNull()
if (wallpaper == null) {
// Reshuffle the wallpapers and pick the first one
val newWallpapers = homeAlbum.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpapers.firstOrNull()
if (wallpaper == null) {
// Delete invalid album if no valid wallpaper
selectedRepository.cascadeDeleteAlbum(homeAlbum.album.initialAlbumName)
onDestroy()
return
@@ -205,11 +205,9 @@ class LockWallpaperService: Service() {
setHome && setLock && scheduleSeparately -> {
var wallpaper = lockAlbum.album.lockWallpapersInQueue.firstOrNull()
if (wallpaper == null) {
// Reshuffle the wallpapers and pick the first one
val newWallpapers = lockAlbum.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpapers.firstOrNull()
if (wallpaper == null) {
// Delete invalid album if no valid wallpaper
selectedRepository.cascadeDeleteAlbum(lockAlbum.album.initialAlbumName)
onDestroy()
return
@@ -312,11 +310,9 @@ class LockWallpaperService: Service() {
setLock -> {
var wallpaper = lockAlbum.album.lockWallpapersInQueue.firstOrNull()
if (wallpaper == null) {
// Reshuffle the wallpapers and pick the first one
val newWallpapers = lockAlbum.wallpapers.map { it.wallpaperUri }.shuffled()
wallpaper = newWallpapers.firstOrNull()
if (wallpaper == null) {
// Delete invalid album if no valid wallpaper
selectedRepository.cascadeDeleteAlbum(lockAlbum.album.initialAlbumName)
onDestroy()
return