Skip to content

Commit

Permalink
Closes mozilla-mobile#27209: fix WallpapersSettings crash
Browse files Browse the repository at this point in the history
  • Loading branch information
mike a committed Sep 29, 2022
1 parent 1005412 commit e42693e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class WallpaperSettingsFragment : Fragment() {
requireComponents.useCases.wallpaperUseCases
}

private var snackBar: FenixSnackbar? = null

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down Expand Up @@ -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(
Expand All @@ -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 */ }
}
Expand All @@ -139,4 +145,9 @@ class WallpaperSettingsFragment : Fragment() {
super.onResume()
showToolbar(getString(R.string.customize_wallpapers))
}

override fun onStop() {
super.onStop()
snackBar?.let { it.dismiss() }
}
}

0 comments on commit e42693e

Please sign in to comment.