From e42693e54e01ef0a8bb94b9125265b73d1ee427f Mon Sep 17 00:00:00 2001 From: mike a Date: Wed, 28 Sep 2022 17:04:12 -0700 Subject: [PATCH] Closes #27209: fix WallpapersSettings crash --- .../wallpaper/WallpaperSettingsFragment.kt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/settings/wallpaper/WallpaperSettingsFragment.kt b/app/src/main/java/org/mozilla/fenix/settings/wallpaper/WallpaperSettingsFragment.kt index 5fc3b556e0a2..37aa4d75ed84 100644 --- a/app/src/main/java/org/mozilla/fenix/settings/wallpaper/WallpaperSettingsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/settings/wallpaper/WallpaperSettingsFragment.kt @@ -37,6 +37,8 @@ class WallpaperSettingsFragment : Fragment() { requireComponents.useCases.wallpaperUseCases } + private var snackBar: FenixSnackbar? = null + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -106,8 +108,10 @@ class WallpaperSettingsFragment : Fragment() { .setText(view.context.getString(R.string.wallpaper_updated_snackbar_message)) .setAction(requireContext().getString(R.string.wallpaper_updated_snackbar_action)) { findNavController().navigate(R.id.homeFragment) + }.also { snackBar -> + this.snackBar = snackBar + snackBar.show() } - .show() Wallpapers.wallpaperSelected.record( Wallpapers.WallpaperSelectedExtra( @@ -128,8 +132,10 @@ class WallpaperSettingsFragment : Fragment() { val retryResult = wallpaperUseCases.selectWallpaper(wallpaper) onWallpaperSelected(wallpaper, retryResult, view) } + }.also { snackBar -> + this.snackBar = snackBar + snackBar.show() } - .show() } else -> { /* noop */ } } @@ -139,4 +145,9 @@ class WallpaperSettingsFragment : Fragment() { super.onResume() showToolbar(getString(R.string.customize_wallpapers)) } + + override fun onStop() { + super.onStop() + snackBar?.let { it.dismiss() } + } }