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

Fix NPE in refreshProductCount on HomeFragment #4237

Merged
merged 1 commit into from Sep 19, 2021

Conversation

naivekook
Copy link
Contributor

Description

Fix NPE in refreshProductCount on HomeFragment.

Related issues

#4234

lifecycleScope.launch {
val resp = try {
withContext(Dispatchers.IO) { productsApi.getTotalProductCount(getUserAgent()) }
lifecycleScope.launchWhenResumed {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main fix
based on log "at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)" I can assume, that the coroutine resumed the work while binding is still not inflated

if (_binding == null) {
Log.w(LOG_TAG, "setProductCount() calls with null binding")
}
_binding?.textHome?.text = if (count == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case if binding is still null at this moment

@sonarcloud
Copy link

sonarcloud bot commented Sep 15, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@teolemon teolemon added home Ideas and changes proposed for the application home NPE labels Sep 15, 2021
@VaiTon VaiTon merged commit 40a8f2d into openfoodfacts:develop Sep 19, 2021
@naivekook naivekook deleted the vt/fix-home-fragment-npe branch September 19, 2021 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
home Ideas and changes proposed for the application home NPE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants