Crash into RecyclerView
See original GitHub issueI had added ChartView into recycler’s cell and received crash on cell updating.
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.ramijemli.percentagechartview.renderer.BaseModeRenderer.draw(android.graphics.Canvas)' on a null object reference at com.ramijemli.percentagechartview.PercentageChartView.onDraw(PercentageChartView.java:186) at android.view.View.draw(View.java:15114) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.updateDisplayListIfDirty(View.java:14043) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15117) at android.widget.FrameLayout.draw(FrameLayout.java:592) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.View.draw(View.java:14838) at android.view.ViewGroup.drawChild(ViewGroup.java:3404) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:4936) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3198) at android.view.View.draw(View.java:15117) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4335) at android.view.View.updateDisplayListIfDirty(View.java:14048) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3388) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3367) at android.view.View.updateDisplayListIfDirty(View.java:14008) at android.view.View.getDisplayList(View.java:14071) at android.view.ThreadedRenderer.updateViewTreeDispl
xml:
<com.ramijemli.percentagechartview.PercentageChartView android:id="@+id/dogProgressView" android:layout_width="40dp" android:layout_height="40dp" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="10dp" app:pcv_mode="ring" app:pcv_orientation="counter_clockwise" app:pcv_animDuration="400" app:pcv_textColor="@color/darkGray" app:pcv_textSize="10sp" app:pcv_animInterpolator="linear" app:pcv_backgroundBarColor="@color/peachyPinkTranparent" app:pcv_progressColor="@color/peachyPink" app:pcv_textStyle="bold" app:pcv_progressBarThickness="4dp" app:pcv_backgroundBarThickness="4dp" app:pcv_startAngle="135"/>
First time Chart draws as expected but crash performs on cell updating. Tested on API 28 and 21.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12
Top GitHub Comments
I found temporary workaround by removing PercentageChartView in onViewDetachedFromWindow and adding in onViewAttachedToWindow. But It lose state and you need keep in manually.
I hope that @RamiJ3mli will find more elegant solution
Here is my workaround: https://jitpack.io/#DroidsOnRoids/PercentageChartView/5a6836bd0d
PS Comments like:
won’t help anybody.