From 24146863cc0985becf4359bd18c95dc182cfea44 Mon Sep 17 00:00:00 2001 From: Swapnil Tiwari Date: Sat, 21 Mar 2020 22:42:20 +0530 Subject: [PATCH 1/2] Configuration enhancements --- .../broooapps/graphview/CurveGraphView.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java index 7a03251..2178158 100644 --- a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java +++ b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java @@ -1,25 +1,30 @@ package com.broooapps.graphview; -import android.animation.*; -import android.app.Activity; +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.animation.PropertyValuesHolder; +import android.animation.ValueAnimator; import android.content.Context; -import android.graphics.*; -import android.os.Handler; +import android.graphics.Canvas; +import android.graphics.DashPathEffect; +import android.graphics.LinearGradient; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PathEffect; +import android.graphics.PathMeasure; +import android.graphics.RectF; +import android.graphics.Shader; import android.util.AttributeSet; import android.view.View; -import android.view.ViewTreeObserver; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateInterpolator; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; import com.broooapps.graphview.models.GraphData; import com.broooapps.graphview.models.GraphPoint; import com.broooapps.graphview.models.PointMap; -import java.lang.ref.WeakReference; import java.text.DecimalFormat; import java.util.ArrayList; @@ -251,7 +256,8 @@ public void onAnimationUpdate(ValueAnimator animation) { for (int i = 0; i < graphGradientPaintsList.size(); i++) { if (graphDataArray[i].isAnimateLine()) { - graphGradientPaintsList.get(i).setAlpha((Integer) animation.getAnimatedValue("PROPERTY_ALPHA")); + if (graphGradientPaintsList.get(i) != null) + graphGradientPaintsList.get(i).setAlpha((Integer) animation.getAnimatedValue("PROPERTY_ALPHA")); graphPointPaintsList.get(i).setAlpha((Integer) animation.getAnimatedValue("PROPERTY_ALPHA")); } } From edfc6a0c0dd5478d96213a1b1492f779b833739c Mon Sep 17 00:00:00 2001 From: Swapnil Tiwari Date: Sat, 21 Mar 2020 22:50:15 +0530 Subject: [PATCH 2/2] Probable bugfix for IndexOutOfBoundException: --- .../src/main/java/com/broooapps/graphview/CurveGraphView.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java index 2178158..acfaf45 100644 --- a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java +++ b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java @@ -168,6 +168,8 @@ public void setData(int span, int maxVal, GraphData... graphDataArray) { this.maxVal = maxVal; this.xSpan = span; this.graphDataArray = graphDataArray; + graphGradientPaintsList.clear(); + graphStrokePaintsList.clear(); pathArrayList = constructPaths(); length = getLengths();