Skip to content

Commit 7a1d174

Browse files
committed
Configuration enhancements
1 parent 5255447 commit 7a1d174

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

graphview/src/main/java/com/broooapps/graphview/CurveGraphView.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class CurveGraphView extends View {
7373
ArrayList<Paint> graphPointPaintsList;
7474

7575
ValueAnimator valueAnimator;
76+
ObjectAnimator ob;
77+
7678

7779
private CurveGraphConfig.Builder builder;
7880
private boolean isConfigured;
@@ -166,7 +168,7 @@ public void configure(CurveGraphConfig builder) {
166168
animationDuration = builder.animationDuration;
167169
}
168170

169-
public void setData(int span, int maxVal, GraphData... graphDataArray) {
171+
public void setData(int span, int maxVal, final GraphData... graphDataArray) {
170172
this.maxVal = maxVal;
171173
this.xSpan = span;
172174
this.graphDataArray = graphDataArray;
@@ -178,8 +180,11 @@ public void setData(int span, int maxVal, GraphData... graphDataArray) {
178180
if (valueAnimator != null) {
179181
valueAnimator.cancel();
180182
}
183+
if (ob != null) {
184+
ob.cancel();
185+
}
181186
length = getLengths();
182-
ObjectAnimator ob = ObjectAnimator.ofFloat(this, "phase", 1f, 0f);
187+
ob = ObjectAnimator.ofFloat(this, "phase", 1f, 0f);
183188
ob.setDuration(animationDuration);
184189
ob.setInterpolator(new AccelerateInterpolator());
185190
ob.start();
@@ -197,6 +202,14 @@ public void onAnimationEnd(Animator animation) {
197202

198203
@Override
199204
public void onAnimationCancel(Animator animation) {
205+
for (int i = 0; i < graphGradientPaintsList.size(); i++) {
206+
if (graphDataArray[i].isAnimateLine()) {
207+
if (graphGradientPaintsList.get(i) != null)
208+
graphGradientPaintsList.get(i).setAlpha(0);
209+
graphPointPaintsList.get(i).setAlpha(0);
210+
}
211+
}
212+
invalidate();
200213

201214
}
202215

0 commit comments

Comments
 (0)