RamiJ3mli / PercentageChartView

An Android custom view that displays the progress of an ongoing task.
Apache License 2.0
377 stars 82 forks source link

Crash into RecyclerView #15

Open igorka48 opened 5 years ago

igorka48 commented 5 years ago

I 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.

varun508 commented 5 years ago

I have the same issue. Any solution?

igorka48 commented 5 years ago

I found temporary workaround by removing PercentageChartView in onViewDetachedFromWindow and adding in onViewAttachedToWindow. But It lose state and you need keep in manually.

  override fun onViewDetachedFromWindow(holder: HomeAdapterHolder) {
        holder.onViewDetachedFromWindow()
        super.onViewDetachedFromWindow(holder)
    }

    override fun onViewAttachedToWindow(holder: HomeAdapterHolder) {
        super.onViewAttachedToWindow(holder)
        holder.onViewAttachedToWindow()
    }

I hope that @RamiJ3mli will find more elegant solution

braver-tool commented 4 years ago

Am also have that issue.Any fix for that?

NoahReyson commented 4 years ago

Same.

No answer yet ?

emilpedersen commented 4 years ago

Same here :/

arpitsingh21 commented 4 years ago

same issue

mv03790 commented 4 years ago

Same issues

eggham0518 commented 4 years ago

same

code-master-ajay commented 3 years ago

i am having same issue .please help

code-master-ajay commented 3 years ago

any solution yet ?? @RamiJ3mli

hazemzuhair commented 3 years ago

Help , same issue

koral-- commented 3 years ago

Here is my workaround: https://jitpack.io/#DroidsOnRoids/PercentageChartView/5a6836bd0d

PS Comments like:

I have the same issue

won't help anybody.