Skip to content

fix NPE when use solid color with barchart#4802

Merged
danielgindi merged 4 commits intoPhilJay:masterfrom
oatrice:fix_crash_solid_color_barchart
Feb 9, 2020
Merged

fix NPE when use solid color with barchart#4802
danielgindi merged 4 commits intoPhilJay:masterfrom
oatrice:fix_crash_solid_color_barchart

Conversation

@oatrice
Copy link
Contributor

@oatrice oatrice commented Feb 7, 2020

PR Checklist:

  • I have tested this extensively and it does not break any existing behavior.
  • I have added/updated examples and tests for any new behavior.
  • If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]

PR Description

fix NPE when use solid color with barchart

npe bug

2020-02-07 18:01:27.307 10747-10747/com.xxmassdeveloper.mpchartexample E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.xxmassdeveloper.mpchartexample, PID: 10747
    java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
        at com.github.mikephil.charting.renderer.BarChartRenderer.drawDataSet(BarChartRenderer.java:147)
        at com.github.mikephil.charting.renderer.BarChartRenderer.drawData(BarChartRenderer.java:81)
        at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:242)
        at android.view.View.draw(View.java:20617)
        at android.view.View.updateDisplayListIfDirty(View.java:19449)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.updateDisplayListIfDirty(View.java:19440)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.updateDisplayListIfDirty(View.java:19440)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.updateDisplayListIfDirty(View.java:19440)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.updateDisplayListIfDirty(View.java:19440)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.updateDisplayListIfDirty(View.java:19440)
        at android.view.View.draw(View.java:20330)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4508)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4264)
        at android.view.View.draw(View.java:20625)
        at com.android.internal.policy.DecorView.draw(DecorView.java:916)
        at android.view.View.updateDisplayListIfDirty(View.java:19449)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:690)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:696)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:805)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3975)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3750)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3046)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1815)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8228)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1048)
        at android.view.Choreographer.doCallbacks(Choreographer.java:860)
        at android.view.Choreographer.doFrame(Choreographer.java:792)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1034)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:226)
        at android.app.ActivityThread.main(ActivityThread.java:7212)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:956)

@oatrice oatrice requested a review from danielgindi February 7, 2020 11:06
Copy link
Collaborator

@danielgindi danielgindi left a comment

Choose a reason for hiding this comment

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

Please clean it up a bit

Copy link
Contributor Author

@oatrice oatrice left a comment

Choose a reason for hiding this comment

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

thank, edited

@danielgindi danielgindi merged commit 9347dd1 into PhilJay:master Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants