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 on Android 8.0.0 #14

Open Ahmed-Adel-Ismail opened 5 years ago

Ahmed-Adel-Ismail commented 5 years ago

once i put these lines in xml:

<com.ramijemli.percentagechartview.PercentageChartView android:id="@+id/deliveryTimeProgress" android:layout_width="24dp" android:layout_height="24dp" android:layout_marginStart="24dp" android:layout_marginTop="8dp" app:pcv_mode="pie" app:pcv_orientation="counter_clockwise" app:pcv_animDuration="800" app:pcv_progress="10" app:pcv_startAngle="90" android:visibility="invisible" app:layout_constraintStart_toEndOf="@+id/pickupImageView" app:layout_constraintTop_toTopOf="@+id/pickupImageView" tools:visibility="visible" />

I find this crash :

java.lang.NullPointerException: Attempt to get length of null array at android.graphics.LinearGradient.(LinearGradient.java:60) at com.ramijemli.percentagechartview.renderer.PieModeRenderer.setupGradientColors(PieModeRenderer.java:129) at com.ramijemli.percentagechartview.renderer.PieModeRenderer.measure(PieModeRenderer.java:67) at com.ramijemli.percentagechartview.PercentageChartView.onMeasure(PercentageChartView.java:168) at android.view.View.measure(View.java:22024) at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227) at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572) at android.view.View.measure(View.java:22024) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6582) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:22024) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6582) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514) at android.widget.LinearLayout.measureVertical(LinearLayout.java:806) at android.widget.LinearLayout.onMeasure(LinearLayout.java:685) at android.view.View.measure(View.java:22024) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6582) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724) at android.view.View.measure(View.java:22024) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2456) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1538) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1791) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1426) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6873) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1026) at android.view.Choreographer.doCallbacks(Choreographer.java:838) at android.view.Choreographer.doFrame(Choreographer.java:769) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1012) at android.os.Handler.handleCallback(Handler.java:792) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:176) at android.app.ActivityThread.main(ActivityThread.java:6701) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:246) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)

RamiJ3mli commented 5 years ago

This is a 1 line fix and unfortunately, I still have some work for the next release. Please, feel free to add the library as a module and change line 124 from the com.ramijemli.percentagechartview.renderer.PieModeRenderer class to if (mGradientType == -1 || bounds.height() == 0) return;. Hopefully, this is convenient.

akardas16 commented 5 years ago

thanks man yes you are right instead of if (mGradientType == -1 && bounds.height() == 0) return; it should be if (mGradientType == -1 || bounds.height() == 0) return; Thanks for this beautiful library

dendrocyte commented 4 years ago

same here. but I faced exception about importing the lib.

Plugin with id 'com.jfrog.bintray' not found

try a lot of work to fix it. but failed. like your lib. wait for the latest one to fix this bug.