From 7a1d1744bc408ef14faafe382c1f14fd9c97e47d Mon Sep 17 00:00:00 2001 From: Swapnil Tiwari Date: Sat, 21 Mar 2020 23:55:28 +0530 Subject: [PATCH] Configuration enhancements --- .../com/broooapps/graphview/CurveGraphView.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java index 3946519..bfdc9be 100644 --- a/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java +++ b/graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java @@ -73,6 +73,8 @@ public class CurveGraphView extends View { ArrayList graphPointPaintsList; ValueAnimator valueAnimator; + ObjectAnimator ob; + private CurveGraphConfig.Builder builder; private boolean isConfigured; @@ -166,7 +168,7 @@ public void configure(CurveGraphConfig builder) { animationDuration = builder.animationDuration; } - public void setData(int span, int maxVal, GraphData... graphDataArray) { + public void setData(int span, int maxVal, final GraphData... graphDataArray) { this.maxVal = maxVal; this.xSpan = span; this.graphDataArray = graphDataArray; @@ -178,8 +180,11 @@ public void setData(int span, int maxVal, GraphData... graphDataArray) { if (valueAnimator != null) { valueAnimator.cancel(); } + if (ob != null) { + ob.cancel(); + } length = getLengths(); - ObjectAnimator ob = ObjectAnimator.ofFloat(this, "phase", 1f, 0f); + ob = ObjectAnimator.ofFloat(this, "phase", 1f, 0f); ob.setDuration(animationDuration); ob.setInterpolator(new AccelerateInterpolator()); ob.start(); @@ -197,6 +202,14 @@ public void onAnimationEnd(Animator animation) { @Override public void onAnimationCancel(Animator animation) { + for (int i = 0; i < graphGradientPaintsList.size(); i++) { + if (graphDataArray[i].isAnimateLine()) { + if (graphGradientPaintsList.get(i) != null) + graphGradientPaintsList.get(i).setAlpha(0); + graphPointPaintsList.get(i).setAlpha(0); + } + } + invalidate(); }