Skip to content

Commit

Permalink
Closes mozilla-mobile#26212: fix lint, add couldn't apply snackbar to…
Browse files Browse the repository at this point in the history
… homescreen
  • Loading branch information
mike a committed Sep 6, 2022
1 parent bd8ba1b commit f5aeeac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/org/mozilla/fenix/home/WallpapersObserver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import mozilla.components.lib.state.Store
import org.mozilla.fenix.R
import org.mozilla.fenix.addons.showSnackBar
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.components.appstate.AppAction
import org.mozilla.fenix.components.appstate.AppState
Expand All @@ -38,6 +40,7 @@ class WallpapersObserver(
) : DefaultLifecycleObserver {
@VisibleForTesting
internal var observeWallpapersStoreSubscription: Store.Subscription<AppState, AppAction>? = null

@VisibleForTesting
internal var wallpapersScope = CoroutineScope(Dispatchers.Main.immediate)

Expand Down Expand Up @@ -91,6 +94,13 @@ class WallpapersObserver(
bitmap?.let {
it.scaleToBottomOfView(wallpaperImageView)
wallpaperImageView.isVisible = true
} ?: run {
with(wallpaperImageView) {
showSnackBar(
view = this,
text = resources.getString(R.string.wallpaper_select_error_snackbar_message),
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class WallpapersUseCases(
*
* @param wallpaper The selected wallpaper.
*/
suspend operator fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState
suspend operator fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
Expand All @@ -435,7 +435,7 @@ class WallpapersUseCases(
*
* @param wallpaper The selected wallpaper.
*/
override suspend fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState {
override suspend fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState {
settings.currentWallpaperName = wallpaper.name
settings.currentWallpaperTextColor = wallpaper.textColor ?: 0
settings.currentWallpaperCardColor = wallpaper.cardColor ?: 0
Expand All @@ -462,7 +462,7 @@ class WallpapersUseCases(
*
* @param wallpaper The selected wallpaper.
*/
override suspend fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState {
override suspend fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState {
return if (wallpaper == Wallpaper.Default || fileManager.wallpaperImagesExist(wallpaper)) {
selectWallpaper(wallpaper)
dispatchDownloadState(wallpaper, Wallpaper.ImageFileState.Downloaded)
Expand Down

0 comments on commit f5aeeac

Please sign in to comment.