-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed dangling snackbar in NearbyFragment #2520
Comments
Hello, I take a look to the fragment NearbyFragment and I notice that the method addNetworkBroadcastReceiver is called each time the tab is selected. This method creates a new Snackbar and register a BroadcastReceiver to the activity. So these 2 actions are done each time the tab is selected. I could explain this bug even if I didn't managed to reproduce it ( enabling/disabling airplane mode). I suppose that registering the broadcaster receiver should be done in the method onCreate and the snackbar should be created only if internet is unavailable. Am I correct ? |
@deniger Yes, currently the broadcast receiver is registered every time the tab is selected. My PR added a test in method addNetworkBroadcastReceiver. It first checks whether broadcastReceiver is null, if it's null we create the broadcastReceiver and register it, if it's not null(meaning a broadcastReceiver has already been created and registered), just skip the creation and registration of broadcastReceiver. I think that's enough to prevent registering multiple broadcastReceivers. Please correct me if I'm wrong :-) |
@zhao-gang my mistake: I didn't see your PR. I need 👓 ... |
NetworkBroadcastReceiver is unregistered in onPause() and not reregistered in onResume(). This causes the snackbar doesn't disappear after network becomes available. Fixed this and improved the null checking logic in snackbar related code.
Summary:
'Internet unavailable' snackbar doesn't disappear after network becomes available in NearbyFragment
Steps to reproduce:
Make network unavailable in Nearby fragment, the 'Internet unavailable' snackbar shows, then make network available, the snackbar doesn't disappear.
Device and Android version:
Unrelated
Commons app version:
master betaDebug
Would you like to work on the issue?
Yes
The text was updated successfully, but these errors were encountered: