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 6c39403 commit 5255447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.broooapps.graphview;

import android.app.AlertDialog.Builder;
import android.content.Context;

import androidx.annotation.ColorInt;
Expand All @@ -11,8 +10,6 @@

public class CurveGraphConfig {

private WeakReference<Context> ctxWeakRef;

@ColorInt
int axisColor;

Expand All @@ -38,8 +35,8 @@ private CurveGraphConfig(Builder builder) {
yAxisScaleColor = (builder.yAxisScaleColor == 0) ? ContextCompat.getColor(builder.ctxWeakRef.get(), R.color.scaleTextColor) : builder.yAxisScaleColor;
guidelineColor = (builder.guidelineColor == 0) ? ContextCompat.getColor(builder.ctxWeakRef.get(), R.color.guidelineColor) : builder.guidelineColor;
axisColor = (builder.axisColor == 0) ? ContextCompat.getColor(builder.ctxWeakRef.get(), R.color.axisColor) : builder.axisColor;
intervalCount = (builder.intervalCount == 0) ? 5 : builder.intervalCount;
guidelineCount = (builder.guidelineCount == 0) ? 5 : builder.guidelineCount;
intervalCount = builder.intervalCount;
guidelineCount = builder.guidelineCount;
noDataMsg = (builder.noDataMsg == null) ? "NO DATA" : builder.noDataMsg;
animationDuration = builder.animationDuration;
builder.ctxWeakRef.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class CurveGraphView extends View {
ArrayList<ArrayList<GraphPoint>> graphPointsList;
ArrayList<Paint> graphPointPaintsList;

ValueAnimator valueAnimator;

private CurveGraphConfig.Builder builder;
private boolean isConfigured;

Expand Down Expand Up @@ -173,6 +175,9 @@ public void setData(int span, int maxVal, GraphData... graphDataArray) {
graphPointPaintsList.clear();
graphPointsList.clear();
pathArrayList = constructPaths();
if (valueAnimator != null) {
valueAnimator.cancel();
}
length = getLengths();
ObjectAnimator ob = ObjectAnimator.ofFloat(this, "phase", 1f, 0f);
ob.setDuration(animationDuration);
Expand Down Expand Up @@ -246,7 +251,7 @@ private void drawGuideline(Canvas canvas) {
}

private void startGradientAnimation() {
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator = new ValueAnimator();
PropertyValuesHolder alphaFactor = PropertyValuesHolder.ofInt("PROPERTY_ALPHA", 0, 255);

valueAnimator.setValues(alphaFactor);
Expand Down

0 comments on commit 5255447

Please sign in to comment.