I’m working inside of a fragment. What’s the best ...
# android
v
I’m working inside of a fragment. What’s the best way to handle a accessing a view in an anonymous class. Initially I thought I could use a coroutine and scope it to the lifecycle of the view to prevent NPE when accessing the view. But that doesn’t work since the viewLifecycleOwner will already be null by then. Am I better off just checking if fragment
isResumed
before accessing progressBar?
Copy code
webview.webViewClient = object : WebViewClient() {

        override fun onPageFinished(view: WebView, url: String?) {
            super.onPageFinished(view, url)
            viewLifecycleOwner.lifecycle.coroutineScope.launchWhenCreated {
                progressBar.visibility = View.GONE
            }
        }
}
google 1