View DrawTiles.java
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = getWidth();
int height = getHeight();
float size = (width > height ? height : width) - tileMargin * 2;
float tileSize = size / 3;
View SetRadiusAndColor.java
public void setRadius(int radius) {
this.radius = radius;
postInvalidate();
}
public void setColor(int color) {
this.color = color;
postInvalidate();
}
View StartAnimation.java
public void start() {
ValueAnimator animator = ValueAnimator.ofInt(0, 1);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
frame = animation.getAnimatedFraction();
postInvalidate();
}
});
animator.setDuration(durationRotate);
View DrawCircles.java
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int width = getWidth();
int height = getHeight();
// o ㅡㅡ o
//
//
// o o
View GetCenter.java
// "positive" is increasing positively horizontally
private float[] getHorizontalCenter(int width, int height, boolean positive) {
float x = (width - 2 * radius) * (positive ? frame : 1 - frame) + radius;
float y = positive ? radius : height - radius;
return new float[] {x, y};
}
// "negative" is increasing negatively vertically
private float[] getVerticalCenter(int width, int height, boolean negative) {
float x = negative ? width - radius : radius;
View ResetPaint.java
// reset paint object and set color, style, alpha by step
private void resetPaint(int step) {
paint.reset();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
paint.setColor(color);
if (step < 3) {
paint.setAlpha((int) (255 - (step + frame) * (255 - ALPHA_FINAL) / 3));