Open baggednismo opened 6 months ago
Hi. I didn't find where you access ViewBinding instance in your code. The most common mistake is accessing it in callback of async calls. Before that you need to check that you view is still exists:
class AnyFragment : Fragment {
fun anyFuncation() {
// Start operation or subscribe on Flow/LiveData/Observable
// that call callback async
source.doOnResult {
if(this@AnyFramgnet.view != null) {
//do operations using ViewBinding instance
}
}
}
}
I have an app with lots of fragments. It does not use view models. I have been using BaseFragment() : Fragment() as I need onCreateView() and onViewCreated() to do all of the same stuff in every view (set entry animations and add an animation delay for the transitions).
Following issue tracked previously here
I attempt to setup a new BaseVBFragment as such
I setup my Fragment as such
So with the error of not being able to access viewLifecycleOwner in onResume(), I moved that to MyFragment.onViewCreated()
This resolved the hard error but the view is completely blank. Looking at logs, MyFragment nor BaseVBFragment runs onViewCreated().