2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

[fenix] No issue: Fix leaks in BookmarkFragment

This commit is contained in:
ekager 2020-04-17 19:27:33 -07:00 committed by Emily Kager
parent b28a0e8ce9
commit e27e45bc75

View File

@ -52,7 +52,9 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
private lateinit var bookmarkStore: BookmarkFragmentStore
private lateinit var bookmarkView: BookmarkView
private lateinit var bookmarkInteractor: BookmarkFragmentInteractor
private var _bookmarkInteractor: BookmarkFragmentInteractor? = null
protected val bookmarkInteractor: BookmarkFragmentInteractor
get() = _bookmarkInteractor!!
private val sharedViewModel: BookmarksSharedViewModel by activityViewModels {
ViewModelProvider.NewInstanceFactory() // this is a workaround for #4652
@ -75,7 +77,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
BookmarkFragmentStore(BookmarkFragmentState(null))
}
bookmarkInteractor = BookmarkFragmentInteractor(
_bookmarkInteractor = BookmarkFragmentInteractor(
bookmarkStore = bookmarkStore,
viewModel = sharedViewModel,
bookmarksController = DefaultBookmarkController(
@ -94,7 +96,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
bookmarkView = BookmarkView(view.bookmarkLayout, bookmarkInteractor)
lifecycle.addObserver(
viewLifecycleOwner.lifecycle.addObserver(
BookmarkDeselectNavigationListener(
findNavController(),
sharedViewModel,
@ -293,6 +295,11 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
)
}
override fun onDestroyView() {
super.onDestroyView()
_bookmarkInteractor = null
}
private fun invokePendingDeletion() {
pendingBookmarkDeletionJob?.let {
viewLifecycleOwner.lifecycleScope.launch {