Skip to content
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

Closed
zhao-gang opened this issue Feb 26, 2019 · 3 comments
Closed

Fixed dangling snackbar in NearbyFragment #2520

zhao-gang opened this issue Feb 26, 2019 · 3 comments
Labels

Comments

@zhao-gang
Copy link
Contributor

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

@deniger
Copy link
Contributor

deniger commented Mar 7, 2019

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 ?

@zhao-gang
Copy link
Contributor Author

@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 :-)

@deniger
Copy link
Contributor

deniger commented Mar 8, 2019

@zhao-gang my mistake: I didn't see your PR. I need 👓 ...

domdomegg pushed a commit that referenced this issue Mar 15, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants