Open A7madHD opened 4 years ago
I am using the emulator and it does not crash. BUT. every time I press it the fragment seams to get created. it should have no effect once on the map tab. we are using nav controller so it is strange. I will try it one my phone and see what happens
the application crash also when the profile button is pressed multiple times.
onCreateView()
is called on each press.
I think the reason is there is business logic, async long running tasks in the view.. these two fragments has to be refactored to create proper view models
i think a better way to handle this is to disable the ability to press current view's tab in the navbar
has anyone tried onRestoreInstance in order to avoid generating new fragment instances?
@0Shift About disabling the button: it might work but you will still need to mange the data on the fragment. you will need to save and restore them on configuration changes. which is more work compared to using view model
About onRestoreInstance
:
I think it is irrelevant. the crash happens we an async function tries to return result to an already destroyed fragment.
i'm not saying not to use a viewmodel, just to disable clicking profile when you're on profile, I'm not sure how to disable it using jetpack navigation tho, i looked it up
I can be done by disabling the button in the click listener. just like it tint is being changed BUT crash inevitable in case of configuration change. say a rotation
if you cycle between the tabs in older versions (no equipment in profile) you wont get a crash no matter how fast you go. If we disable the buttons the only realistic problem is with profile
when u r at the map fragment, touch the map button in the bottom-nav-menu 3 times and the app will crash with u.