No issue: Fix LeakCanary detected memory leaks
Co-authored-by: Emily Kager <emilykager@gmail.com> Co-authored-by: Pierre-Yves Ricau <py@squareup.com>master
parent
bd4701f29e
commit
a6b07afa95
|
@ -98,8 +98,14 @@ import org.mozilla.fenix.theme.ThemeManager
|
|||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, SessionManager.Observer {
|
||||
protected lateinit var browserFragmentStore: BrowserFragmentStore
|
||||
protected lateinit var browserInteractor: BrowserToolbarViewInteractor
|
||||
protected lateinit var browserToolbarView: BrowserToolbarView
|
||||
|
||||
private var _browserInteractor: BrowserToolbarViewInteractor? = null
|
||||
protected val browserInteractor: BrowserToolbarViewInteractor
|
||||
get() = _browserInteractor!!
|
||||
|
||||
private var _browserToolbarView: BrowserToolbarView? = null
|
||||
protected val browserToolbarView: BrowserToolbarView
|
||||
get() = _browserToolbarView!!
|
||||
|
||||
protected val readerViewFeature = ViewBoundFeatureWrapper<ReaderViewFeature>()
|
||||
|
||||
|
@ -191,15 +197,16 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
topSiteStorage = requireComponents.core.topSiteStorage
|
||||
)
|
||||
|
||||
browserInteractor = BrowserInteractor(
|
||||
_browserInteractor = BrowserInteractor(
|
||||
browserToolbarController = browserToolbarController
|
||||
)
|
||||
|
||||
browserToolbarView = BrowserToolbarView(
|
||||
_browserToolbarView = BrowserToolbarView(
|
||||
container = view.browserLayout,
|
||||
shouldUseBottomToolbar = context.settings().shouldUseBottomToolbar,
|
||||
interactor = browserInteractor,
|
||||
customTabSession = customTabSessionId?.let { sessionManager.findSessionById(it) }
|
||||
customTabSession = customTabSessionId?.let { sessionManager.findSessionById(it) },
|
||||
lifecycleOwner = this.viewLifecycleOwner
|
||||
)
|
||||
|
||||
toolbarIntegration.set(
|
||||
|
@ -764,6 +771,15 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dereference these views when the fragment view is destroyed to prevent memory leaks
|
||||
*/
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
_browserToolbarView = null
|
||||
_browserInteractor = null
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val KEY_CUSTOM_TAB_SESSION_ID = "custom_tab_session_id"
|
||||
private const val REQUEST_CODE_DOWNLOAD_PERMISSIONS = 1
|
||||
|
|
|
@ -11,9 +11,9 @@ import android.view.ViewGroup
|
|||
import android.widget.LinearLayout
|
||||
import android.widget.PopupWindow
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.browser_toolbar_popup_window.view.*
|
||||
|
@ -45,7 +45,8 @@ class BrowserToolbarView(
|
|||
private val container: ViewGroup,
|
||||
private val shouldUseBottomToolbar: Boolean,
|
||||
private val interactor: BrowserToolbarViewInteractor,
|
||||
private val customTabSession: Session?
|
||||
private val customTabSession: Session?,
|
||||
private val lifecycleOwner: LifecycleOwner
|
||||
) : LayoutContainer {
|
||||
|
||||
override val containerView: View?
|
||||
|
@ -188,7 +189,7 @@ class BrowserToolbarView(
|
|||
hasAccountProblem = components.backgroundServices.accountManager.accountNeedsReauth(),
|
||||
shouldReverseItems = !shouldUseBottomToolbar,
|
||||
onItemTapped = { interactor.onBrowserToolbarMenuItemTapped(it) },
|
||||
lifecycleOwner = container.context as AppCompatActivity,
|
||||
lifecycleOwner = lifecycleOwner,
|
||||
sessionManager = sessionManager,
|
||||
bookmarksStorage = bookmarkStorage
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue