OmarAlghamdi / walkly-android

Android implementation of Walkly (the walking game)
0 stars 1 forks source link

Pressing the bottom-nav-menu multiple times make the app crash #53

Open A7madHD opened 4 years ago

A7madHD commented 4 years ago

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.

OmarAlghamdi commented 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

OmarAlghamdi commented 4 years ago

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

0Shift commented 4 years ago

i think a better way to handle this is to disable the ability to press current view's tab in the navbar

0Shift commented 4 years ago

https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample/app/src/main/java/com/example/android/navigationadvancedsample

has anyone tried onRestoreInstance in order to avoid generating new fragment instances?

OmarAlghamdi commented 4 years ago

@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.

0Shift commented 4 years ago

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

OmarAlghamdi commented 4 years ago

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

0Shift commented 4 years ago

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