├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── liyanzhao.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── Design.gif ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── ui │ │ └── trainer │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── ui │ │ │ └── trainer │ │ │ ├── DataAnimation.java │ │ │ ├── DataAnimationListener.java │ │ │ ├── MainActivity.java │ │ │ ├── Point.java │ │ │ └── view │ │ │ ├── BezierView.java │ │ │ └── FloatingActionButton.java │ └── res │ │ ├── drawable-xhdpi │ │ ├── card0.png │ │ ├── card1.png │ │ ├── card2.png │ │ └── card3.png │ │ ├── drawable-xxhdpi │ │ └── real_bg.png │ │ ├── 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-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── ui │ └── trainer │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── implement.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Trainer -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/liyanzhao.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.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 | 47 | 48 | 49 | 50 | 51 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /Design.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/Design.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trainer 2 | [Design:MartinRGB](https://dribbble.com/shots/2346124-Private-Trainer-Course-List) 3 | 4 | 实现效果图 5 | ![image](https://github.com/liyanzhao/Trainer/blob/master/implement.gif) 6 | 7 | 设计图 8 | ![image](https://github.com/liyanzhao/Trainer/blob/master/Design.gif) 9 | 10 | 11 | 贝塞尔曲线参考:[hellocharts-android](https://github.com/lecho/hellocharts-android) 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.ui.trainer" 9 | minSdkVersion 12 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 | 25 | final SUPPORT_LIBRARY_VERSION = '23.2.1' 26 | 27 | compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" 28 | compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" 29 | compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION" 30 | compile "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION" 31 | 32 | compile 'com.jakewharton:butterknife:7.0.1' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /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/liyanzhao/Downloads/Android/adt-bundle-mac-x86_64-20131030/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/ui/trainer/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 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 | 14 | 15 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/DataAnimation.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 2 | 3 | import android.animation.Animator; 4 | import android.animation.TimeInterpolator; 5 | import android.animation.ValueAnimator; 6 | 7 | /** 8 | * @author LiYanZhao 9 | * @date 16-3-19 下午5:13 10 | */ 11 | public class DataAnimation implements Animator.AnimatorListener, ValueAnimator.AnimatorUpdateListener { 12 | ValueAnimator mValueAnimator; 13 | private DataAnimationListener mDataAnimationListener; 14 | 15 | private final long DEFAULT_DURATION = 500; 16 | 17 | public DataAnimation() { 18 | mValueAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); 19 | mValueAnimator.addListener(this); 20 | mValueAnimator.addUpdateListener(this); 21 | 22 | mDataAnimationListener = new DataAnimationListener() { 23 | @Override 24 | public void onAnimationUpdate(float scale) { 25 | 26 | } 27 | 28 | @Override 29 | public void onAnimationFinish() { 30 | 31 | } 32 | 33 | @Override 34 | public void onAnimationStart(Animator animation) { 35 | 36 | } 37 | 38 | }; 39 | } 40 | 41 | public void startAnimation(long duration) { 42 | if (duration >= 0) { 43 | mValueAnimator.setDuration(duration); 44 | } else { 45 | mValueAnimator.setDuration(DEFAULT_DURATION); 46 | } 47 | mValueAnimator.start(); 48 | } 49 | 50 | public void cancelAnimation() { 51 | mValueAnimator.cancel(); 52 | } 53 | 54 | @Override 55 | public void onAnimationUpdate(ValueAnimator animation) { 56 | mDataAnimationListener.onAnimationUpdate(animation.getAnimatedFraction()); 57 | } 58 | 59 | public void setInterpolator(TimeInterpolator interpolator){ 60 | mValueAnimator.setInterpolator(interpolator); 61 | } 62 | 63 | public void setStartDelay(long startDelay){ 64 | mValueAnimator.setStartDelay(startDelay); 65 | } 66 | 67 | @Override 68 | public void onAnimationStart(Animator animation) { 69 | mDataAnimationListener.onAnimationStart(animation); 70 | } 71 | 72 | @Override 73 | public void onAnimationEnd(Animator animation) { 74 | mDataAnimationListener.onAnimationFinish(); 75 | } 76 | 77 | @Override 78 | public void onAnimationCancel(Animator animation) { 79 | } 80 | 81 | @Override 82 | public void onAnimationRepeat(Animator animation) { 83 | 84 | } 85 | 86 | public void setDataAnimationListener(DataAnimationListener dataAnimationListener) { 87 | if (null != dataAnimationListener) { 88 | this.mDataAnimationListener = dataAnimationListener; 89 | } 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/DataAnimationListener.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 2 | 3 | import android.animation.Animator; 4 | 5 | /** 6 | * @author LiYanZhao 7 | * @date 16-3-19 下午5:43 8 | */ 9 | public interface DataAnimationListener { 10 | 11 | public void onAnimationUpdate(float scale); 12 | 13 | public void onAnimationFinish(); 14 | 15 | void onAnimationStart(Animator animation); 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.content.Context; 7 | import android.os.Bundle; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.util.DisplayMetrics; 10 | import android.util.Log; 11 | import android.view.View; 12 | import android.view.ViewTreeObserver; 13 | import android.view.WindowManager; 14 | import android.view.animation.AccelerateInterpolator; 15 | import android.view.animation.DecelerateInterpolator; 16 | import android.view.animation.OvershootInterpolator; 17 | import android.widget.ImageView; 18 | 19 | import com.ui.trainer.view.BezierView; 20 | import com.ui.trainer.view.FloatingActionButton; 21 | 22 | import java.util.List; 23 | import java.util.Timer; 24 | import java.util.TimerTask; 25 | 26 | import butterknife.Bind; 27 | import butterknife.ButterKnife; 28 | import butterknife.OnClick; 29 | 30 | public class MainActivity extends AppCompatActivity { 31 | 32 | int index = 1; 33 | private int screenHeight; 34 | private int screenWidth; 35 | 36 | private final int BEZIER_ENTER_DURATION = 1300; 37 | private final int BEZIER_EXIT_DURATION = 800; 38 | 39 | @OnClick({R.id.floating}) 40 | public void onClick(View view) { 41 | if(index == 1){ 42 | exit(); 43 | index ++; 44 | } 45 | 46 | } 47 | 48 | @Bind(R.id.bezier) 49 | BezierView mBezierView; 50 | 51 | @Bind(R.id.floating) 52 | FloatingActionButton mFloatingActionButton; 53 | 54 | @Bind({R.id.card0, R.id.card1, R.id.card2, R.id.card3}) 55 | List cards; 56 | 57 | @Override 58 | protected void onCreate(Bundle savedInstanceState) { 59 | super.onCreate(savedInstanceState); 60 | setContentView(R.layout.activity_main); 61 | ButterKnife.bind(this); 62 | 63 | WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); 64 | DisplayMetrics metrics = new DisplayMetrics(); 65 | wm.getDefaultDisplay().getMetrics(metrics); 66 | screenHeight = metrics.heightPixels; 67 | screenWidth = metrics.widthPixels; 68 | 69 | this.getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 70 | @Override 71 | public void onGlobalLayout() { 72 | 73 | enter(); 74 | 75 | MainActivity.this.getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(this); 76 | } 77 | }); 78 | } 79 | 80 | 81 | public void enter(){ 82 | mBezierView.switchLine(BezierView.TYPE_SECOND); 83 | Animator animator = ObjectAnimator.ofFloat(mBezierView, "baseLine", -BezierView.RANGE, mFloatingActionButton.getY() - mFloatingActionButton.getMeasuredHeight() / 2); 84 | //animator.setStartDelay(BezierView.ANIMATION_DURATION); 85 | // animator.setInterpolator(new OvershootInterpolator()); 86 | animator.setDuration(BEZIER_ENTER_DURATION); 87 | animator.start(); 88 | 89 | Animator floatingAnimaor = ObjectAnimator.ofFloat(mFloatingActionButton, "translationY", 300f, 0f); 90 | floatingAnimaor.setStartDelay(BezierView.ANIMATION_DURATION); 91 | floatingAnimaor.setDuration(BEZIER_ENTER_DURATION); 92 | floatingAnimaor.setInterpolator(new OvershootInterpolator()); 93 | floatingAnimaor.start(); 94 | floatingAnimaor.addListener(new MyAnimatorListener() { 95 | @Override 96 | public void onAnimationStart(Animator animation) { 97 | mFloatingActionButton.setVisibility(View.VISIBLE); 98 | } 99 | 100 | @Override 101 | public void onAnimationEnd(Animator animation) { 102 | mFloatingActionButton.switchState(FloatingActionButton.CIRCLE_TO_ROUND_RECT); 103 | } 104 | }); 105 | 106 | cardEnter(); 107 | } 108 | 109 | public void exit(){ 110 | mFloatingActionButton.switchState(FloatingActionButton.ROUND_RECT_TO_CIRCLE,BEZIER_EXIT_DURATION); 111 | cardExit(); 112 | 113 | mBezierView.switchLine(BezierView.TYPE_THIRD); 114 | 115 | Animator animator = ObjectAnimator.ofFloat(mBezierView, "baseLine",mBezierView.getBaseLine(),0f); 116 | animator.setStartDelay(BezierView.ANIMATION_DURATION); 117 | // animator.setInterpolator(new OvershootInterpolator()); 118 | animator.setDuration(BEZIER_EXIT_DURATION); 119 | animator.start(); 120 | 121 | new Timer().schedule(new TimerTask() { 122 | @Override 123 | public void run() { 124 | runOnUiThread(new Runnable() { 125 | @Override 126 | public void run() { 127 | mBezierView.switchLine(BezierView.TYPE_ONE); 128 | } 129 | }); 130 | 131 | } 132 | },BEZIER_EXIT_DURATION + BezierView.ANIMATION_DURATION - 110); 133 | } 134 | 135 | public void cardEnter() { 136 | int delay = 100; 137 | for (final ImageView card : cards) { 138 | Animator animator = ObjectAnimator.ofFloat(card, "translationX", screenWidth - card.getLeft(), 0f); 139 | animator.setDuration(550); 140 | animator.setStartDelay(BezierView.ANIMATION_DURATION + delay * cards.indexOf(card)); 141 | animator.start(); 142 | animator.addListener(new MyAnimatorListener(){ 143 | @Override 144 | public void onAnimationStart(Animator animation) { 145 | card.setVisibility(View.VISIBLE); 146 | } 147 | }); 148 | } 149 | } 150 | 151 | public void cardExit() { 152 | int delay = 50; 153 | for (final ImageView card : cards) { 154 | Animator animator = ObjectAnimator.ofFloat(card, "translationY", 0, - (card.getY() + card.getMeasuredHeight())); 155 | animator.setDuration(300 + 150 * cards.indexOf(card)); 156 | animator.setStartDelay(delay * cards.indexOf(card)); 157 | animator.setInterpolator(new AccelerateInterpolator()); 158 | animator.start(); 159 | } 160 | } 161 | 162 | 163 | 164 | public class MyAnimatorListener implements Animator.AnimatorListener{ 165 | 166 | @Override 167 | public void onAnimationStart(Animator animation) { 168 | 169 | } 170 | 171 | @Override 172 | public void onAnimationEnd(Animator animation) { 173 | 174 | } 175 | 176 | @Override 177 | public void onAnimationCancel(Animator animation) { 178 | 179 | } 180 | 181 | @Override 182 | public void onAnimationRepeat(Animator animation) { 183 | 184 | } 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/Point.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 2 | 3 | /** 4 | * @author LiYanZhao 5 | * @date 16-3-19 上午10:51 6 | */ 7 | public class Point { 8 | 9 | private float x; 10 | private float y; 11 | private float originX; 12 | private float originY; 13 | private float diffX; 14 | private float diffY; 15 | private char[] label; 16 | 17 | public Point() { 18 | set(0, 0); 19 | } 20 | 21 | public Point(float x, float y) { 22 | set(x, y); 23 | } 24 | 25 | public Point(Point Point) { 26 | set(Point.x, Point.y); 27 | this.label = Point.label; 28 | } 29 | 30 | public void update(float scale) { 31 | x = originX + diffX * scale; 32 | y = originY + diffY * scale; 33 | } 34 | 35 | public void finish() { 36 | set(originX + diffX, originY + diffY); 37 | } 38 | 39 | public Point set(float x, float y) { 40 | this.x = x; 41 | this.y = y; 42 | this.originX = x; 43 | this.originY = y; 44 | this.diffX = 0; 45 | this.diffY = 0; 46 | return this; 47 | } 48 | 49 | public Point setTarget(float targetX, float targetY) { 50 | set(x, y); 51 | this.diffX = targetX - originX; 52 | this.diffY = targetY - originY; 53 | return this; 54 | } 55 | 56 | public float getX() { 57 | return this.x; 58 | } 59 | 60 | public float getY() { 61 | return this.y; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/view/BezierView.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer.view; 2 | 3 | import android.animation.Animator; 4 | import android.animation.TimeInterpolator; 5 | import android.annotation.TargetApi; 6 | import android.content.Context; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.Path; 11 | import android.os.Build; 12 | import android.support.v4.view.ViewCompat; 13 | import android.util.AttributeSet; 14 | import android.util.DisplayMetrics; 15 | import android.view.View; 16 | import android.view.WindowManager; 17 | 18 | import com.ui.trainer.DataAnimation; 19 | import com.ui.trainer.DataAnimationListener; 20 | import com.ui.trainer.Point; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | /** 26 | * @author LiYanZhao 27 | * @date 16-3-19 上午10:50 28 | */ 29 | public class BezierView extends View implements DataAnimationListener { 30 | public static final int TYPE_ONE = 1; 31 | public static final int TYPE_SECOND = 2; 32 | public static final int TYPE_THIRD = 3; 33 | 34 | public List line = new ArrayList<>(); 35 | private Paint paint = new Paint(); 36 | private Path path = new Path(); 37 | private DataAnimation dataAnimation; 38 | public static final int ANIMATION_DURATION = 400; 39 | private int screenHeight; 40 | float screenWidth = 780f; 41 | public static final float RANGE = 200f; 42 | 43 | private int lineColor = Color.parseColor("#E1E8F8"); 44 | 45 | private static final float LINE_SMOOTHNESS = 0.16f; 46 | 47 | private float baseLine = 0; //横向基准线 48 | 49 | private DataAnimationListener mDataAnimationListener; 50 | 51 | 52 | public BezierView(Context context) { 53 | super(context); 54 | init(); 55 | } 56 | 57 | public BezierView(Context context, AttributeSet attrs) { 58 | super(context, attrs); 59 | init(); 60 | } 61 | 62 | public BezierView(Context context, AttributeSet attrs, int defStyleAttr) { 63 | super(context, attrs, defStyleAttr); 64 | init(); 65 | } 66 | 67 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 68 | public BezierView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 69 | super(context, attrs, defStyleAttr, defStyleRes); 70 | init(); 71 | } 72 | 73 | public void init(){ 74 | paint.setAntiAlias(true); 75 | paint.setStyle(Paint.Style.STROKE); 76 | paint.setStrokeCap(Paint.Cap.ROUND); 77 | paint.setStrokeWidth(3); 78 | paint.setColor(lineColor); 79 | 80 | dataAnimation = new DataAnimation(); 81 | dataAnimation.setDataAnimationListener(this); 82 | 83 | WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE); 84 | DisplayMetrics metrics = new DisplayMetrics(); 85 | wm.getDefaultDisplay().getMetrics(metrics); 86 | screenHeight = metrics.heightPixels; 87 | screenWidth = metrics.widthPixels; 88 | 89 | line = getLevelLine(); 90 | } 91 | 92 | @Override 93 | public void draw(Canvas canvas) { 94 | super.draw(canvas); 95 | drawBesizer(canvas); 96 | } 97 | 98 | public void drawBesizer(Canvas canvas){ 99 | float prePreviousPointX = Float.NaN; 100 | float prePreviousPointY = Float.NaN; 101 | float previousPointX = Float.NaN; 102 | float previousPointY = Float.NaN; 103 | float currentPointX = Float.NaN; 104 | float currentPointY = Float.NaN; 105 | float nextPointX = Float.NaN; 106 | float nextPointY = Float.NaN; 107 | 108 | for(int index = 0; index < line.size(); index++){ 109 | if(Float.isNaN(currentPointX)){ 110 | Point point = line.get(index); 111 | currentPointX = point.getX(); 112 | currentPointY = point.getY() + baseLine; 113 | } 114 | 115 | if(Float.isNaN(previousPointX)){ 116 | if(index > 0){ 117 | Point point = line.get(index - 1); 118 | previousPointX = point.getX(); 119 | previousPointY = point.getY() + baseLine; 120 | }else{ 121 | previousPointX = currentPointX; 122 | previousPointY = currentPointY; 123 | } 124 | } 125 | 126 | if(Float.isNaN(prePreviousPointX)){ 127 | if(index > 1){ 128 | Point point = line.get(index - 2); 129 | prePreviousPointX = point.getX(); 130 | prePreviousPointY = point.getY() + baseLine; 131 | }else{ 132 | prePreviousPointX = previousPointX; 133 | prePreviousPointY = previousPointY; 134 | } 135 | } 136 | 137 | if(index < line.size() - 1){ 138 | Point point = line.get(index + 1); 139 | nextPointX = point.getX(); 140 | nextPointY = point.getY() + baseLine; 141 | }else{ 142 | nextPointX = currentPointX; 143 | nextPointY = currentPointY; 144 | } 145 | 146 | if(index == 0){ 147 | path.moveTo(currentPointX,currentPointY); 148 | }else{ 149 | final float firstDiffX = (currentPointX - prePreviousPointX); 150 | final float firstDiffY = (currentPointY - prePreviousPointY); 151 | final float secondDiffX = (nextPointX - previousPointX); 152 | final float secondDiffY = (nextPointY - previousPointY); 153 | final float firstControlPointX = previousPointX + (LINE_SMOOTHNESS * firstDiffX); 154 | final float firstControlPointY = previousPointY + (LINE_SMOOTHNESS * firstDiffY); 155 | final float secondControlPointX = currentPointX - (LINE_SMOOTHNESS * secondDiffX); 156 | final float secondControlPointY = currentPointY - (LINE_SMOOTHNESS * secondDiffY); 157 | path.cubicTo(firstControlPointX, firstControlPointY, secondControlPointX, secondControlPointY, 158 | currentPointX, currentPointY); 159 | } 160 | 161 | prePreviousPointX = previousPointX; 162 | prePreviousPointY = previousPointY; 163 | previousPointX = currentPointX; 164 | previousPointY = currentPointY; 165 | currentPointX = nextPointX; 166 | currentPointY = nextPointY; 167 | } 168 | canvas.drawPath(path, paint); 169 | 170 | path.lineTo(line.get(line.size() - 1).getX(), screenHeight); 171 | path.lineTo(line.get(0).getX(), screenHeight); 172 | path.close(); 173 | paint.setColor(Color.WHITE); 174 | paint.setStyle(Paint.Style.FILL); 175 | //paint.setAlpha(64); 176 | canvas.drawPath(path, paint); 177 | paint.setStyle(Paint.Style.STROKE); 178 | 179 | path.reset(); 180 | } 181 | 182 | 183 | public void switchLine(int type){ 184 | switchLine(type,ANIMATION_DURATION); 185 | } 186 | 187 | /** 188 | * 切换曲线 189 | */ 190 | public void switchLine(int type,int duration){ 191 | List newLine; 192 | switch (type){ 193 | case TYPE_SECOND: 194 | newLine = getBottomLine(); 195 | break; 196 | case TYPE_THIRD: 197 | newLine = getUpLine(); 198 | break; 199 | default: 200 | newLine = getLevelLine(); 201 | break; 202 | } 203 | 204 | if(newLine.size() != line.size()){ 205 | line = newLine; 206 | ViewCompat.postInvalidateOnAnimation(this); 207 | return; 208 | } 209 | 210 | for(int i = 0; i < newLine.size(); i++){ 211 | Point point = newLine.get(i); 212 | line.get(i).setTarget(point.getX(),point.getY()); 213 | } 214 | dataAnimation.startAnimation(duration); 215 | } 216 | 217 | public void setInterpolator(TimeInterpolator interpolator){ 218 | dataAnimation.setInterpolator(interpolator); 219 | } 220 | 221 | public void setStartDelay(long startDelay){ 222 | dataAnimation.setStartDelay(startDelay); 223 | } 224 | 225 | private List getBottomLine(){ 226 | List line = new ArrayList<>(); 227 | line.add(new Point(0.0f,RANGE / 5)); 228 | line.add(new Point(screenWidth /4,0f)); 229 | line.add(new Point(screenWidth /2,RANGE / 2)); 230 | line.add(new Point(screenWidth /4*3,RANGE)); 231 | line.add(new Point(screenWidth,RANGE / 5 * 4 )); 232 | return line; 233 | } 234 | 235 | private List getUpLine(){ 236 | List line = new ArrayList<>(); 237 | line.add(new Point(0.0f,0f)); 238 | line.add(new Point(screenWidth /4,RANGE)); 239 | line.add(new Point(screenWidth /8 * 5,RANGE/3*2)); 240 | line.add(new Point(screenWidth /10*8.5f,RANGE / 10 * 9)); 241 | line.add(new Point(screenWidth,RANGE / 5 * 3)); 242 | return line; 243 | } 244 | 245 | private List getLevelLine(){ 246 | List line = new ArrayList<>(); 247 | line.add(new Point(0.0f,0f)); 248 | line.add(new Point(screenWidth /4,0f)); 249 | line.add(new Point(screenWidth /8 * 5,0f)); 250 | line.add(new Point(screenWidth /10*8.5f,0f)); 251 | line.add(new Point(screenWidth,0f)); 252 | return line; 253 | } 254 | 255 | 256 | @Override 257 | public void onAnimationUpdate(float scale) { 258 | for(Point point : line){ 259 | point.update(scale); 260 | } 261 | 262 | ViewCompat.postInvalidateOnAnimation(this); 263 | } 264 | 265 | @Override 266 | public void onAnimationFinish() { 267 | for(Point point : line){ 268 | point.finish(); 269 | } 270 | ViewCompat.postInvalidateOnAnimation(this); 271 | if(mDataAnimationListener != null){ 272 | mDataAnimationListener.onAnimationFinish(); 273 | } 274 | } 275 | 276 | @Override 277 | public void onAnimationStart(Animator animation) { 278 | if(mDataAnimationListener != null){ 279 | mDataAnimationListener.onAnimationStart(animation); 280 | } 281 | } 282 | 283 | public float getBaseLine() { 284 | return baseLine; 285 | } 286 | 287 | public void setBaseLine(float baseLine) { 288 | this.baseLine = baseLine; 289 | ViewCompat.postInvalidateOnAnimation(this); 290 | } 291 | 292 | public DataAnimationListener getDataAnimationListener() { 293 | return mDataAnimationListener; 294 | } 295 | 296 | public void setDataAnimationListener(DataAnimationListener mDataAnimationListener) { 297 | this.mDataAnimationListener = mDataAnimationListener; 298 | } 299 | } 300 | -------------------------------------------------------------------------------- /app/src/main/java/com/ui/trainer/view/FloatingActionButton.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer.view; 2 | 3 | import android.animation.Animator; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.RectF; 11 | import android.os.Build; 12 | import android.util.AttributeSet; 13 | import android.util.DisplayMetrics; 14 | import android.util.TypedValue; 15 | import android.view.View; 16 | import android.view.WindowManager; 17 | import android.view.animation.DecelerateInterpolator; 18 | 19 | import com.ui.trainer.DataAnimation; 20 | import com.ui.trainer.DataAnimationListener; 21 | import com.ui.trainer.R; 22 | 23 | /** 24 | * @author LiYanZhao 25 | * @date 16-3-21 下午4:02 26 | */ 27 | public class FloatingActionButton extends View implements DataAnimationListener { 28 | private Paint bgPaint; 29 | private Paint contentPaint; 30 | int centerX = 0; 31 | int centerY = 0; 32 | int width = 0; 33 | int height = 0; 34 | 35 | private final int DURATION = 600; 36 | 37 | 38 | public static final int CIRCLE_TO_ROUND_RECT = 0; //圆形状态切换为圆角矩形 39 | public static final int ROUND_RECT_TO_CIRCLE = 1; //圆角矩形切换为圆形 40 | 41 | private float originRadius; //原始半径 42 | private float radius; //当前半径 43 | private float roundRectWidth = 0; //长度(不含弧度半径) 44 | private float diffRadius; //弧度半径差值 45 | private float diffWidth; //长度差值 46 | private float offsetX = Float.NaN; //在圆角矩形切换圆形状态时X坐标偏移量 47 | private int marginRight = 0; 48 | 49 | private float originArrowHeight = Float.NaN; //原箭头高度 50 | private float arrowHeight = Float.NaN; //现箭头高度 51 | private float diffArrowHeight = Float.NaN; //箭头高度差 52 | private float arrowDegree = 45f; 53 | private float originDegree = 45f; //原角度 54 | private float diffDegree = 135f; //原角度 55 | 56 | // private float originUpheight = Float.NaN; //箭头 转 X 上部分原高度 57 | // private float originDownheight = Float.NaN; //箭头 转 X 下部分原高度 58 | // private float originOffsetCenter = Float.NaN;//原中心偏移量 59 | 60 | private float diffUpHeight = Float.NaN; // 箭头 转 X 上部分高度差 61 | private float diffDownHeight = Float.NaN; // 箭头 转 X 下部分高度差 62 | private float diffOffsetCenter = Float.NaN; // 箭头 转 X 中心偏移量差 63 | 64 | private float addHalfHeight = Float.NaN; // 加号半边长度 65 | 66 | private float arrowUpHeight = Float.NaN; // 箭头上部分长度 67 | private float arrowDownHeight = Float.NaN; //箭头下部分长度 68 | private float offsetCenter = Float.NaN; //中心偏移量 69 | 70 | private String text = ""; 71 | private float textWidth; 72 | private float textSize = dip2px(16); //默认字体大小 73 | 74 | private final float ARROW_RADIUS = dip2px(2); 75 | private final float ARROW_WIDTH = dip2px(2.5f); 76 | 77 | 78 | 79 | private int type = 0; 80 | 81 | private DataAnimation mDataAnimation; 82 | private int screenWidth = 0; 83 | 84 | public FloatingActionButton(Context context) { 85 | super(context); 86 | init(null); 87 | } 88 | 89 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 90 | public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 91 | super(context, attrs, defStyleAttr, defStyleRes); 92 | init(attrs); 93 | } 94 | 95 | public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) { 96 | super(context, attrs, defStyleAttr); 97 | init(attrs); 98 | } 99 | 100 | public FloatingActionButton(Context context, AttributeSet attrs) { 101 | super(context, attrs); 102 | init(attrs); 103 | } 104 | 105 | @Override 106 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 107 | setMeasuredDimension(width, height); 108 | } 109 | 110 | @SuppressWarnings("ResourceType") 111 | public void init(AttributeSet attrs){ 112 | bgPaint = new Paint(); 113 | bgPaint.setColor(getResources().getColor(R.color.jordy_blue)); 114 | bgPaint.setAntiAlias(true); 115 | 116 | contentPaint = new Paint(); 117 | contentPaint.setColor(Color.WHITE); 118 | contentPaint.setAntiAlias(true); 119 | 120 | radius = originRadius = getResources().getDimensionPixelSize(R.dimen.design_fab_size_normal) / 2; 121 | diffRadius = originRadius / 4; 122 | diffWidth = 5 * originRadius; 123 | 124 | mDataAnimation = new DataAnimation(); 125 | mDataAnimation.setDataAnimationListener(this); 126 | 127 | height = width = (int) (radius * 2); 128 | 129 | arrowHeight = originArrowHeight = radius / 3 * 2; //箭头初始长度 130 | if(Float.isNaN(arrowUpHeight)){ 131 | arrowUpHeight = arrowHeight / 3 * 2; 132 | arrowDownHeight = arrowHeight / 3; 133 | offsetCenter = arrowHeight / 3 - ARROW_WIDTH / 2; 134 | } 135 | float minArrowHeight = originArrowHeight / 2; //箭头最小长度 136 | diffArrowHeight = originArrowHeight - minArrowHeight; 137 | 138 | addHalfHeight = radius / 2; 139 | 140 | marginRight = this.getContext().getResources().getDimensionPixelOffset(R.dimen.floating_margin_right); 141 | if(attrs != null){ 142 | int[] attrsId = new int[]{android.R.attr.layout_marginRight,android.R.attr.text,android.R.attr.textSize}; 143 | TypedArray ta = this.getContext().obtainStyledAttributes(attrs,attrsId); 144 | marginRight = ta.getDimensionPixelOffset(0,marginRight); 145 | textSize = ta.getDimensionPixelSize(2, (int) textSize); 146 | text = ta.getString(1); 147 | ta.recycle(); 148 | } 149 | 150 | WindowManager wm = (WindowManager) this.getContext().getSystemService(Context.WINDOW_SERVICE); 151 | DisplayMetrics metrics = new DisplayMetrics(); 152 | wm.getDefaultDisplay().getMetrics(metrics); 153 | screenWidth = metrics.widthPixels; 154 | } 155 | 156 | @Override 157 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 158 | super.onSizeChanged(w, h, oldw, oldh); 159 | centerX = w /2; 160 | centerY = h /2; 161 | 162 | if(Float.isNaN(offsetX)){ 163 | offsetX = screenWidth - getLeft() - marginRight - originRadius * 2; 164 | } 165 | } 166 | 167 | @Override 168 | public void draw(Canvas canvas) { 169 | super.draw(canvas); 170 | 171 | //绘制背景 172 | RectF rect = new RectF(centerX - radius - roundRectWidth / 2,centerY - radius,centerX + radius + roundRectWidth / 2,centerY + radius); 173 | canvas.drawRoundRect(rect,radius,radius,bgPaint); 174 | 175 | drawText(canvas); 176 | 177 | drawIcon(canvas); 178 | } 179 | 180 | /** 181 | * 绘制箭头图标及十字图标 182 | * @param canvas 183 | */ 184 | public void drawIcon(Canvas canvas){ 185 | float arrowCenterX = centerX + roundRectWidth / 2; 186 | canvas.rotate(arrowDegree,arrowCenterX,centerY); 187 | 188 | // float arrowUpHeight = arrowHeight / 3 * 2; // 箭头上部分长度 189 | // float arrowDownHeight = arrowHeight / 3; //箭头下部分长度 190 | // float offsetCenter = arrowHeight / 3 - ARROW_WIDTH / 2; //中心偏移量 191 | 192 | RectF leftRect = new RectF(arrowCenterX - arrowUpHeight,centerY + offsetCenter - ARROW_WIDTH / 2,arrowCenterX + arrowDownHeight,centerY + offsetCenter + ARROW_WIDTH / 2); 193 | canvas.drawRoundRect(leftRect,ARROW_RADIUS,ARROW_RADIUS,contentPaint); 194 | 195 | 196 | RectF rightRect = new RectF(arrowCenterX + offsetCenter - ARROW_WIDTH / 2,centerY - arrowUpHeight,arrowCenterX + offsetCenter + ARROW_WIDTH / 2,centerY + arrowDownHeight); 197 | canvas.drawRoundRect(rightRect,ARROW_RADIUS,ARROW_RADIUS,contentPaint); 198 | 199 | canvas.restore(); 200 | } 201 | 202 | /** 203 | * 绘制文字 204 | * @param canvas 205 | */ 206 | public void drawText(Canvas canvas){ 207 | contentPaint.setTextSize(textSize); 208 | textWidth = contentPaint.measureText(text); 209 | float textLeft; 210 | if(type == CIRCLE_TO_ROUND_RECT){ 211 | textLeft = centerX - textWidth / 2 - diffWidth /2 + roundRectWidth /2; 212 | }else{ 213 | textLeft = centerX - textWidth / 2; 214 | } 215 | canvas.drawText(text,textLeft,centerY - ((contentPaint.descent() + contentPaint.ascent()) / 2),contentPaint); 216 | canvas.save(); 217 | } 218 | 219 | 220 | public void switchState(int type){ 221 | switchState(type,DURATION); 222 | } 223 | 224 | public void switchState(int type,int duration){ 225 | this.type = type; 226 | mDataAnimation.setInterpolator(new DecelerateInterpolator()); 227 | mDataAnimation.startAnimation(duration); 228 | } 229 | 230 | @Override 231 | public void onAnimationUpdate(float scale) { 232 | if(this.type == CIRCLE_TO_ROUND_RECT){ 233 | radius = originRadius - diffRadius * scale; 234 | roundRectWidth = diffWidth * scale; 235 | 236 | //计算箭头数据 237 | arrowHeight = originArrowHeight - scale * diffArrowHeight; 238 | arrowUpHeight = arrowHeight / 3 * 2; 239 | arrowDownHeight = arrowHeight / 3; 240 | offsetCenter = arrowHeight / 3 - ARROW_WIDTH / 2; 241 | }else{ 242 | textSize = (1 - scale) * textSize; 243 | 244 | radius = originRadius - (1f - scale) * diffRadius; 245 | roundRectWidth = (1f - scale) * diffWidth; 246 | setTranslationX(scale * offsetX); 247 | 248 | if(Float.isNaN(diffUpHeight)){ 249 | diffUpHeight = addHalfHeight - arrowUpHeight; 250 | diffDownHeight = addHalfHeight - arrowDownHeight; 251 | diffOffsetCenter = offsetCenter; 252 | } 253 | 254 | arrowUpHeight = addHalfHeight - (1 - scale) * diffUpHeight; 255 | arrowDownHeight = addHalfHeight - (1 - scale) * diffDownHeight; 256 | offsetCenter = (1 - scale) * diffOffsetCenter; 257 | arrowDegree = originDegree + scale * diffDegree; 258 | } 259 | 260 | width = (int) (radius * 2 + roundRectWidth); 261 | height = (int) (radius * 2); 262 | 263 | requestLayout(); //强制measure 264 | // ViewCompat.postInvalidateOnAnimation(this); 265 | } 266 | 267 | @Override 268 | public void onAnimationFinish() { 269 | 270 | } 271 | 272 | @Override 273 | public void onAnimationStart(Animator animation) { 274 | 275 | } 276 | 277 | public float dip2px(float dipValue){ 278 | DisplayMetrics metrics = this.getContext().getResources().getDisplayMetrics(); 279 | return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dipValue, metrics); 280 | } 281 | } 282 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/card0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/drawable-xhdpi/card0.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/card1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/drawable-xhdpi/card1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/card2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/drawable-xhdpi/card2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/card3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/drawable-xhdpi/card3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/real_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/drawable-xxhdpi/real_bg.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 25 | 26 | 32 | 33 | 34 | 40 | 41 | 47 | 48 | 49 | 53 | 54 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #7CBAE2 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 50dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Trainer 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/ui/trainer/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.ui.trainer; 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-alpha3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /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/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/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 | -------------------------------------------------------------------------------- /implement.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liyanzhao/Trainer/54de2dc5724565c126085a694b9fa826996cd3b7/implement.gif -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------