Skip to content

Commit

Permalink
Configuration enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil1104 committed Mar 21, 2020
1 parent 5255447 commit 7a1d174
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class CurveGraphView extends View {
ArrayList<Paint> graphPointPaintsList;

ValueAnimator valueAnimator;
ObjectAnimator ob;


private CurveGraphConfig.Builder builder;
private boolean isConfigured;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();

}

Expand Down

0 comments on commit 7a1d174

Please sign in to comment.