Closed bogdanmunteanu closed 4 years ago
Issue was with version 2.4.6 of the library , checking for reproduction with most current version
Still ocurring , NPE thrown on com.shawnlin.numberpicker.NumberPicker.drawText(NumberPicker.java:1825
Is there any null present in any of the values in NumberPicker? I tested the library on Android 10 and I found it to be working fine.
Hello ,
We invastigated further, and found that in NumberPicker.java at line 1763 , when instantiating the selectorIndex , the isAscendingOrder() returns true which means selectorIndex is going to be initialized with 0. The problem is the SparseArray mSelectorIndexToStringCache.get[0] is going to return a NPE , because mSelectorIndexToStringCache contains only [1,2,100]
Hello ,
We invastigated further, and found that in NumberPicker.java at line 1763 , when instantiating the selectorIndex , the isAscendingOrder() returns true which means selectorIndex is going to be initialized with 0. The problem is the SparseArray mSelectorIndexToStringCache.get[0] is going to return a NPE , because mSelectorIndexToStringCache contains only [1,2,100]
@bogdanmunteanu Could you provide your code snippet and settings?
@bogdanmunteanu Please try the latest version v2.4.9.
Close this inactive issue for now. Please reopen this issue if are still encountering problems.
@ShawnLin013 It was fixed , thank you for your support
Hello , just wanted to let you know that onDraw method of the library crashes randomly on Android 10. Here is the stacktrace I managed to get.
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at android.graphics.BaseRecordingCanvas.drawText(BaseRecordingCanvas.java:458) at com.shawnlin.numberpicker.NumberPicker.onDraw(NumberPicker.java:1533) at android.view.View.draw(View.java:23143) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023) at android.view.View.draw(View.java:23146) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023) at android.view.View.draw(View.java:23146) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023) at android.view.View.draw(View.java:23146) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.draw(View.java:23146) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1426) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.updateDisplayListIfDirty(View.java:22004) at android.view.View.draw(View.java:22873) at android.view.ViewGroup.drawChild(ViewGroup.java:4620) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4377) at android.view.View.draw(View.java:23146) at com.android.internal.policy.DecorView.draw(DecorView.java:1107) at android.view.View.updateDisplayListIfDirty(View.java:22018) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:588) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:594) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:667) at android.view.ViewRootImpl.draw(ViewRootImpl.java:4199) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3983)