-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformatted code according to my code style
- Loading branch information
Showing
91 changed files
with
7,597 additions
and
7,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 55 additions & 54 deletions
109
hellocharts-library/src/lecho/lib/hellocharts/animation/ChartDataAnimatorV14.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,77 @@ | ||
package lecho.lib.hellocharts.animation; | ||
|
||
import lecho.lib.hellocharts.view.Chart; | ||
import android.animation.Animator; | ||
import android.animation.Animator.AnimatorListener; | ||
import android.animation.ValueAnimator; | ||
import android.animation.ValueAnimator.AnimatorUpdateListener; | ||
import android.annotation.SuppressLint; | ||
|
||
import lecho.lib.hellocharts.view.Chart; | ||
|
||
@SuppressLint("NewApi") | ||
public class ChartDataAnimatorV14 implements ChartDataAnimator, AnimatorListener, AnimatorUpdateListener { | ||
private ValueAnimator animator; | ||
private final Chart chart; | ||
private ChartAnimationListener animationListener = new DummyChartAnimationListener(); | ||
private ValueAnimator animator; | ||
private final Chart chart; | ||
private ChartAnimationListener animationListener = new DummyChartAnimationListener(); | ||
|
||
public ChartDataAnimatorV14(Chart chart) { | ||
this.chart = chart; | ||
animator = ValueAnimator.ofFloat(0.0f, 1.0f); | ||
animator.addListener(this); | ||
animator.addUpdateListener(this); | ||
} | ||
public ChartDataAnimatorV14(Chart chart) { | ||
this.chart = chart; | ||
animator = ValueAnimator.ofFloat(0.0f, 1.0f); | ||
animator.addListener(this); | ||
animator.addUpdateListener(this); | ||
} | ||
|
||
@Override | ||
public void startAnimation(long duration) { | ||
if (duration >= 0) { | ||
animator.setDuration(duration); | ||
} else { | ||
animator.setDuration(DEFAULT_ANIMATION_DURATION); | ||
} | ||
animator.start(); | ||
} | ||
@Override | ||
public void startAnimation(long duration) { | ||
if (duration >= 0) { | ||
animator.setDuration(duration); | ||
} else { | ||
animator.setDuration(DEFAULT_ANIMATION_DURATION); | ||
} | ||
animator.start(); | ||
} | ||
|
||
@Override | ||
public void cancelAnimation() { | ||
animator.cancel(); | ||
} | ||
@Override | ||
public void cancelAnimation() { | ||
animator.cancel(); | ||
} | ||
|
||
@Override | ||
public void onAnimationUpdate(ValueAnimator animation) { | ||
chart.animationDataUpdate(animation.getAnimatedFraction()); | ||
} | ||
@Override | ||
public void onAnimationUpdate(ValueAnimator animation) { | ||
chart.animationDataUpdate(animation.getAnimatedFraction()); | ||
} | ||
|
||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
} | ||
@Override | ||
public void onAnimationCancel(Animator animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
chart.animationDataFinished(); | ||
animationListener.onAnimationFinished(); | ||
} | ||
@Override | ||
public void onAnimationEnd(Animator animation) { | ||
chart.animationDataFinished(); | ||
animationListener.onAnimationFinished(); | ||
} | ||
|
||
@Override | ||
public void onAnimationRepeat(Animator animation) { | ||
} | ||
@Override | ||
public void onAnimationRepeat(Animator animation) { | ||
} | ||
|
||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
animationListener.onAnimationStarted(); | ||
} | ||
@Override | ||
public void onAnimationStart(Animator animation) { | ||
animationListener.onAnimationStarted(); | ||
} | ||
|
||
@Override | ||
public boolean isAnimationStarted() { | ||
return animator.isStarted(); | ||
} | ||
@Override | ||
public boolean isAnimationStarted() { | ||
return animator.isStarted(); | ||
} | ||
|
||
@Override | ||
public void setChartAnimationListener(ChartAnimationListener animationListener) { | ||
if (null == animationListener) { | ||
this.animationListener = new DummyChartAnimationListener(); | ||
} else { | ||
this.animationListener = animationListener; | ||
} | ||
} | ||
@Override | ||
public void setChartAnimationListener(ChartAnimationListener animationListener) { | ||
if (null == animationListener) { | ||
this.animationListener = new DummyChartAnimationListener(); | ||
} else { | ||
this.animationListener = animationListener; | ||
} | ||
} | ||
|
||
} |
117 changes: 59 additions & 58 deletions
117
hellocharts-library/src/lecho/lib/hellocharts/animation/ChartDataAnimatorV8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,77 @@ | ||
package lecho.lib.hellocharts.animation; | ||
|
||
import lecho.lib.hellocharts.view.Chart; | ||
import android.os.Handler; | ||
import android.os.SystemClock; | ||
import android.view.animation.AccelerateDecelerateInterpolator; | ||
import android.view.animation.Interpolator; | ||
|
||
import lecho.lib.hellocharts.view.Chart; | ||
|
||
public class ChartDataAnimatorV8 implements ChartDataAnimator { | ||
|
||
long start; | ||
boolean isAnimationStarted = false; | ||
long duration; | ||
final Chart chart; | ||
final Handler handler; | ||
final Interpolator interpolator = new AccelerateDecelerateInterpolator(); | ||
private ChartAnimationListener animationListener = new DummyChartAnimationListener(); | ||
private final Runnable runnable = new Runnable() { | ||
long start; | ||
boolean isAnimationStarted = false; | ||
long duration; | ||
final Chart chart; | ||
final Handler handler; | ||
final Interpolator interpolator = new AccelerateDecelerateInterpolator(); | ||
private ChartAnimationListener animationListener = new DummyChartAnimationListener(); | ||
private final Runnable runnable = new Runnable() { | ||
|
||
@Override | ||
public void run() { | ||
long elapsed = SystemClock.uptimeMillis() - start; | ||
if (elapsed > duration) { | ||
isAnimationStarted = false; | ||
handler.removeCallbacks(runnable); | ||
chart.animationDataFinished(); | ||
return; | ||
} | ||
float scale = Math.min(interpolator.getInterpolation((float) elapsed / duration), 1); | ||
chart.animationDataUpdate(scale); | ||
handler.postDelayed(this, 16); | ||
@Override | ||
public void run() { | ||
long elapsed = SystemClock.uptimeMillis() - start; | ||
if (elapsed > duration) { | ||
isAnimationStarted = false; | ||
handler.removeCallbacks(runnable); | ||
chart.animationDataFinished(); | ||
return; | ||
} | ||
float scale = Math.min(interpolator.getInterpolation((float) elapsed / duration), 1); | ||
chart.animationDataUpdate(scale); | ||
handler.postDelayed(this, 16); | ||
|
||
} | ||
}; | ||
} | ||
}; | ||
|
||
public ChartDataAnimatorV8(Chart chart) { | ||
this.chart = chart; | ||
this.handler = new Handler(); | ||
} | ||
public ChartDataAnimatorV8(Chart chart) { | ||
this.chart = chart; | ||
this.handler = new Handler(); | ||
} | ||
|
||
@Override | ||
public void startAnimation(long duration) { | ||
if (duration >= 0) { | ||
this.duration = duration; | ||
} else { | ||
this.duration = DEFAULT_ANIMATION_DURATION; | ||
} | ||
@Override | ||
public void startAnimation(long duration) { | ||
if (duration >= 0) { | ||
this.duration = duration; | ||
} else { | ||
this.duration = DEFAULT_ANIMATION_DURATION; | ||
} | ||
|
||
isAnimationStarted = true; | ||
animationListener.onAnimationStarted(); | ||
start = SystemClock.uptimeMillis(); | ||
handler.post(runnable); | ||
} | ||
isAnimationStarted = true; | ||
animationListener.onAnimationStarted(); | ||
start = SystemClock.uptimeMillis(); | ||
handler.post(runnable); | ||
} | ||
|
||
@Override | ||
public void cancelAnimation() { | ||
isAnimationStarted = false; | ||
handler.removeCallbacks(runnable); | ||
chart.animationDataFinished(); | ||
animationListener.onAnimationFinished(); | ||
} | ||
@Override | ||
public void cancelAnimation() { | ||
isAnimationStarted = false; | ||
handler.removeCallbacks(runnable); | ||
chart.animationDataFinished(); | ||
animationListener.onAnimationFinished(); | ||
} | ||
|
||
@Override | ||
public boolean isAnimationStarted() { | ||
return isAnimationStarted; | ||
} | ||
@Override | ||
public boolean isAnimationStarted() { | ||
return isAnimationStarted; | ||
} | ||
|
||
@Override | ||
public void setChartAnimationListener(ChartAnimationListener animationListener) { | ||
if (null == animationListener) { | ||
this.animationListener = new DummyChartAnimationListener(); | ||
} else { | ||
this.animationListener = animationListener; | ||
} | ||
} | ||
@Override | ||
public void setChartAnimationListener(ChartAnimationListener animationListener) { | ||
if (null == animationListener) { | ||
this.animationListener = new DummyChartAnimationListener(); | ||
} else { | ||
this.animationListener = animationListener; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.