├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable
│ │ │ │ ├── fingle.png
│ │ │ │ ├── heart.png
│ │ │ │ └── loading.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── fragment_animation.xml
│ │ │ │ ├── content_main.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── havrylyuk
│ │ │ │ └── dynamicanimationexample
│ │ │ │ ├── animation
│ │ │ │ ├── AnimationType.java
│ │ │ │ ├── SpringAnimationUtil.java
│ │ │ │ ├── PositionSpringAnimation.java
│ │ │ │ ├── ScaleSpringAnimation.java
│ │ │ │ └── RotationSpringAnimation.java
│ │ │ │ ├── adapter
│ │ │ │ └── AnimationPagerAdapter.java
│ │ │ │ ├── fragment
│ │ │ │ └── AnimationFragment.java
│ │ │ │ └── MainActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── havrylyuk
│ │ │ └── dynamicanimationexample
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── havrylyuk
│ │ └── dynamicanimationexample
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── media
└── example.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/media/example.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/media/example.gif
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fingle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/drawable/fingle.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/heart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/drawable/heart.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/drawable/loading.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graviton57/DynamicAnimationExample/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Dynamic Animation Example
3 | About
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 | 128dp
4 | 36dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 26 21:03:34 EEST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/animation/AnimationType.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.animation;
2 |
3 | /**
4 | * Created by Igor Havrylyuk on 26.03.2017.
5 | */
6 |
7 | public enum AnimationType {
8 |
9 | POSITION("Position"),
10 | ROTATION("Rotation"),
11 | SCALE("Scale");
12 |
13 | private String name;
14 |
15 | AnimationType(String name) {
16 | this.name = name;
17 | }
18 |
19 | public String getName() {
20 | return name;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/test/java/com/havrylyuk/dynamicanimationexample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample;
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 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/havrylyuk/dynamicanimationexample/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample;
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("com.havrylyuk.dynamicanimationexample", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/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 D:\Android\AndroidStudio\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
20 |
21 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/animation/SpringAnimationUtil.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.animation;
2 |
3 | import android.support.animation.DynamicAnimation;
4 | import android.support.animation.SpringAnimation;
5 | import android.support.animation.SpringForce;
6 | import android.view.View;
7 |
8 | /**
9 | * Created by Igor Havrylyuk on 26.03.2017.
10 | */
11 |
12 | public class SpringAnimationUtil {
13 |
14 | public static SpringAnimation createSpringAnimation(View view,
15 | DynamicAnimation.ViewProperty property,
16 | float finalPosition,
17 | float stiffness,
18 | float dampingRatio) {
19 | SpringAnimation animation = new SpringAnimation(view, property);
20 | SpringForce springForce = new SpringForce(finalPosition);
21 | springForce.setStiffness(stiffness);
22 | springForce.setDampingRatio(dampingRatio);
23 | animation.setSpring(springForce);
24 | return animation;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.compileSdkVersion
5 | buildToolsVersion rootProject.buildToolsVersion
6 | defaultConfig {
7 | applicationId "com.havrylyuk.dynamicanimationexample"
8 | minSdkVersion rootProject.minSdkVersion
9 | targetSdkVersion rootProject.targetSdkVersion
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:$rootProject.espressoVersion", {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
28 | compile "com.android.support:support-dynamic-animation:$rootProject.supportLibraryVersion"
29 | compile "com.android.support:design:$rootProject.supportLibraryVersion"
30 |
31 | testCompile "junit:junit:$rootProject.junitVersion"
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/adapter/AnimationPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.adapter;
2 |
3 |
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentStatePagerAdapter;
7 |
8 | import com.havrylyuk.dynamicanimationexample.fragment.AnimationFragment;
9 | import com.havrylyuk.dynamicanimationexample.animation.AnimationType;
10 |
11 | import java.util.List;
12 |
13 |
14 | /**
15 | *
16 | * Created by Igor Havrylyuk on 26.03.2017.
17 | */
18 |
19 | public class AnimationPagerAdapter extends FragmentStatePagerAdapter {
20 |
21 | private List typeList;
22 |
23 | public AnimationPagerAdapter(FragmentManager fm, List animations) {
24 | super(fm);
25 | this.typeList = animations;
26 | }
27 |
28 | public void addItem(AnimationType item) {
29 | typeList.add(item);
30 | notifyDataSetChanged();
31 | }
32 |
33 | public void addItems(List data) {
34 | typeList.addAll(data);
35 | notifyDataSetChanged();
36 | }
37 |
38 | @Override
39 | public CharSequence getPageTitle(int position) {
40 | return typeList.get(position).getName();
41 | }
42 |
43 | @Override
44 | public Fragment getItem(int position) {
45 | return AnimationFragment.getInstance(typeList.get(position).ordinal());
46 | }
47 |
48 | @Override
49 | public int getCount() {
50 | return typeList != null ? typeList.size() : 0;
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/animation/PositionSpringAnimation.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.animation;
2 |
3 | import android.support.animation.SpringAnimation;
4 | import android.support.animation.SpringForce;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.view.ViewTreeObserver;
8 |
9 | import static com.havrylyuk.dynamicanimationexample.animation.SpringAnimationUtil.createSpringAnimation;
10 |
11 | /**
12 | * Simple class showcase position spring animation
13 | * Created by Igor Havrylyuk on 27.03.2017.
14 | */
15 |
16 | public class PositionSpringAnimation {
17 |
18 | private View animatedView;
19 |
20 | private SpringAnimation xAnimation;
21 | private SpringAnimation yAnimation;
22 |
23 | private float dX;
24 | private float dY;
25 |
26 | public PositionSpringAnimation(final View animatedView) {
27 | if (animatedView != null) {
28 | this.animatedView = animatedView;
29 | animatedView.getViewTreeObserver().addOnGlobalLayoutListener(globalLayoutListener);
30 | this.animatedView.setOnTouchListener(touchListener);
31 | }
32 | }
33 |
34 | // create X and Y animations for view's initial position once it's known
35 | private ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
36 | @Override
37 | public void onGlobalLayout() {
38 | xAnimation = createSpringAnimation(animatedView, SpringAnimation.X, animatedView.getX(),
39 | SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
40 | yAnimation = createSpringAnimation(animatedView, SpringAnimation.Y, animatedView.getY(),
41 | SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
42 | }
43 | };
44 |
45 | private View.OnTouchListener touchListener = new View.OnTouchListener() {
46 | @Override
47 | public boolean onTouch(View v, MotionEvent event) {
48 | switch (event.getActionMasked()){
49 | case MotionEvent.ACTION_DOWN:
50 | // capture the difference between view's top left corner and touch point
51 | dX = v.getX() - event.getRawX();
52 | dY = v.getY() - event.getRawY();
53 | // cancel animations
54 | xAnimation.cancel();
55 | yAnimation.cancel();
56 | break;
57 | case MotionEvent.ACTION_MOVE:
58 | // a different approach would be to change the view's LayoutParams.
59 | animatedView.animate()
60 | .x(event.getRawX() + dX)
61 | .y(event.getRawY() + dY)
62 | .setDuration(0)
63 | .start();
64 | break;
65 | case MotionEvent.ACTION_UP:
66 | xAnimation.start();
67 | yAnimation.start();
68 | break;
69 | }
70 | return true;
71 | }
72 | };
73 | }
74 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Dynamic Animation Example
2 |
3 | [](https://android-arsenal.com/details/3/5635)
4 | [](https://www.apache.org/licenses/LICENSE-2.0)
5 | [](https://android-arsenal.com/api?level=16)
6 |
7 | ###
8 | [Dynamic-animation](https://developer.android.com/reference/android/support/animation/package-summary.html) is a new module introduced in [revision 25.3.0 of the Android Support Library](https://developer.android.com/topic/libraries/support-library/revisions.html#25-3-0). It provides a small set of classes for making realistic physics-based view animations.
9 |
10 |
11 | ### Setup
12 | To get started, add the following dependency to your module’s build.gradle:
13 |
14 | ```gradle
15 | dependencies {
16 | compile 'com.android.support:support-dynamic-animation:25.3.0'
17 | }
18 | ```
19 | **support-dynamic-animation:25.3.0** new physics-based animation library that provides a set of APIs for building animations that dynamically react to user input
20 |
21 | ### Making a SpringAnimation
22 | Well, it won’t really be generic in a programming sense, but let’s start with how every SpringAnimation is made.
23 |
24 | 1. Create a SpringAnimation object for your View with a specified ViewProperty
25 | 2. Create a SpringForce object and set your desired parameters (which are described above).
26 | 3. Apply the created SpringForce to your SpringAnimation.
27 | 4. Start the animation.
28 |
29 | ```java
30 | private void startSpringAnimation(View view){
31 | // create an animation for your view and set the property you want to animate
32 | SpringAnimation animation = new SpringAnimation(view, SpringAnimation.X);
33 | // create a spring with desired parameters
34 | SpringForce spring = new SpringForce();
35 | // can also be passed directly in the constructor
36 | spring.setFinalPosition(100f);
37 | // optional, default is STIFFNESS_MEDIUM
38 | spring.setStiffness(SpringForce.STIFFNESS_LOW);
39 | // optional, default is DAMPING_RATIO_MEDIUM_BOUNCY
40 | spring.setDampingRatio(SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
41 | // set your animation's spring
42 | animation.setSpring(spring);
43 | // animate!
44 | animation.start();
45 | }
46 | ```
47 |
48 | ### Preview
49 | 
50 |
51 | ### Position
52 | Let’s say we have an arbitrary view positioned in the center of the screen
53 | We want to achieve the following behavior:
54 |
55 | 1. Drag the view.
56 | 2. Move it around.
57 | 3. Release it.
58 | 4. The view springs back to its original position.
59 |
60 | ### Rotation
61 | There’s a rotating view on our screen which behaves like this:
62 |
63 | 1. Grab the view.
64 | 2. Spin it.
65 | 3. Release it.
66 | 4. The view spins back to its original position, again with a bounce.
67 |
68 | ### Scale
69 | As usual, there’s a view on our screen (it could be a photo) which has the following behavior:
70 |
71 | 1. Grab it with 2 fingers.
72 | 2. Do a typical pinching gesture to zoom in or out.
73 | 3. Release it.
74 | 4. The view scales back to its original size.
75 |
76 | Feel free to fork, contribute and poke at the code.
77 |
78 | Developed By
79 | -------
80 | Igor Havrylyuk (Graviton57)
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/fragment/AnimationFragment.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.havrylyuk.dynamicanimationexample.animation.AnimationType;
13 | import com.havrylyuk.dynamicanimationexample.R;
14 | import com.havrylyuk.dynamicanimationexample.animation.PositionSpringAnimation;
15 | import com.havrylyuk.dynamicanimationexample.animation.RotationSpringAnimation;
16 | import com.havrylyuk.dynamicanimationexample.animation.ScaleSpringAnimation;
17 |
18 |
19 | /**
20 | *
21 | * Created by Igor Havrylyuk on 27.03.2017.
22 | */
23 |
24 | public class AnimationFragment extends Fragment {
25 |
26 |
27 | private static final String ARG_ITEM_ID = "ARG_ITEM_ID";
28 | private AnimationType animType;
29 | private ImageView animateView;
30 | private TextView infoView;
31 |
32 |
33 | public static AnimationFragment getInstance(int itemId) {
34 | Bundle args = new Bundle();
35 | args.putInt(ARG_ITEM_ID, itemId);
36 | AnimationFragment animationFragment = new AnimationFragment();
37 | animationFragment.setArguments(args);
38 | return animationFragment;
39 | }
40 |
41 | @Nullable
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
44 | View rootView = inflater.inflate(R.layout.fragment_animation, container, false);
45 | if (getArguments() != null) {
46 | animType = AnimationType.values()[getArguments().getInt(ARG_ITEM_ID)];
47 | }
48 | initUI(rootView);
49 | prepareAnimations();
50 | return rootView;
51 | }
52 |
53 | private void initUI (View rootView) {
54 | infoView = (TextView) rootView.findViewById(R.id.info_text_view);
55 | animateView = ( ImageView) rootView.findViewById(R.id.animate_image);
56 | }
57 |
58 | private void prepareAnimations() {
59 | switch (animType) {
60 | case POSITION:
61 | animateView.setImageResource(R.drawable.heart);
62 | PositionSpringAnimation positionSpringAnimation =
63 | new PositionSpringAnimation(animateView);
64 | setInfoTextVisible(false);
65 | break;
66 | case ROTATION:
67 | animateView.setImageResource(R.drawable.loading);
68 | RotationSpringAnimation rotationAnimation =
69 | new RotationSpringAnimation(animateView, infoView);
70 | setInfoTextVisible(true);
71 | break;
72 | case SCALE:
73 | animateView.setImageResource(R.drawable.fingle);
74 | ScaleSpringAnimation scaleSpringAnimation =
75 | new ScaleSpringAnimation(animateView, infoView);
76 | setInfoTextVisible(true);
77 | break;
78 | }
79 | }
80 |
81 | private void setInfoTextVisible(boolean isVisible){
82 | if (infoView != null) {
83 | if (isVisible){
84 | infoView.setVisibility(View.VISIBLE);
85 | } else {
86 | infoView.setVisibility(View.GONE);
87 | }
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/animation/ScaleSpringAnimation.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.animation;
2 |
3 | import android.support.animation.DynamicAnimation;
4 | import android.support.animation.SpringAnimation;
5 | import android.support.animation.SpringForce;
6 | import android.view.MotionEvent;
7 | import android.view.ScaleGestureDetector;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import java.util.Locale;
13 |
14 | import static com.havrylyuk.dynamicanimationexample.animation.SpringAnimationUtil.createSpringAnimation;
15 |
16 | /**
17 | * Simple class showcase scale spring animation
18 | * Created by Igor Havrylyuk on 27.03.2017.
19 | */
20 |
21 | public class ScaleSpringAnimation {
22 |
23 | private static final float INITIAL_SCALE = 1f;
24 | private float scaleFactor = 1f;
25 |
26 | private SpringAnimation scaleXAnimation ;
27 | private SpringAnimation scaleYAnimation;
28 | private ScaleGestureDetector scaleGestureDetector;
29 |
30 | private View animateView;
31 | private TextView infoView;
32 |
33 | public ScaleSpringAnimation(ImageView animateView, TextView infoView) {
34 | this.infoView = infoView;
35 | this.animateView = animateView;
36 | // create scaleX and scaleY animations
37 | scaleXAnimation = createSpringAnimation( animateView, SpringAnimation.SCALE_X,
38 | INITIAL_SCALE, SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
39 | scaleYAnimation = createSpringAnimation( animateView, SpringAnimation.SCALE_Y,
40 | INITIAL_SCALE, SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
41 | updateInfoView();
42 | setupPinchToZoom();
43 | this.animateView.setOnTouchListener(touchListener);
44 | scaleXAnimation.addUpdateListener(updateListener);
45 | }
46 |
47 | private View.OnTouchListener touchListener = new View.OnTouchListener() {
48 | @Override
49 | public boolean onTouch(View v, MotionEvent event) {
50 | if (event.getAction() == MotionEvent.ACTION_UP) {
51 | scaleXAnimation.start();
52 | scaleYAnimation.start();
53 | } else {
54 | // cancel animations so we can grab the view during previous animation
55 | scaleXAnimation.cancel();
56 | scaleYAnimation.cancel();
57 | // pass touch event to ScaleGestureDetector
58 | scaleGestureDetector.onTouchEvent(event);
59 | }
60 | return true;
61 | }
62 | };
63 |
64 | private void setupPinchToZoom() {
65 | scaleGestureDetector = new ScaleGestureDetector(animateView.getContext(),
66 | new ScaleGestureDetector.SimpleOnScaleGestureListener(){
67 | @Override
68 | public boolean onScale(ScaleGestureDetector detector) {
69 | scaleFactor *= detector.getScaleFactor();
70 | animateView.setScaleX(animateView.getScaleX() * scaleFactor);
71 | animateView.setScaleY(animateView.getScaleY() * scaleFactor);
72 | updateInfoView();
73 | return true;
74 | }
75 | }
76 | );
77 | }
78 |
79 | private DynamicAnimation.OnAnimationUpdateListener updateListener = new DynamicAnimation.OnAnimationUpdateListener() {
80 | @Override
81 | public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
82 | updateInfoView();
83 | }
84 | };
85 |
86 | public void updateInfoView(){
87 | if (animateView != null && infoView != null) {
88 | infoView.setText(String.format(Locale.getDefault(), "%.2f", animateView.getScaleX()));
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/animation/RotationSpringAnimation.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample.animation;
2 |
3 | import android.support.animation.DynamicAnimation;
4 | import android.support.animation.SpringAnimation;
5 | import android.support.animation.SpringForce;
6 | import android.view.MotionEvent;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import java.util.Locale;
12 |
13 | import static com.havrylyuk.dynamicanimationexample.animation.SpringAnimationUtil.createSpringAnimation;
14 |
15 | /**
16 | * Simple class showcase rotation spring animation
17 | * Created by Igor Havrylyuk on 27.03.2017.
18 | */
19 |
20 | public class RotationSpringAnimation {
21 |
22 | private static final float INITIAL_ROTATION = 0f;
23 | private SpringAnimation rotationAnimation;
24 | private float previousRotation;
25 | private float currentRotation ;
26 | private View animateView;
27 | private TextView infoView;
28 |
29 | public RotationSpringAnimation(ImageView animateView, TextView infoView) {
30 | // create a rotation SpringAnimation
31 | rotationAnimation = createSpringAnimation(animateView,
32 | SpringAnimation.ROTATION, INITIAL_ROTATION,
33 | SpringForce.STIFFNESS_MEDIUM, SpringForce.DAMPING_RATIO_HIGH_BOUNCY);
34 | this.infoView = infoView;
35 | this.animateView = animateView;
36 | this.animateView.setOnTouchListener(touchListener);
37 | rotationAnimation.addUpdateListener(updateListener);
38 | updateInfoView();
39 | }
40 |
41 | public View.OnTouchListener getTouchListener() {
42 | return touchListener;
43 | }
44 |
45 | private View.OnTouchListener touchListener = new View.OnTouchListener() {
46 | double centerX;
47 | double centerY;
48 | float x;
49 | float y;
50 | // angle calculation
51 | private void updateRotation(View view){
52 | currentRotation = view.getRotation() +
53 | (float) Math.toDegrees(Math.atan2(x - centerX, centerY - y));
54 | }
55 | @Override
56 | public boolean onTouch(View view, MotionEvent event) {
57 | centerX = view.getWidth() / 2.0;
58 | centerY = view.getHeight() / 2.0;
59 | x = event.getX();
60 | y = event.getY();
61 | switch (event.getActionMasked()) {
62 | case MotionEvent.ACTION_DOWN:
63 | // cancel so we can grab the view during previous animation
64 | rotationAnimation.cancel();
65 | updateRotation(view);
66 | break;
67 | case MotionEvent.ACTION_MOVE:
68 | // save current rotation
69 | previousRotation = currentRotation;
70 | updateRotation(view);
71 | // rotate view by angle difference
72 | float angle = currentRotation - previousRotation;
73 | view.setRotation(view.getRotation() + angle);// += angle;
74 | updateInfoView();
75 | break;
76 | case MotionEvent.ACTION_UP:
77 | rotationAnimation.start();
78 | break;
79 | }
80 | return true;
81 | }
82 | };
83 |
84 | private DynamicAnimation.OnAnimationUpdateListener updateListener = new DynamicAnimation.OnAnimationUpdateListener() {
85 | @Override
86 | public void onAnimationUpdate(DynamicAnimation animation, float value, float velocity) {
87 | updateInfoView();
88 | }
89 | };
90 |
91 | public void updateInfoView(){
92 | if (animateView != null && infoView != null) {
93 | infoView.setText(String.format(Locale.getDefault(), "%.2f", animateView.getRotation()));
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/havrylyuk/dynamicanimationexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.havrylyuk.dynamicanimationexample;
2 |
3 | import android.os.Build;
4 | import android.os.Bundle;
5 | import android.support.annotation.RequiresApi;
6 | import android.support.design.widget.TabLayout;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.widget.Toast;
15 |
16 |
17 | import com.havrylyuk.dynamicanimationexample.adapter.AnimationPagerAdapter;
18 | import com.havrylyuk.dynamicanimationexample.animation.AnimationType;
19 |
20 | import java.util.ArrayList;
21 |
22 | public class MainActivity extends AppCompatActivity {
23 |
24 | private AnimationPagerAdapter animationsAdapter;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
31 | setSupportActionBar(toolbar);
32 | setupAnimationsViewPager();
33 | populateAnimationsData();
34 | }
35 |
36 | private void setupAnimationsViewPager(){
37 | final ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
38 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
39 | animationsAdapter = new AnimationPagerAdapter(getSupportFragmentManager(),
40 | new ArrayList());
41 | viewPager.setAdapter(animationsAdapter);
42 | tabLayout.setupWithViewPager(viewPager);
43 | viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
44 | viewPager.setOnTouchListener(new View.OnTouchListener()
45 | {
46 | @Override
47 | public boolean onTouch(View v, MotionEvent event)
48 | {
49 | return true;
50 | }
51 | });
52 | tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
53 | @Override
54 | public void onTabSelected(TabLayout.Tab tab) {
55 | viewPager.setCurrentItem(tab.getPosition());
56 | }
57 |
58 | @Override
59 | public void onTabUnselected(TabLayout.Tab tab) {
60 | }
61 |
62 | @Override
63 | public void onTabReselected(TabLayout.Tab tab) {
64 | }
65 | });
66 | }
67 |
68 | private void populateAnimationsData() {
69 | ArrayList data = new ArrayList<>();
70 | data.add(AnimationType.POSITION);
71 | data.add(AnimationType.ROTATION);
72 | data.add(AnimationType.SCALE);
73 | if (animationsAdapter != null) {
74 | animationsAdapter.addItems(data);
75 | }
76 | }
77 |
78 | @Override
79 | public boolean onCreateOptionsMenu(Menu menu) {
80 | getMenuInflater().inflate(R.menu.menu_main, menu);
81 | return true;
82 | }
83 |
84 | @Override
85 | public boolean onOptionsItemSelected(MenuItem item) {
86 | int id = item.getItemId();
87 | if (id == R.id.action_about) {
88 | Toast.makeText(this, "Graviton57", Toast.LENGTH_SHORT).show();
89 | return true;
90 | }
91 | return super.onOptionsItemSelected(item);
92 | }
93 |
94 | /*
95 | * Enables immersive mode to automatically hide system bars.
96 | */
97 | @RequiresApi(api = Build.VERSION_CODES.KITKAT)
98 | @Override
99 | public void onWindowFocusChanged(boolean hasFocus) {
100 | super.onWindowFocusChanged(hasFocus);
101 | if (hasWindowFocus()){
102 | getWindow().getDecorView().setSystemUiVisibility(
103 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
104 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
105 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
106 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
107 | View.SYSTEM_UI_FLAG_FULLSCREEN |
108 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
109 | }
110 | }
111 |
112 | }
113 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------