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