├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── even │ │ └── numbermorphview │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── even │ │ │ └── numbermorphview │ │ │ ├── NumberMorphView.java │ │ │ └── TimerView.java │ └── res │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ └── attrs.xml │ └── test │ └── java │ └── com │ └── even │ └── numbermorphview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── raw └── master │ └── screenshot │ └── sample.gif ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── even │ │ └── sample │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── even │ │ │ └── sample │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── even │ └── sample │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /app/build 2 | /.gradle 3 | *.iml 4 | .gradle 5 | /local.properties 6 | /.idea/workspace.xml 7 | /.idea/libraries 8 | .DS_Store 9 | /build 10 | /captures 11 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | NumberMorphView -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | NumberMorphView4Android 2 | ====== 3 | **NumberMorphView** for Android.
4 | Based on (https://github.com/me-abhinav/NumberMorphView) 5 | 6 | #### Screenshot 7 | ![](https://github.com/Even201314/NumberMorphView4Android/blob/master/raw/master/screenshot/sample.gif) 8 | 9 | 10 | ### Download 11 | First, Add it in your root build.gradle at the end of repositories: 12 | ```groovy 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | maven { url "https://jitpack.io" } 17 | } 18 | } 19 | ``` 20 | Then,Add the dependency: 21 | ```groovy 22 | compile 'com.github.Even201314:NumberMorphView4Android:1.2.0' 23 | ``` 24 | 25 | ## Usage 26 | * XML 27 | 28 | Add TimerView to the xml file : 29 | ```groovy 30 | 38 | ``` 39 | there are optional attributes to personalize the interface : 40 | 41 | Color : numColor, numBackgroundColor; 42 | 43 | Dimension : strokeWidth; 44 | 45 | Paint Style : strokeCap(BUTT,ROUND,SQUARE), strokeJoin(MITER,ROUND,BEVEL); 46 | 47 | * Code 48 | 49 | ```groovy 50 | numberMorphView.interpolator = new TimerView.LinearInterpolator(); 51 | numberMorphView.setPeriod(1000); 52 | ``` 53 | We support six Interpolators : 54 | 55 | LinearInterpolator, OvershootInterpolator, SpringInterpolator, 56 | BounceInterpolator, AnticipateOvershootInterpolator, CubicHermiteInterpolator; 57 | 58 | setPeriod() to set the interval time of animation; 59 | 60 | In this vesion 1.2.0, I use handler and message to achieve the timing, the code is in [sample](https://github.com/Even201314/NumberMorphView4Android/blob/master/sample/src/main/java/com/even/sample/MainActivity.java). 61 | 62 | ## License 63 | NumberMorphView4Android is available under the MIT license. See the LICENSE file for more info. 64 | 65 | ## Version 66 | * Version 1.2.0 67 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group = 'com.github.Even201314' 5 | 6 | android { 7 | compileSdkVersion 23 8 | buildToolsVersion "23.0.3" 9 | 10 | defaultConfig { 11 | minSdkVersion 15 12 | targetSdkVersion 23 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(dir: 'libs', include: ['*.jar']) 26 | testCompile 'junit:junit:4.12' 27 | compile 'com.android.support:appcompat-v7:23.4.0' 28 | } 29 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/even/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/even/numbermorphview/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.even.numbermorphview; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/com/even/numbermorphview/NumberMorphView.java: -------------------------------------------------------------------------------- 1 | package com.even.numbermorphview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.Path; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | 12 | import java.util.ArrayList; 13 | 14 | /** 15 | * NumberMorphView for Android 16 | * Created by even on 16/5/17. 17 | */ 18 | public class NumberMorphView extends View { 19 | private float screenWidth = 0; 20 | private float screenHeight = 0; 21 | 22 | //private properties 23 | private float[][][] endpoints_original = new float[10][5][2]; 24 | private float[][][] controlPoints1_original = new float[10][4][2]; 25 | private float[][][] controlPoints2_original = new float[10][4][2]; 26 | 27 | private float[][][] endpoints_scaled = new float[10][5][2]; 28 | private float[][][] controlPoints1_scaled = new float[10][4][2]; 29 | private float[][][] controlPoints2_scaled = new float[10][4][2]; 30 | 31 | private Paint paint; 32 | private Path path; 33 | @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") 34 | private ArrayList paths = new ArrayList<>(); 35 | 36 | private int currentIndex = 0; 37 | private int priorNum = 0; 38 | private double currentFrame = 0; 39 | private double period = 1000; 40 | protected boolean isFinished = false; 41 | 42 | public Interpolator interpolator = new OvershootInterpolator(1.3f); 43 | 44 | public NumberMorphView(Context context) { 45 | this(context, null); 46 | } 47 | 48 | public NumberMorphView(Context context, AttributeSet attrs) { 49 | this(context, attrs, 0); 50 | } 51 | 52 | public NumberMorphView(Context context, AttributeSet attrs, int defStyleAttr) { 53 | super(context, attrs, defStyleAttr); 54 | initStyle(context, attrs); 55 | init(); 56 | } 57 | 58 | private void initStyle(Context context, AttributeSet attrs) { 59 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.NumberMorphView); 60 | paint = new Paint(); 61 | path = new Path(); 62 | 63 | int numColor = typedArray.getColor(R.styleable.NumberMorphView_numColor, Color.BLACK); 64 | int backgroundColor = typedArray.getColor(R.styleable.NumberMorphView_numBackgroundColor, Color.TRANSPARENT); 65 | float strokeWidth = typedArray.getDimension(R.styleable.NumberMorphView_strokeWidth, 10); 66 | int capValue = typedArray.getInteger(R.styleable.NumberMorphView_strokeCap, 1); 67 | int joinValue = typedArray.getInteger(R.styleable.NumberMorphView_strokeJoin, 1); 68 | 69 | paint.setAntiAlias(true); 70 | paint.setStyle(Paint.Style.STROKE); 71 | paint.setStrokeCap(getCapFromInt(capValue)); 72 | paint.setStrokeJoin(getJoinFromInt(joinValue)); 73 | paint.setStrokeWidth(strokeWidth); 74 | paint.setColor(numColor); 75 | 76 | setBackgroundColor(backgroundColor); 77 | 78 | typedArray.recycle(); 79 | } 80 | 81 | private Paint.Cap getCapFromInt(int value) { 82 | Paint.Cap cap; 83 | switch (value) { 84 | case 0: 85 | cap = Paint.Cap.BUTT; 86 | break; 87 | case 1: 88 | cap = Paint.Cap.ROUND; 89 | break; 90 | case 2: 91 | cap = Paint.Cap.SQUARE; 92 | break; 93 | default: 94 | cap = Paint.Cap.ROUND; 95 | } 96 | return cap; 97 | } 98 | 99 | private Paint.Join getJoinFromInt(int value) { 100 | Paint.Join join; 101 | switch (value) { 102 | case 0: 103 | join = Paint.Join.MITER; 104 | break; 105 | case 1: 106 | join = Paint.Join.ROUND; 107 | break; 108 | case 2: 109 | join = Paint.Join.BEVEL; 110 | break; 111 | default: 112 | join = Paint.Join.ROUND; 113 | } 114 | return join; 115 | } 116 | 117 | private void init() { 118 | endpoints_original[0] = new float[][]{{500f, 800f}, {740f, 400f}, {500f, 0f}, {260f, 400f}, {500f, 800f}}; 119 | endpoints_original[1] = new float[][]{{383f, 712f}, {500f, 800f}, {500f, 0f}, {500f, 800f}, {383f, 712f}}; 120 | endpoints_original[2] = new float[][]{{300f, 640f}, {700f, 640f}, {591f, 369f}, {300f, 0f}, {700f, 0f}}; 121 | endpoints_original[3] = new float[][]{{300f, 600f}, {700f, 600f}, {500f, 400f}, {700f, 200f}, {300f, 200f}}; 122 | endpoints_original[4] = new float[][]{{650f, 0f}, {650f, 140f}, {650f, 800f}, {260f, 140f}, {760f, 140f}}; 123 | endpoints_original[5] = new float[][]{{645f, 800f}, {400f, 800f}, {300f, 480f}, {690f, 285f}, {272f, 92f}}; 124 | endpoints_original[6] = new float[][]{{640f, 800f}, {321f, 458f}, {715f, 144f}, {257f, 146f}, {321f, 458f}}; 125 | endpoints_original[7] = new float[][]{{275f, 800f}, {725f, 800f}, {586f, 544f}, {424f, 262f}, {275f, 0f}}; 126 | endpoints_original[8] = new float[][]{{500f, 400f}, {500f, 0f}, {500f, 400f}, {500f, 800f}, {500f, 400f}}; 127 | endpoints_original[9] = new float[][]{{679f, 342f}, {743f, 654f}, {285f, 656f}, {679f, 342f}, {360f, 0f}}; 128 | 129 | controlPoints1_original[0] = new float[][]{{650f, 800f}, {740f, 200f}, {350f, 0f}, {260f, 600f}}; 130 | controlPoints1_original[1] = new float[][]{{383f, 712f}, {500f, 488f}, {500f, 488f}, {383f, 712f}}; 131 | controlPoints1_original[2] = new float[][]{{335f, 853f}, {710f, 538f}, {477f, 213f}, {450f, 0f}}; 132 | controlPoints1_original[3] = new float[][]{{300f, 864f}, {700f, 400f}, {500f, 400f}, {700f, -64f}}; 133 | controlPoints1_original[4] = new float[][]{{650f, 50f}, {650f, 340f}, {502f, 572f}, {350f, 140f}}; 134 | controlPoints1_original[5] = new float[][]{{550f, 800f}, {400f, 800f}, {495f, 567f}, {717f, 30f}}; 135 | controlPoints1_original[6] = new float[][]{{578f, 730f}, {492f, 613f}, {634f, -50f}, {208f, 264f}}; 136 | controlPoints1_original[7] = new float[][]{{350f, 800f}, {676f, 700f}, {538f, 456f}, {366f, 160f}}; 137 | controlPoints1_original[8] = new float[][]{{775f, 400f}, {225f, 0f}, {225f, 400f}, {775f, 800f}}; 138 | controlPoints1_original[9] = new float[][]{{746f, 412f}, {662f, 850f}, {164f, 398f}, {561f, 219f}}; 139 | 140 | controlPoints2_original[0] = new float[][]{{740f, 600f}, {650f, 0f}, {260f, 200f}, {350f, 800f}}; 141 | controlPoints2_original[1] = new float[][]{{500f, 800f}, {500f, 312f}, {500f, 312f}, {500f, 800f}}; 142 | controlPoints2_original[2] = new float[][]{{665f, 853f}, {658f, 461f}, {424f, 164f}, {544f, 1f}}; 143 | controlPoints2_original[3] = new float[][]{{700f, 864f}, {500f, 400f}, {700f, 400f}, {300f, -64f}}; 144 | controlPoints2_original[4] = new float[][]{{650f, 100f}, {650f, 600f}, {356f, 347f}, {680f, 140f}}; 145 | controlPoints2_original[5] = new float[][]{{450f, 800f}, {300f, 480f}, {675f, 460f}, {410f, -100f}}; 146 | controlPoints2_original[6] = new float[][]{{455f, 602f}, {840f, 444f}, {337f, -46f}, {255f, 387f}}; 147 | controlPoints2_original[7] = new float[][]{{500f, 800f}, {634f, 631f}, {487f, 372f}, {334f, 102f}}; 148 | controlPoints2_original[8] = new float[][]{{775f, 0f}, {225f, 400f}, {225f, 800f}, {775f, 400f}}; 149 | controlPoints2_original[9] = new float[][]{{792f, 536f}, {371f, 840f}, {475f, 195f}, {432f, 79f}}; 150 | 151 | for (int digit = 0; digit < 10; digit++) { 152 | for (int pointIndex = 0; pointIndex < 5; pointIndex++) { 153 | endpoints_original[digit][pointIndex][1] = 800 - endpoints_original[digit][pointIndex][1]; 154 | 155 | if (pointIndex < 4) { 156 | controlPoints1_original[digit][pointIndex][1] = 800 - controlPoints1_original[digit][pointIndex][1]; 157 | controlPoints2_original[digit][pointIndex][1] = 800 - controlPoints2_original[digit][pointIndex][1]; 158 | } 159 | } 160 | } 161 | } 162 | 163 | private void scalePoints(float width, float height) { 164 | for (int digit = 0; digit < 10; digit++) { 165 | for (int pointIndex = 0; pointIndex < 5; pointIndex++) { 166 | endpoints_scaled[digit][pointIndex][0] = (float) (endpoints_original[digit][pointIndex][0] / 1000.0 * 167 | 1.4 - 0.2) * width; 168 | endpoints_scaled[digit][pointIndex][1] = (float) (endpoints_original[digit][pointIndex][1] / 800.0 * 169 | 0.6 + 0.2) * height; 170 | 171 | if (pointIndex < 4) { 172 | controlPoints1_scaled[digit][pointIndex][0] = (float) 173 | (controlPoints1_original[digit][pointIndex][0] / 1000.0 * 1.4 - 0.2) * width; 174 | controlPoints1_scaled[digit][pointIndex][1] = (float) 175 | (controlPoints1_original[digit][pointIndex][1] / 800.0 * 0.6 + 0.2) * height; 176 | 177 | controlPoints2_scaled[digit][pointIndex][0] = (float) 178 | (controlPoints2_original[digit][pointIndex][0] / 1000.0 * 1.4 - 0.2) * width; 179 | controlPoints2_scaled[digit][pointIndex][1] = (float) 180 | (controlPoints2_original[digit][pointIndex][1] / 800.0 * 0.6 + 0.2) * height; 181 | } 182 | } 183 | } 184 | } 185 | 186 | private void initializePaths() { 187 | if (paths == null) { 188 | paths = new ArrayList<>(); 189 | } 190 | paths.clear(); 191 | 192 | for (int digit = 0; digit < 10; digit++) { 193 | Path path = new Path(); 194 | float[][] p = endpoints_scaled[digit]; 195 | float[][] cp1 = controlPoints1_scaled[digit]; 196 | float[][] cp2 = controlPoints2_scaled[digit]; 197 | 198 | path.moveTo(p[0][0], p[0][1]); 199 | for (int i = 1; i < 5; i++) { 200 | path.cubicTo(cp1[i - 1][0], cp1[i - 1][1], cp2[i - 1][0], cp2[i - 1][1], p[i][0], p[i][1]); 201 | } 202 | paths.add(path); 203 | } 204 | } 205 | 206 | private void updateAnimationFrame() { 207 | float[][] pCur = endpoints_scaled[priorNum]; 208 | float[][] cp1Cur = controlPoints1_scaled[priorNum]; 209 | float[][] cp2Cur = controlPoints2_scaled[priorNum]; 210 | 211 | int nextIndex = currentIndex; 212 | float[][] pNext = endpoints_scaled[nextIndex]; 213 | float[][] cp1Next = controlPoints1_scaled[nextIndex]; 214 | float[][] cp2Next = controlPoints2_scaled[nextIndex]; 215 | 216 | path.reset(); 217 | float factor = interpolator.getInterpolation((float) (currentFrame >= 30 ? 30 : currentFrame) / 30f); 218 | 219 | path.moveTo(pCur[0][0] + (pNext[0][0] - pCur[0][0]) * factor, pCur[0][1] + (pNext[0][1] - pCur[0][1]) * factor); 220 | for (int i = 1; i < 5; i++) { 221 | float ex = pCur[i][0] + (pNext[i][0] - pCur[i][0]) * factor; 222 | float ey = pCur[i][1] + (pNext[i][1] - pCur[i][1]) * factor; 223 | 224 | int iMinus = i - 1; 225 | float cp1x = cp1Cur[iMinus][0] + (cp1Next[iMinus][0] - cp1Cur[iMinus][0]) * factor; 226 | float cp1y = cp1Cur[iMinus][1] + (cp1Next[iMinus][1] - cp1Cur[iMinus][1]) * factor; 227 | 228 | float cp2x = cp2Cur[iMinus][0] + (cp2Next[iMinus][0] - cp2Cur[iMinus][0]) * factor; 229 | float cp2y = cp2Cur[iMinus][1] + (cp2Next[iMinus][1] - cp2Cur[iMinus][1]) * factor; 230 | 231 | path.cubicTo(cp1x, cp1y, cp2x, cp2y, ex, ey); 232 | } 233 | currentFrame += period; 234 | 235 | if (currentFrame >= 30) { 236 | drawDigitWithoutAnimation(nextIndex); 237 | } 238 | } 239 | 240 | protected void drawDigitWithoutAnimation(int currentDigit) { 241 | float[][] p = endpoints_scaled[currentDigit]; 242 | float[][] cp1 = controlPoints1_scaled[currentDigit]; 243 | float[][] cp2 = controlPoints2_scaled[currentDigit]; 244 | 245 | path.reset(); 246 | 247 | path.moveTo(p[0][0], p[0][1]); 248 | for (int i = 1; i < 5; i++) { 249 | path.cubicTo(cp1[i - 1][0], cp1[i - 1][1], cp2[i - 1][0], cp2[i - 1][1], p[i][0], p[i][1]); 250 | } 251 | } 252 | 253 | protected void updateNumber() { 254 | if (currentFrame <= 30) { 255 | postInvalidate(); 256 | } else { 257 | currentFrame += period; 258 | if (currentFrame >= 60) { 259 | isFinished = true; 260 | currentFrame = 0; 261 | } 262 | } 263 | } 264 | 265 | @Override 266 | protected void onDraw(Canvas canvas) { 267 | if (screenWidth != getWidth() || screenHeight != getHeight()) { 268 | screenWidth = getWidth(); 269 | screenHeight = getHeight(); 270 | scalePoints(screenWidth, screenHeight); 271 | initializePaths(); 272 | } 273 | 274 | updateAnimationFrame(); 275 | canvas.drawPath(path, paint); 276 | super.onDraw(canvas); 277 | } 278 | 279 | protected int getCurrentIndex() { 280 | return currentIndex; 281 | } 282 | 283 | protected void setCurrentIndex(int currentIndex) { 284 | priorNum = this.currentIndex; 285 | this.currentIndex = currentIndex; 286 | } 287 | 288 | @SuppressWarnings("unused") 289 | public double getPeriod() { 290 | return period; 291 | } 292 | 293 | public void setPeriod(double period) { 294 | this.period = period; 295 | } 296 | 297 | /** 298 | * --------------------Interpolator------------------- 299 | **/ 300 | public interface Interpolator { 301 | float getInterpolation(float x); 302 | } 303 | 304 | public static class LinearInterpolator implements Interpolator { 305 | 306 | @Override 307 | public float getInterpolation(float x) { 308 | return x; 309 | } 310 | } 311 | 312 | public static class OvershootInterpolator implements Interpolator { 313 | private float tension; 314 | 315 | public OvershootInterpolator() { 316 | this(2.0f); 317 | } 318 | 319 | public OvershootInterpolator(float tension) { 320 | this.tension = tension; 321 | } 322 | 323 | @Override 324 | public float getInterpolation(float x) { 325 | float x2 = x - 1.0f; 326 | return x2 * x2 * ((tension + 1) * x2 + tension) + 1.0f; 327 | } 328 | } 329 | 330 | public static class SpringInterpolator implements Interpolator { 331 | private float tension; 332 | private static final float PI = 3.141592653f; 333 | 334 | public SpringInterpolator() { 335 | this(0.3f); 336 | } 337 | 338 | public SpringInterpolator(float tension) { 339 | this.tension = tension; 340 | } 341 | 342 | @Override 343 | public float getInterpolation(float x) { 344 | return (float) (Math.pow(2, -10 * x) * Math.sin((x - tension / 4) * (2 * PI) / tension) + 1); 345 | 346 | } 347 | } 348 | 349 | public static class BounceInterpolator implements Interpolator { 350 | public BounceInterpolator() { 351 | } 352 | 353 | private float bounce(float t) { 354 | return t * t * 8; 355 | } 356 | 357 | @Override 358 | public float getInterpolation(float x) { 359 | if (x < 0.3535) { 360 | return bounce(x); 361 | } else if (x < 0.7408) { 362 | return bounce(x - 0.54719f) + 0.7f; 363 | } else if (x < 0.9644) { 364 | return bounce(x - 0.8526f) + 0.9f; 365 | } else { 366 | return bounce(x - 1.0435f) + 0.95f; 367 | } 368 | } 369 | } 370 | 371 | public static class AnticipateOvershootInterpolator implements Interpolator { 372 | private float tension; 373 | 374 | public AnticipateOvershootInterpolator() { 375 | this(2.0f); 376 | } 377 | 378 | public AnticipateOvershootInterpolator(float tension) { 379 | this.tension = tension; 380 | } 381 | 382 | private float anticipate(float x, float tension) { 383 | return x * x * ((tension + 1) * x - tension); 384 | } 385 | 386 | private float overshoot(float x, float tension) { 387 | return x * x * ((tension + 1) * x + tension); 388 | } 389 | 390 | @Override 391 | public float getInterpolation(float x) { 392 | if (x < 0.5) { 393 | return 0.5f * anticipate(x * 2.0f, tension); 394 | } else { 395 | return 0.5f * (overshoot(x * 2.0f - 2.0f, tension) + 2.0f); 396 | } 397 | } 398 | } 399 | 400 | public static class CubicHermiteInterpolator implements Interpolator { 401 | private float tangent0; 402 | private float tangent1; 403 | 404 | public CubicHermiteInterpolator() { 405 | this(2.2f, 2.2f); 406 | } 407 | 408 | public CubicHermiteInterpolator(float tangent0, float tangent1) { 409 | this.tangent0 = tangent0; 410 | this.tangent1 = tangent1; 411 | } 412 | 413 | private float cubicHermite(float t, float start, float end, float tangent0, float tangent1) { 414 | float t2 = t * t; 415 | float t3 = t2 * t; 416 | return (2 * t3 - 3 * t2 + 1) * start + (t3 - 2 * t2 + t) * tangent0 + (-2 * t3 + 3 * t2) * end + (t3 - 417 | t2) * tangent1; 418 | } 419 | 420 | @Override 421 | public float getInterpolation(float x) { 422 | return cubicHermite(x, 0, 1, tangent0, tangent1); 423 | 424 | } 425 | } 426 | } -------------------------------------------------------------------------------- /app/src/main/java/com/even/numbermorphview/TimerView.java: -------------------------------------------------------------------------------- 1 | package com.even.numbermorphview; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.util.AttributeSet; 7 | 8 | /** 9 | * TimerView 10 | * Created by Even on 20/5/16. 11 | */ 12 | public class TimerView extends NumberMorphView { 13 | 14 | public TimerView(Context context) { 15 | super(context); 16 | } 17 | 18 | public TimerView(Context context, AttributeSet attrs) { 19 | super(context, attrs); 20 | } 21 | 22 | public TimerView(Context context, AttributeSet attrs, int defStyleAttr) { 23 | super(context, attrs, defStyleAttr); 24 | } 25 | 26 | private boolean mRunning; 27 | private boolean mVisible; 28 | private boolean mStarted; 29 | private static final int TICK_WHAT = 2; 30 | 31 | private Handler mHandler = new Handler() { 32 | @Override 33 | public void handleMessage(Message msg) { 34 | if (mRunning) { 35 | if (isFinished) { 36 | stop(); 37 | isFinished = false; 38 | } else { 39 | updateNumber(); 40 | sendMessageDelayed(Message.obtain(this, TICK_WHAT), 0); 41 | } 42 | } 43 | } 44 | }; 45 | 46 | @Override 47 | protected void onDetachedFromWindow() { 48 | super.onDetachedFromWindow(); 49 | mVisible = false; 50 | updateRunning(); 51 | } 52 | 53 | @Override 54 | protected void onWindowVisibilityChanged(int visibility) { 55 | super.onWindowVisibilityChanged(visibility); 56 | mVisible = visibility == VISIBLE; 57 | updateRunning(); 58 | } 59 | 60 | private void updateRunning() { 61 | boolean running = mVisible && mStarted; 62 | if (running != mRunning) { 63 | if (running) { 64 | updateNumber(); 65 | mHandler.sendMessageDelayed(Message.obtain(mHandler, TICK_WHAT), 0); 66 | } else { 67 | mHandler.removeMessages(TICK_WHAT); 68 | } 69 | mRunning = running; 70 | } 71 | } 72 | 73 | @Override 74 | public void setPeriod(double period) { 75 | super.setPeriod(1000.0 / period); 76 | } 77 | 78 | @SuppressWarnings("unused") 79 | public void start() { 80 | mStarted = true; 81 | updateRunning(); 82 | } 83 | 84 | @SuppressWarnings("unused") 85 | public void stop() { 86 | mStarted = false; 87 | updateRunning(); 88 | } 89 | 90 | public void setCurrentNum(int currentNum) { 91 | setCurrentIndex(currentNum); 92 | start(); 93 | } 94 | 95 | @SuppressWarnings("unused") 96 | public int getCurrentNum() { 97 | return getCurrentIndex(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/test/java/com/even/numbermorphview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.even.numbermorphview; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.0' 9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /raw/master/screenshot/sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/raw/master/screenshot/sample.gif -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.even.sample" 9 | minSdkVersion 15 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.4.0' 26 | compile project(path: ':app') 27 | } 28 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/even/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/even/sample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.even.sample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/java/com/even/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.even.sample; 2 | 3 | import android.os.Bundle; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.support.v7.app.AppCompatActivity; 7 | 8 | import com.even.numbermorphview.TimerView; 9 | 10 | import java.util.Calendar; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | private TimerView numberMorphView; 14 | private TimerView numberMorphView1; 15 | private TimerView numberMorphView2; 16 | private TimerView numberMorphView3; 17 | private TimerView numberMorphView4; 18 | private TimerView numberMorphView5; 19 | 20 | private TimerView numberMorphView6; 21 | private TimerView numberMorphView7; 22 | private TimerView numberMorphView8; 23 | private TimerView numberMorphView9; 24 | private TimerView numberMorphView10; 25 | private TimerView numberMorphView11; 26 | 27 | 28 | private static final int TICK_WHAT = 1; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | 35 | numberMorphView = (TimerView) findViewById(R.id.numberMorphView); 36 | numberMorphView1 = (TimerView) findViewById(R.id.numberMorphView1); 37 | numberMorphView2 = (TimerView) findViewById(R.id.numberMorphView2); 38 | numberMorphView3 = (TimerView) findViewById(R.id.numberMorphView3); 39 | numberMorphView4 = (TimerView) findViewById(R.id.numberMorphView4); 40 | numberMorphView5 = (TimerView) findViewById(R.id.numberMorphView5); 41 | 42 | numberMorphView6 = (TimerView) findViewById(R.id.numberMorphView6); 43 | numberMorphView7 = (TimerView) findViewById(R.id.numberMorphView7); 44 | numberMorphView8 = (TimerView) findViewById(R.id.numberMorphView8); 45 | numberMorphView9 = (TimerView) findViewById(R.id.numberMorphView9); 46 | numberMorphView10 = (TimerView) findViewById(R.id.numberMorphView10); 47 | numberMorphView11 = (TimerView) findViewById(R.id.numberMorphView11); 48 | 49 | if (numberMorphView != null) { 50 | numberMorphView.interpolator = new TimerView.LinearInterpolator(); 51 | numberMorphView.setPeriod(1000); 52 | } 53 | if (numberMorphView1 != null) { 54 | numberMorphView1.interpolator = new TimerView.OvershootInterpolator(); 55 | numberMorphView1.setPeriod(1000); 56 | } 57 | if (numberMorphView2 != null) { 58 | numberMorphView2.interpolator = new TimerView.SpringInterpolator(); 59 | numberMorphView2.setPeriod(1000); 60 | } 61 | if (numberMorphView3 != null) { 62 | numberMorphView3.interpolator = new TimerView.BounceInterpolator(); 63 | numberMorphView3.setPeriod(1000); 64 | } 65 | if (numberMorphView4 != null) { 66 | numberMorphView4.interpolator = new TimerView.AnticipateOvershootInterpolator(); 67 | numberMorphView4.setPeriod(1000); 68 | } 69 | if (numberMorphView5 != null) { 70 | numberMorphView5.interpolator = new TimerView.CubicHermiteInterpolator(); 71 | numberMorphView5.setPeriod(1000); 72 | } 73 | 74 | if (numberMorphView6 != null) { 75 | numberMorphView6.interpolator = new TimerView.LinearInterpolator(); 76 | numberMorphView6.setPeriod(1000); 77 | } 78 | if (numberMorphView7 != null) { 79 | numberMorphView7.interpolator = new TimerView.OvershootInterpolator(); 80 | numberMorphView7.setPeriod(1000); 81 | } 82 | if (numberMorphView8 != null) { 83 | numberMorphView8.interpolator = new TimerView.SpringInterpolator(); 84 | numberMorphView8.setPeriod(1000); 85 | } 86 | if (numberMorphView9 != null) { 87 | numberMorphView9.interpolator = new TimerView.BounceInterpolator(); 88 | numberMorphView9.setPeriod(1000); 89 | } 90 | if (numberMorphView10 != null) { 91 | numberMorphView10.interpolator = new TimerView.AnticipateOvershootInterpolator(); 92 | numberMorphView10.setPeriod(1000); 93 | } 94 | if (numberMorphView11 != null) { 95 | numberMorphView11.interpolator = new TimerView.CubicHermiteInterpolator(); 96 | numberMorphView11.setPeriod(1000); 97 | } 98 | 99 | mHandler.sendMessageDelayed(Message.obtain(mHandler, TICK_WHAT), 1000); 100 | } 101 | 102 | private Handler mHandler = new Handler() { 103 | @Override 104 | public void handleMessage(Message msg) { 105 | Calendar calendar = Calendar.getInstance(); 106 | 107 | int hour = calendar.get(Calendar.HOUR); 108 | int minute = calendar.get(Calendar.MINUTE); 109 | int second = calendar.get(Calendar.SECOND); 110 | 111 | numberMorphView.setCurrentNum((hour / 10) % 24); 112 | numberMorphView1.setCurrentNum(hour % 10); 113 | 114 | numberMorphView2.setCurrentNum((minute / 10) % 6); 115 | numberMorphView3.setCurrentNum(minute % 10); 116 | 117 | numberMorphView4.setCurrentNum((second / 10) % 6); 118 | 119 | numberMorphView5.setCurrentNum(second % 10); 120 | 121 | numberMorphView6.setCurrentNum(second % 10); 122 | numberMorphView7.setCurrentNum(second % 10); 123 | numberMorphView8.setCurrentNum(second % 10); 124 | numberMorphView9.setCurrentNum(second % 10); 125 | numberMorphView10.setCurrentNum(second % 10); 126 | numberMorphView11.setCurrentNum(second % 10); 127 | 128 | sendMessageDelayed(Message.obtain(this, TICK_WHAT), 1000); 129 | } 130 | }; 131 | 132 | @Override 133 | protected void onResume() { 134 | super.onResume(); 135 | } 136 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 22 | 23 | 33 | 34 | 44 | 45 | 52 | 53 | 61 | 62 | 69 | 70 | 71 | 77 | 78 | 86 | 87 | 97 | 98 | 108 | 109 | 115 | 116 | 125 | 126 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Even201314/NumberMorphView4Android/800687114d715ca832634e6322926c8b52024847/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Sample 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/test/java/com/even/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.even.sample; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':sample' 2 | --------------------------------------------------------------------------------