├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── jp │ │ └── citrous │ │ └── practicalanimation │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── jp │ │ │ └── citrous │ │ │ └── practicalanimation │ │ │ ├── AlphaAnimationSampleActivity.java │ │ │ ├── AnimatedVectorDrawableSampleActivity.java │ │ │ ├── FireworkAnimationActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MarbleAnimationActivity.java │ │ │ ├── ObjectAnimatorSampleActivity.java │ │ │ ├── PlayPauseAnimationSampleActivity.java │ │ │ ├── RotationAnimationSampleActivity.java │ │ │ ├── ScaleAnimationSampleActivity.java │ │ │ ├── TranslationAnimationSampleActivity.java │ │ │ ├── model │ │ │ ├── Photon.java │ │ │ ├── Quadrangle.java │ │ │ └── QuadrangleEvaluator.java │ │ │ └── view │ │ │ ├── FireworkView.java │ │ │ ├── MarbleView.java │ │ │ └── PlayPauseIconView.java │ └── res │ │ ├── animator │ │ └── animator.xml │ │ ├── drawable │ │ ├── animated_vector_drawable.xml │ │ └── vector_drawable.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── animated_vector_drawable.xml │ │ ├── firework.xml │ │ ├── marbles.xml │ │ ├── playpause.xml │ │ └── simple_animation.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ ├── droid2017.png │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── jp │ └── citrous │ └── practicalanimation │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea/ 5 | .gradle/ 6 | .DS_Store 7 | build/ 8 | /captures 9 | .externalNativeBuild 10 | local.properties 11 | *.apk 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Practical Animation 2 | An Android application for session of "Practical Animation" at DroidKaigi2017. 3 | 4 | ## Slide 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "jp.citrous.practicalanimation" 8 | minSdkVersion 17 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.2.0' 28 | testCompile 'junit:junit:4.12' 29 | } 30 | -------------------------------------------------------------------------------- /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 C:\Users\citrous\AppData\Local\Android\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/jp/citrous/practicalanimation/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("jp.citrous.practicalanimation", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/AlphaAnimationSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by citrous on 2017/03/03. 9 | */ 10 | public class AlphaAnimationSampleActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | 16 | setContentView(R.layout.simple_animation); 17 | 18 | findViewById(R.id.droid_icon).setOnClickListener(new View.OnClickListener() { 19 | @Override 20 | public void onClick(View v) { 21 | v.animate().alpha(0f).start(); 22 | } 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/AnimatedVectorDrawableSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.graphics.drawable.AnimatedVectorDrawableCompat; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | 10 | /** 11 | * Created by citrous on 2017/03/03. 12 | */ 13 | 14 | public class AnimatedVectorDrawableSampleActivity extends AppCompatActivity { 15 | 16 | private AnimatedVectorDrawableCompat animatable; 17 | 18 | @Override 19 | protected void onCreate(@Nullable Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | 22 | setContentView(R.layout.animated_vector_drawable); 23 | animatable = AnimatedVectorDrawableCompat.create(this, R.drawable.animated_vector_drawable); 24 | ImageView imageView = (ImageView) findViewById(R.id.imageView); 25 | imageView.setImageDrawable(animatable); 26 | imageView.setOnClickListener(new View.OnClickListener() { 27 | @Override 28 | public void onClick(View v) { 29 | animatable.start(); 30 | } 31 | }); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/FireworkAnimationActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import jp.citrous.practicalanimation.view.FireworkView; 8 | 9 | /** 10 | * Created by citrous on 2017/03/04. 11 | */ 12 | 13 | public class FireworkAnimationActivity extends AppCompatActivity { 14 | 15 | private FireworkView animatorView; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | 21 | setContentView(R.layout.firework); 22 | 23 | animatorView = (FireworkView) findViewById(R.id.animatorView); 24 | 25 | animatorView.setOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View v) { 28 | animatorView.startCustomAnimation(); 29 | } 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/MainActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.LinearLayout; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | private static Class activities[] = { 13 | TranslationAnimationSampleActivity.class, 14 | ScaleAnimationSampleActivity.class, 15 | RotationAnimationSampleActivity.class, 16 | AlphaAnimationSampleActivity.class, 17 | AnimatedVectorDrawableSampleActivity.class, 18 | ObjectAnimatorSampleActivity.class, 19 | FireworkAnimationActivity.class, 20 | MarbleAnimationActivity.class, 21 | PlayPauseAnimationSampleActivity.class 22 | }; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | 28 | setContentView(R.layout.activity_main); 29 | 30 | LinearLayout layoutParent = (LinearLayout) findViewById(R.id.activity_main); 31 | for (Class activity : activities) { 32 | layoutParent.addView(createActivityButton(activity)); 33 | } 34 | } 35 | 36 | private Button createActivityButton(final Class cls) { 37 | Button button = new Button(this); 38 | button.setAllCaps(false); 39 | button.setText(cls.getSimpleName()); 40 | button.setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | startActivity(new Intent(MainActivity.this, cls)); 44 | } 45 | }); 46 | return button; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/MarbleAnimationActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import jp.citrous.practicalanimation.view.MarbleView; 8 | 9 | /** 10 | * Created by citrous on 2017/03/05. 11 | */ 12 | 13 | public class MarbleAnimationActivity extends AppCompatActivity { 14 | 15 | private MarbleView animatorView; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | 21 | setContentView(R.layout.marbles); 22 | 23 | animatorView = (MarbleView) findViewById(R.id.animatorView); 24 | 25 | animatorView.setOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View v) { 28 | animatorView.startCustomAnimation(); 29 | } 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/ObjectAnimatorSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.animation.AnimatorInflater; 4 | import android.animation.AnimatorSet; 5 | import android.os.Bundle; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.View; 8 | 9 | /** 10 | * Created by citrous on 2017/03/04. 11 | */ 12 | 13 | public class ObjectAnimatorSampleActivity extends AppCompatActivity { 14 | 15 | private AnimatorSet animator; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | 21 | setContentView(R.layout.simple_animation); 22 | 23 | View view = findViewById(R.id.droid_icon); 24 | animator = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animator); 25 | animator.setTarget(view); 26 | 27 | view.setOnClickListener(new View.OnClickListener() { 28 | @Override 29 | public void onClick(View v) { 30 | animator.start(); 31 | } 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/PlayPauseAnimationSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | import jp.citrous.practicalanimation.view.PlayPauseIconView; 8 | 9 | /** 10 | * Created by citrous on 2017/03/13. 11 | */ 12 | 13 | public class PlayPauseAnimationSampleActivity extends AppCompatActivity { 14 | 15 | private PlayPauseIconView animatorView; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | 21 | setContentView(R.layout.playpause); 22 | 23 | animatorView = (PlayPauseIconView) findViewById(R.id.animatorView); 24 | 25 | animatorView.setOnClickListener(new View.OnClickListener() { 26 | @Override 27 | public void onClick(View v) { 28 | animatorView.startCustomAnimation(); 29 | } 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/RotationAnimationSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by citrous on 2017/03/03. 9 | */ 10 | 11 | public class RotationAnimationSampleActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | 17 | setContentView(R.layout.simple_animation); 18 | 19 | findViewById(R.id.droid_icon).setOnClickListener(new View.OnClickListener() { 20 | @Override 21 | public void onClick(View v) { 22 | v.animate().rotation(180f).start(); 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/ScaleAnimationSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by citrous on 2017/03/03. 9 | */ 10 | 11 | public class ScaleAnimationSampleActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | 17 | setContentView(R.layout.simple_animation); 18 | 19 | findViewById(R.id.droid_icon).setOnClickListener(new View.OnClickListener() { 20 | @Override 21 | public void onClick(View v) { 22 | v.animate().scaleX(2.0f).scaleY(2.0f).start(); 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/TranslationAnimationSampleActivity.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.view.View; 6 | 7 | /** 8 | * Created by citrous on 2017/03/03. 9 | */ 10 | 11 | public class TranslationAnimationSampleActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | 17 | setContentView(R.layout.simple_animation); 18 | 19 | findViewById(R.id.droid_icon).setOnClickListener(new View.OnClickListener() { 20 | @Override 21 | public void onClick(View v) { 22 | v.animate().translationX(128).translationY(128).start(); 23 | } 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/model/Photon.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.model; 2 | 3 | import android.graphics.Paint; 4 | 5 | /** 6 | * Created by citrous on 2017/03/05. 7 | */ 8 | 9 | public class Photon { 10 | 11 | private float[] xParams; 12 | private float[] yParams; 13 | private float radius; 14 | private Paint paint; 15 | 16 | public Photon(float[] xParams, float[] yParams, float radius, Paint paint) { 17 | this.xParams = xParams; 18 | this.yParams = yParams; 19 | this.radius = radius; 20 | this.paint = paint; 21 | } 22 | 23 | public float[] getXParams() { 24 | return xParams; 25 | } 26 | 27 | public void setXParams(float[] xParams) { 28 | this.xParams = xParams; 29 | } 30 | 31 | public float[] getYParams() { 32 | return yParams; 33 | } 34 | 35 | public void setYParams(float[] yParams) { 36 | this.yParams = yParams; 37 | } 38 | 39 | public float getRadius() { 40 | return radius; 41 | } 42 | 43 | public void setRadius(float radius) { 44 | this.radius = radius; 45 | } 46 | 47 | public Paint getPaint() { 48 | return paint; 49 | } 50 | 51 | public void setPaint(Paint paint) { 52 | this.paint = paint; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/model/Quadrangle.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.model; 2 | 3 | import android.graphics.Point; 4 | 5 | /** 6 | * Created by citrous on 2017/03/13. 7 | */ 8 | 9 | public class Quadrangle { 10 | 11 | private Point point1; 12 | private Point point2; 13 | private Point point3; 14 | private Point point4; 15 | 16 | public Quadrangle(Point point1, Point point2, Point point3, Point point4) { 17 | this.point1 = point1; 18 | this.point2 = point2; 19 | this.point3 = point3; 20 | this.point4 = point4; 21 | } 22 | 23 | public Point getPoint1() { 24 | return point1; 25 | } 26 | 27 | public Point getPoint2() { 28 | return point2; 29 | } 30 | 31 | public Point getPoint3() { 32 | return point3; 33 | } 34 | 35 | public Point getPoint4() { 36 | return point4; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/model/QuadrangleEvaluator.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.model; 2 | 3 | import android.animation.TypeEvaluator; 4 | import android.graphics.Point; 5 | 6 | /** 7 | * Created by citrous on 2017/03/10. 8 | */ 9 | 10 | public class QuadrangleEvaluator implements TypeEvaluator { 11 | 12 | @Override 13 | public Quadrangle evaluate(float fraction, Quadrangle startValue, Quadrangle endValue) { 14 | 15 | Point point1 = evaluatePoint(fraction, startValue.getPoint1(), endValue.getPoint1()); 16 | Point point2 = evaluatePoint(fraction, startValue.getPoint2(), endValue.getPoint2()); 17 | Point point3 = evaluatePoint(fraction, startValue.getPoint3(), endValue.getPoint3()); 18 | Point point4 = evaluatePoint(fraction, startValue.getPoint4(), endValue.getPoint4()); 19 | 20 | return new Quadrangle(point1, point2, point3, point4); 21 | } 22 | 23 | private Point evaluatePoint(float fraction, Point startPoint, Point endPoint) { 24 | return new Point( 25 | (int) (startPoint.x + fraction * (endPoint.x - startPoint.x)), 26 | (int) (startPoint.y + fraction * (endPoint.y - startPoint.y)) 27 | ); 28 | } 29 | } 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/view/FireworkView.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.view; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.os.Build; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.view.animation.AccelerateDecelerateInterpolator; 12 | 13 | import java.util.Random; 14 | 15 | import jp.citrous.practicalanimation.R; 16 | import jp.citrous.practicalanimation.model.Photon; 17 | 18 | /** 19 | * Created by citrous on 2017/03/04. 20 | */ 21 | 22 | public class FireworkView extends View { 23 | 24 | private static final int ANIMATION_DURATION = 1000; 25 | 26 | private Photon[] photons = new Photon[50]; 27 | private float photonRadius; 28 | private int xParam; 29 | private int yParam1; 30 | private int yParam2; 31 | 32 | private ValueAnimator animator = createAnimator(); 33 | 34 | public FireworkView(Context context) { 35 | super(context); 36 | initParams(); 37 | } 38 | 39 | public FireworkView(Context context, AttributeSet attrs) { 40 | super(context, attrs); 41 | initParams(); 42 | } 43 | 44 | public FireworkView(Context context, AttributeSet attrs, int defStyleAttr) { 45 | super(context, attrs, defStyleAttr); 46 | initParams(); 47 | } 48 | 49 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 50 | public FireworkView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 51 | super(context, attrs, defStyleAttr, defStyleRes); 52 | initParams(); 53 | } 54 | 55 | private void initParams() { 56 | photonRadius = getContext().getResources().getDimensionPixelSize(R.dimen.firework_photon_radius); 57 | xParam = getContext().getResources().getDimensionPixelSize(R.dimen.firework_photon_x_param); 58 | yParam1 = getContext().getResources().getDimensionPixelSize(R.dimen.firework_photon_y_param1); 59 | yParam2 = getContext().getResources().getDimensionPixelSize(R.dimen.firework_photon_y_param2); 60 | } 61 | 62 | private ValueAnimator createAnimator() { 63 | ValueAnimator animator = new ValueAnimator(); 64 | animator.setFloatValues(100f); 65 | animator.setDuration(ANIMATION_DURATION); 66 | animator.setInterpolator(new AccelerateDecelerateInterpolator()); 67 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 68 | @Override 69 | public void onAnimationUpdate(ValueAnimator animation) { 70 | invalidate(); 71 | } 72 | }); 73 | return animator; 74 | } 75 | 76 | public void startCustomAnimation() { 77 | for (int i = 0; i < photons.length; i++) { 78 | photons[i] = createPhoton(); 79 | } 80 | animator.start(); 81 | } 82 | 83 | private Photon createPhoton() { 84 | Random random = new Random(); 85 | Paint paint = new Paint(); 86 | paint.setARGB(255, random.nextInt(255), random.nextInt(255), random.nextInt(255)); 87 | return new Photon( 88 | new float[] {random.nextInt(xParam * 2) - xParam}, 89 | new float[] {random.nextInt(yParam1) / 10f, random.nextInt(yParam2) + (yParam2 / 3)}, 90 | photonRadius, 91 | paint 92 | ); 93 | } 94 | 95 | @Override 96 | protected void onDraw(Canvas canvas) { 97 | super.onDraw(canvas); 98 | 99 | if (animator.isRunning()) { 100 | float value = (float) animator.getAnimatedValue(""); 101 | drawPhotons(canvas, value); 102 | } 103 | } 104 | 105 | private void drawPhotons(Canvas canvas, float value) { 106 | for (Photon photon : photons) { 107 | canvas.drawCircle(calcX(photon, value), 108 | calcY(photon, value), 109 | photon.getRadius(), 110 | photon.getPaint()); 111 | } 112 | } 113 | 114 | private float calcX(Photon photon, float value) { 115 | return value / 100 * photon.getXParams()[0] + centerOfX(); 116 | } 117 | 118 | private float calcY(Photon photon, float value) { 119 | float[] params = photon.getYParams(); 120 | float x = value / 100; 121 | return (params[0] * x * params[0] * x) - 2 * params[0] * params[1] * x + centerOfY(); 122 | } 123 | 124 | private int centerOfX() { 125 | return getWidth() / 2; 126 | } 127 | 128 | private int centerOfY() { 129 | return getHeight() / 2; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/view/MarbleView.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.view; 2 | 3 | import android.animation.Animator; 4 | import android.animation.PropertyValuesHolder; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.content.Context; 8 | import android.graphics.Canvas; 9 | import android.graphics.Paint; 10 | import android.os.Build; 11 | import android.util.AttributeSet; 12 | import android.view.View; 13 | import android.view.animation.DecelerateInterpolator; 14 | 15 | import java.util.Random; 16 | 17 | import jp.citrous.practicalanimation.R; 18 | 19 | /** 20 | * Created by citrous on 2017/03/05. 21 | */ 22 | 23 | public class MarbleView extends View { 24 | 25 | private static final int CIRCLE_COUNT = 20; 26 | private static final int MAX_DURATION = 1000; 27 | 28 | private static final String VELOCITY_X = "velocityX"; 29 | private static final String VELOCITY_Y = "velocityY"; 30 | private static final String PROGRESS = "progress"; 31 | 32 | private ValueAnimator[] animators = new ValueAnimator[CIRCLE_COUNT]; 33 | private Paint[] paints = new Paint[CIRCLE_COUNT]; 34 | private boolean isRunning = false; 35 | 36 | private int maxDistance; 37 | private float circleRadius; 38 | 39 | public MarbleView(Context context) { 40 | super(context); 41 | initParams(); 42 | } 43 | 44 | public MarbleView(Context context, AttributeSet attrs) { 45 | super(context, attrs); 46 | initParams(); 47 | } 48 | 49 | public MarbleView(Context context, AttributeSet attrs, int defStyleAttr) { 50 | super(context, attrs, defStyleAttr); 51 | initParams(); 52 | } 53 | 54 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 55 | public MarbleView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 56 | super(context, attrs, defStyleAttr, defStyleRes); 57 | initParams(); 58 | } 59 | 60 | private void initParams() { 61 | maxDistance = getContext().getResources().getDimensionPixelSize(R.dimen.marble_max_distance); 62 | circleRadius = getContext().getResources().getDimensionPixelSize(R.dimen.marble_max_circle_radius); 63 | } 64 | 65 | private ValueAnimator createAnimator() { 66 | Random random = new Random(); 67 | ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder( 68 | PropertyValuesHolder.ofFloat(VELOCITY_X, (random.nextFloat() - 0.5f) * 2), 69 | PropertyValuesHolder.ofFloat(VELOCITY_Y, (random.nextFloat() - 0.5f) * 2), 70 | PropertyValuesHolder.ofFloat(PROGRESS, 1.0f)); 71 | animator.setDuration(random.nextInt(MAX_DURATION / 2) + MAX_DURATION / 2); 72 | animator.setInterpolator(new DecelerateInterpolator()); 73 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 74 | @Override 75 | public void onAnimationUpdate(ValueAnimator animation) { 76 | invalidate(); 77 | } 78 | }); 79 | return animator; 80 | } 81 | 82 | private Paint createPaint() { 83 | Random random = new Random(); 84 | Paint paint = new Paint(); 85 | paint.setARGB(255, random.nextInt(255), random.nextInt(255), random.nextInt(255)); 86 | return paint; 87 | } 88 | 89 | private void createAndStart(final int index) { 90 | paints[index] = createPaint(); 91 | animators[index] = createAnimator(); 92 | animators[index].addListener(new Animator.AnimatorListener() { 93 | @Override 94 | public void onAnimationStart(Animator animation) { 95 | } 96 | 97 | @Override 98 | public void onAnimationEnd(Animator animation) { 99 | createAndStart(index); 100 | } 101 | 102 | @Override 103 | public void onAnimationCancel(Animator animation) { 104 | } 105 | 106 | @Override 107 | public void onAnimationRepeat(Animator animation) { 108 | } 109 | }); 110 | animators[index].start(); 111 | } 112 | 113 | public void startCustomAnimation() { 114 | if (isRunning) return; 115 | 116 | isRunning = true; 117 | for (int i = 0; i < animators.length; i++) { 118 | createAndStart(i); 119 | } 120 | } 121 | 122 | @Override 123 | protected void onDraw(Canvas canvas) { 124 | super.onDraw(canvas); 125 | 126 | if (isRunning) { 127 | drawPhotons(canvas); 128 | } 129 | } 130 | 131 | private void drawPhotons(Canvas canvas) { 132 | for (int i = 0; i < animators.length; i++) { 133 | float velocityX = (float) animators[i].getAnimatedValue(VELOCITY_X); 134 | float velocityY = (float) animators[i].getAnimatedValue(VELOCITY_Y); 135 | float progress = (float) animators[i].getAnimatedValue(PROGRESS); 136 | paints[i].setAlpha(255 - (int) (255 * progress)); 137 | canvas.drawCircle(maxDistance * velocityX + centerOfX(), 138 | maxDistance * velocityY + centerOfY(), 139 | circleRadius * progress, 140 | paints[i]); 141 | } 142 | } 143 | 144 | private int centerOfX() { 145 | return getWidth() / 2; 146 | } 147 | 148 | private int centerOfY() { 149 | return getHeight() / 2; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /app/src/main/java/jp/citrous/practicalanimation/view/PlayPauseIconView.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation.view; 2 | 3 | import android.animation.ValueAnimator; 4 | import android.annotation.TargetApi; 5 | import android.content.Context; 6 | import android.content.res.Resources; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.Path; 11 | import android.graphics.Point; 12 | import android.os.Build; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | import android.view.animation.AccelerateDecelerateInterpolator; 16 | 17 | import jp.citrous.practicalanimation.R; 18 | import jp.citrous.practicalanimation.model.Quadrangle; 19 | import jp.citrous.practicalanimation.model.QuadrangleEvaluator; 20 | 21 | /** 22 | * Created by citrous on 2017/03/13. 23 | */ 24 | 25 | public class PlayPauseIconView extends View { 26 | 27 | private static final int ANIMATION_DURATION = 1000; 28 | private Quadrangle startQuadrangle1; 29 | private Quadrangle endQuadrangle1; 30 | private Quadrangle currentQuadrangle1; 31 | private ValueAnimator animator1; 32 | private ValueAnimator animator2; 33 | private Quadrangle startQuadrangle2; 34 | private Quadrangle endQuadrangle2; 35 | private Quadrangle currentQuadrangle2; 36 | private Path path1 = new Path(); 37 | private Path path2 = new Path(); 38 | private Paint pathPaint; 39 | 40 | public PlayPauseIconView(Context context) { 41 | super(context); 42 | initParams(); 43 | } 44 | 45 | public PlayPauseIconView(Context context, AttributeSet attrs) { 46 | super(context, attrs); 47 | initParams(); 48 | } 49 | 50 | public PlayPauseIconView(Context context, AttributeSet attrs, int defStyleAttr) { 51 | super(context, attrs, defStyleAttr); 52 | initParams(); 53 | } 54 | 55 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 56 | public PlayPauseIconView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 57 | super(context, attrs, defStyleAttr, defStyleRes); 58 | initParams(); 59 | } 60 | 61 | private void initParams() { 62 | setupQuadrangle1(); 63 | setupQuadrangle2(); 64 | animator1 = createAnimator(startQuadrangle1, endQuadrangle1); 65 | animator2 = createAnimator(startQuadrangle2, endQuadrangle2); 66 | pathPaint = new Paint(); 67 | pathPaint.setColor(Color.WHITE); 68 | pathPaint.setStyle(Paint.Style.FILL); 69 | } 70 | 71 | private void setupQuadrangle1() { 72 | Resources res = getResources(); 73 | int startIconLeft = res.getDimensionPixelSize(R.dimen.start_icon1_left); 74 | int startIconTop = res.getDimensionPixelSize(R.dimen.start_icon1_top); 75 | int startIconRight = res.getDimensionPixelSize(R.dimen.start_icon1_right); 76 | int startIconBottom = res.getDimensionPixelSize(R.dimen.start_icon1_bottom); 77 | int pauseIconLeft = res.getDimensionPixelSize(R.dimen.pause_icon1_left); 78 | int pauseIconTop = res.getDimensionPixelSize(R.dimen.pause_icon1_top); 79 | int pauseIconRight = res.getDimensionPixelSize(R.dimen.pause_icon1_right); 80 | int pauseIconBottom = res.getDimensionPixelSize(R.dimen.pause_icon1_bottom); 81 | 82 | startQuadrangle1 = new Quadrangle( 83 | new Point(startIconLeft, startIconTop), 84 | new Point(startIconRight, (int) (startIconTop + (startIconBottom - startIconTop) * 0.25)), 85 | new Point(startIconRight, (int) (startIconTop + (startIconBottom - startIconTop) * 0.75)), 86 | new Point(startIconLeft, startIconBottom) 87 | ); 88 | endQuadrangle1 = new Quadrangle( 89 | new Point(pauseIconLeft, pauseIconTop), 90 | new Point(pauseIconRight, pauseIconTop), 91 | new Point(pauseIconRight, pauseIconBottom), 92 | new Point(pauseIconLeft, pauseIconBottom) 93 | ); 94 | currentQuadrangle1 = startQuadrangle1; 95 | } 96 | 97 | private void setupQuadrangle2() { 98 | Resources res = getResources(); 99 | int startIconLeft = res.getDimensionPixelSize(R.dimen.start_icon2_left); 100 | int startIconTop = res.getDimensionPixelSize(R.dimen.start_icon2_top); 101 | int startIconRight = res.getDimensionPixelSize(R.dimen.start_icon2_right); 102 | int startIconBottom = res.getDimensionPixelSize(R.dimen.start_icon2_bottom); 103 | int pauseIcon1Left = res.getDimensionPixelSize(R.dimen.pause_icon2_left); 104 | int pauseIcon1Top = res.getDimensionPixelSize(R.dimen.pause_icon2_top); 105 | int pauseIcon1Right = res.getDimensionPixelSize(R.dimen.pause_icon2_right); 106 | int pauseIcon1Bottom = res.getDimensionPixelSize(R.dimen.pause_icon2_bottom); 107 | 108 | startQuadrangle2 = new Quadrangle( 109 | new Point(startIconLeft, startIconTop), 110 | new Point(startIconRight, (startIconBottom + startIconTop) / 2), 111 | new Point(startIconRight, (startIconBottom + startIconTop) / 2), 112 | new Point(startIconLeft, startIconBottom) 113 | ); 114 | endQuadrangle2 = new Quadrangle( 115 | new Point(pauseIcon1Left, pauseIcon1Top), 116 | new Point(pauseIcon1Right, pauseIcon1Top), 117 | new Point(pauseIcon1Right, pauseIcon1Bottom), 118 | new Point(pauseIcon1Left, pauseIcon1Bottom) 119 | ); 120 | currentQuadrangle2 = startQuadrangle2; 121 | } 122 | 123 | private ValueAnimator createAnimator(Quadrangle startValue, Quadrangle endValue) { 124 | ValueAnimator animator = ValueAnimator.ofObject(new QuadrangleEvaluator(), startValue, endValue); 125 | animator.setDuration(ANIMATION_DURATION); 126 | animator.setInterpolator(new AccelerateDecelerateInterpolator()); 127 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 128 | @Override 129 | public void onAnimationUpdate(ValueAnimator animation) { 130 | invalidate(); 131 | } 132 | }); 133 | return animator; 134 | } 135 | 136 | public void startCustomAnimation() { 137 | animator1.start(); 138 | animator2.start(); 139 | } 140 | 141 | @Override 142 | protected void onDraw(Canvas canvas) { 143 | super.onDraw(canvas); 144 | 145 | if (animator1.isRunning()) { 146 | currentQuadrangle1 = (Quadrangle) animator1.getAnimatedValue(); 147 | currentQuadrangle2 = (Quadrangle) animator2.getAnimatedValue(); 148 | } 149 | 150 | path1.reset(); 151 | path1.moveTo(currentQuadrangle1.getPoint1().x, currentQuadrangle1.getPoint1().y); 152 | path1.lineTo(currentQuadrangle1.getPoint2().x, currentQuadrangle1.getPoint2().y); 153 | path1.lineTo(currentQuadrangle1.getPoint3().x, currentQuadrangle1.getPoint3().y); 154 | path1.lineTo(currentQuadrangle1.getPoint4().x, currentQuadrangle1.getPoint4().y); 155 | canvas.drawPath(path1, pathPaint); 156 | 157 | path2.reset(); 158 | path2.moveTo(currentQuadrangle2.getPoint1().x, currentQuadrangle2.getPoint1().y); 159 | path2.lineTo(currentQuadrangle2.getPoint2().x, currentQuadrangle2.getPoint2().y); 160 | path2.lineTo(currentQuadrangle2.getPoint3().x, currentQuadrangle2.getPoint3().y); 161 | path2.lineTo(currentQuadrangle2.getPoint4().x, currentQuadrangle2.getPoint4().y); 162 | canvas.drawPath(path2, pathPaint); 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /app/src/main/res/animator/animator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 13 | 18 | 23 | 28 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/animated_vector_drawable.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 16 | 24 | 33 | 42 | 51 | 60 | 69 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 92 | 100 | 101 | 102 | 103 | 104 | 105 | 114 | 115 | 116 | 117 | 118 | 127 | 128 | 129 | 130 | 131 | 140 | 141 | 142 | 143 | 144 | 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/vector_drawable.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 16 | 20 | 25 | 30 | 34 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/animated_vector_drawable.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/firework.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/marbles.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/playpause.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/simple_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/droid2017.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/app/src/main/res/mipmap-xxxhdpi/droid2017.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/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 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | 2dp 7 | 50dp 8 | 60dp 9 | 3dp 10 | 11 | 50dp 12 | 5dp 13 | 14 | 37.5dp 15 | 25dp 16 | 75dp 17 | 55dp 18 | 55dp 19 | 37.5dp 20 | 62.5dp 21 | 72.5dp 22 | 23 | 37.5dp 24 | 25dp 25 | 47.5dp 26 | 75dp 27 | 55dp 28 | 25dp 29 | 65dp 30 | 75dp 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PracticalAnimation 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/jp/citrous/practicalanimation/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package jp.citrous.practicalanimation; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /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.2.3' 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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/citrous/practicalanimation/f66895263f0d8852e5889bc02c06b40d180fb871/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.14.1-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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------