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: Fix crash on SearchByCodeFragment #4652

Merged
merged 3 commits into from
Apr 9, 2022

Conversation

g123k
Copy link
Contributor

@g123k g123k commented Apr 8, 2022

Fix crash:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: openfoodfacts.github.scrachx.openfood.debug, PID: 4914
    java.lang.NullPointerException
        at openfoodfacts.github.scrachx.openfood.features.searchbycode.SearchByCodeFragment.getBinding(SearchByCodeFragment.kt:30)
        at openfoodfacts.github.scrachx.openfood.features.searchbycode.SearchByCodeFragment.onDrawerClosed(SearchByCodeFragment.kt:106)
        at openfoodfacts.github.scrachx.openfood.features.MainActivity$setupDrawer$1$1.onDrawerClosed(MainActivity.kt:348)
        at com.mikepenz.materialdrawer.DrawerBuilder$handleDrawerNavigation$1.onDrawerClosed(DrawerBuilder.kt:1444)
        at androidx.drawerlayout.widget.DrawerLayout.dispatchOnDrawerClosed(DrawerLayout.java:891)
        at androidx.drawerlayout.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:861)
        at androidx.drawerlayout.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:2249)
        at androidx.customview.widget.ViewDragHelper.setDragState(ViewDragHelper.java:920)
        at androidx.customview.widget.ViewDragHelper$2.run(ViewDragHelper.java:345)
        at android.os.Handler.handleCallback(Handler.java:942)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7850)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

"at openfoodfacts.github.scrachx.openfood.features.searchbycode.SearchByCodeFragment.getBinding(SearchByCodeFragment.kt:30)"
@g123k g123k added the NPE label Apr 8, 2022
@g123k g123k requested a review from a team as a code owner April 8, 2022 21:14
@g123k g123k changed the title Fix crash fix: Fix crash on SearchByCodeFragment Apr 8, 2022
Copy link
Member

@VaiTon VaiTon left a comment

Choose a reason for hiding this comment

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

We should register/unregister the listener with the lifecycle of the fragment instead of checking for _binding

@sonarcloud
Copy link

sonarcloud bot commented Apr 9, 2022

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

Copy link
Member

@VaiTon VaiTon left a comment

Choose a reason for hiding this comment

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

Thank you! 🎉

@VaiTon VaiTon merged commit 53f79aa into openfoodfacts:develop Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants