├── LICENSE.txt ├── README.md ├── ZeroGravityAnimation.iml ├── app ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cooltechworks │ │ └── zerogravityanimation │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── cooltechworks │ │ └── zerogravityanimation │ │ ├── MainActivity.java │ │ ├── RandomUtil.java │ │ ├── ZeroGravityAnimation.java │ │ ├── direction │ │ ├── Direction.java │ │ └── DirectionGenerator.java │ │ └── ott │ │ └── OverTheTopLayer.java │ └── res │ ├── drawable-hdpi │ ├── star.png │ └── starglow.png │ ├── drawable-mdpi │ ├── star.png │ └── starglow.png │ ├── drawable-xhdpi │ ├── star.png │ └── starglow.png │ ├── drawable │ ├── bg_space.jpg │ ├── earth.png │ ├── meteor.png │ ├── round_rectangle_white.xml │ └── satellite.png │ ├── layout │ └── act_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Cooltechworks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZeroGravityAnimation 2 | 3 | Make random object fly on your screen. 4 | 5 | The repo helps in easier development of flying random objects on random directions (or 6 | on specific directions) to give a goodUI experience for the user. Specifically made for 7 | gaming purpose, the repo will be highly useful for apps that deals with space related 8 | animations, thus named as ZeroGravityAnimation. The animation works with a class called 9 | OverTheTopLayer, that makes the object to fly on the top of the screen. A ViewGroup layout 10 | can be passed optionally that acts as a container for the animating objects. 11 | 12 | ####Sample: 13 | 14 | The image illustrates the stars flying beneath the earth with the help of container layout while a meteor and 15 | a satellite flying on the top of screen through OverTheTopLayer. 16 | 17 | ![zero](https://cloud.githubusercontent.com/assets/13122232/9293135/fdfffd2a-443b-11e5-9710-bdf98e610c37.gif) 18 | 19 | ####Usage: 20 | 21 | ```java 22 | 23 | int imgResource = R.drawable.star; // your animating object here 24 | int count = 1; // # of objects to fly 25 | float scale = 0.2f; // scaling factor for the animating objects - value ranges from 0.0 to 1.0 26 | 27 | // directions are optional and by default RANDOM will be picked 28 | Direction origin = Direction.LEFT; // animation origin direction - can also use Direction.TOP, Direction.BOTTOM, Direction.LEFT or Direction.RANDOM 29 | Direction destination = Direction.RIGHT; // same case as above for destination 30 | 31 | 32 | ZeroGravityAnimation animation = new ZeroGravityAnimation(); 33 | animation.setCount(count); 34 | animation.setScalingFactor(scale); 35 | animation.setOriginationDirection(origin); 36 | animation.setDestinationDirection(destination); 37 | animation.setImage(resId); 38 | animation.play(this); 39 | ``` 40 | 41 | 42 | #####Animation Listener: 43 | Default animation listener can used to collect events of this animation. 44 | ````java 45 | animation.setAnimationListener(new Animation.AnimationListener() { 46 | @Override 47 | public void onAnimationStart(Animation animation) { 48 | 49 | } 50 | 51 | @Override 52 | public void onAnimationEnd(Animation animation) { 53 | 54 | } 55 | 56 | @Override 57 | public void onAnimationRepeat(Animation animation) { 58 | 59 | } 60 | } 61 | ); 62 | ``` 63 | 64 | #####Animation Object Container Specification: 65 | Wanted you animation to take place beneath certain views - like the stars that fly beneath Earth in the above demo? 66 | Make sure you design your layouts to have a container layout (FrameLayout) that lies below than the original views and use the following code 67 | 68 | ```java 69 | 70 | ViewGroup container = (ViewGroup) findViewById(R.id.animation_container_layout); 71 | animation.play(this,container); 72 | ``` 73 | 74 | ###Apps using ZeroGravityAnimation: 75 | [Goldhunt Game](https://play.google.com/store/apps/details?id=com.cooltechworks.goldhunt)| 76 | ------------ | 77 | ![goldhuntdemo](https://cloud.githubusercontent.com/assets/13122232/9293580/3521f486-444e-11e5-9de2-3b9cab9a13f6.gif)| 78 | 79 | 80 | 81 | 82 | Developed By 83 | ============ 84 | 85 | * Harish Sridharan - 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /ZeroGravityAnimation.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "23.0.0 rc3" 6 | 7 | defaultConfig { 8 | applicationId "com.cooltechworks.zerogravityanimation" 9 | minSdkVersion 8 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:22.2.0' 25 | } 26 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/sharish/ADT_BASE/adt-bundle-mac-x86_64-20130729/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/cooltechworks/zerogravityanimation/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.ViewGroup; 6 | import android.view.animation.Animation; 7 | 8 | import com.cooltechworks.zerogravityanimation.direction.Direction; 9 | 10 | /** 11 | * Created by Harish Sridharan on July 20 2015. 12 | */ 13 | public class MainActivity extends Activity { 14 | 15 | public void onCreate(Bundle savedState) { 16 | super.onCreate(savedState); 17 | setContentView(R.layout.act_main); 18 | 19 | for(int i=0;i<5;i++) { 20 | // stars will fly behind the earth. 21 | flyStars(R.drawable.starglow); 22 | } 23 | 24 | // meteor will fly over the earth 25 | flyObject(R.drawable.meteor, 20000, Direction.RIGHT, Direction.LEFT, 1f); 26 | // satellite will fly over the earth. 27 | flyObject(R.drawable.satellite, 10000, Direction.LEFT, Direction.RIGHT, .4f); 28 | 29 | 30 | } 31 | 32 | /** 33 | * Animate the bigger objects. 34 | * @param resId image resource id of bigger object. 35 | * @param duration time duration for animation. 36 | * @param from origin direction 37 | * @param to destination direction. 38 | * @param scale scales the flier 39 | */ 40 | public void flyObject(final int resId, final int duration, final Direction from, final Direction to, final float scale) { 41 | 42 | ZeroGravityAnimation animation = new ZeroGravityAnimation(); 43 | animation.setCount(1); 44 | animation.setScalingFactor(scale); 45 | animation.setOriginationDirection(from); 46 | animation.setDestinationDirection(to); 47 | animation.setImage(resId); 48 | animation.setDuration(duration); 49 | animation.setAnimationListener(new Animation.AnimationListener() { 50 | @Override 51 | public void onAnimationStart(Animation animation) { 52 | 53 | } 54 | 55 | @Override 56 | public void onAnimationEnd(Animation animation) { 57 | 58 | flyObject(resId, duration, from, to, scale); 59 | } 60 | 61 | @Override 62 | public void onAnimationRepeat(Animation animation) { 63 | 64 | } 65 | }); 66 | 67 | ViewGroup container = (ViewGroup) findViewById(R.id.animation_bigger_objects_holder); 68 | animation.play(this,container); 69 | 70 | } 71 | 72 | /** 73 | * Animates the flying stars. 74 | * @param resId star image resource id. 75 | */ 76 | public void flyStars(final int resId) { 77 | 78 | ZeroGravityAnimation animation = new ZeroGravityAnimation(); 79 | animation.setCount(1); 80 | animation.setScalingFactor(0.2f); 81 | animation.setOriginationDirection(Direction.RANDOM); 82 | animation.setDestinationDirection(Direction.RANDOM); 83 | animation.setImage(resId); 84 | 85 | animation.setAnimationListener(new Animation.AnimationListener() { 86 | @Override 87 | public void onAnimationStart(Animation animation) { 88 | 89 | } 90 | 91 | @Override 92 | public void onAnimationEnd(Animation animation) { 93 | 94 | flyStars(resId == R.drawable.starglow ? R.drawable.star : R.drawable.starglow); 95 | } 96 | 97 | @Override 98 | public void onAnimationRepeat(Animation animation) { 99 | 100 | } 101 | } 102 | ); 103 | 104 | ViewGroup container = (ViewGroup) findViewById(R.id.star_animation_holder); 105 | animation.play(this,container); 106 | 107 | } 108 | } -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/RandomUtil.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * Created by Harish Sridharan on July 20 2015 7 | */ 8 | public class RandomUtil { 9 | 10 | /** 11 | * Generates the random between two given integers. 12 | * @param start 13 | * @param end 14 | * @return 15 | */ 16 | public static int generateRandomBetween(int start, int end) { 17 | 18 | Random random = new Random(); 19 | int rand = random.nextInt(Integer.MAX_VALUE - 1) % end; 20 | 21 | if (rand < start) { 22 | rand = start; 23 | } 24 | return rand; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/ZeroGravityAnimation.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.util.Log; 7 | import android.view.ViewGroup; 8 | import android.view.animation.Animation; 9 | import android.view.animation.TranslateAnimation; 10 | import android.widget.FrameLayout; 11 | import android.widget.ImageView; 12 | 13 | import com.cooltechworks.zerogravityanimation.direction.Direction; 14 | import com.cooltechworks.zerogravityanimation.direction.DirectionGenerator; 15 | import com.cooltechworks.zerogravityanimation.ott.OverTheTopLayer; 16 | 17 | import java.util.Random; 18 | 19 | /** 20 | * Created by Harish Sridharan on July 20 2015 21 | */ 22 | public class ZeroGravityAnimation { 23 | 24 | private static final int RANDOM_DURATION = -1; 25 | 26 | 27 | 28 | private Direction mOriginationDirection = Direction.RANDOM; 29 | private Direction mDestinationDirection = Direction.RANDOM; 30 | private int mDuration = RANDOM_DURATION; 31 | private int mCount = 1; 32 | private int mImageResId; 33 | private float mScalingFactor = 1f; 34 | private Animation.AnimationListener mAnimationListener; 35 | 36 | 37 | /** 38 | * Sets the orignal direction. The animation will originate from the given direction. 39 | * @param direction 40 | * @return 41 | */ 42 | public ZeroGravityAnimation setOriginationDirection(Direction direction) { 43 | this.mOriginationDirection = direction; 44 | return this; 45 | } 46 | 47 | /** 48 | * Sets the animation destination direction. The translate animation will proceed towards the given direction. 49 | * @param direction 50 | * @return 51 | */ 52 | public ZeroGravityAnimation setDestinationDirection(Direction direction) { 53 | this.mDestinationDirection = direction; 54 | return this; 55 | } 56 | 57 | /** 58 | * Will take a random time duriation for the animation 59 | * @return 60 | */ 61 | public ZeroGravityAnimation setRandomDuration() { 62 | return setDuration(RANDOM_DURATION); 63 | } 64 | 65 | /** 66 | * Sets the time duration in millseconds for animation to proceed. 67 | * @param duration 68 | * @return 69 | */ 70 | public ZeroGravityAnimation setDuration(int duration) { 71 | this.mDuration = duration; 72 | return this; 73 | } 74 | 75 | /** 76 | * Sets the image reference id for drawing the image 77 | * @param resId 78 | * @return 79 | */ 80 | public ZeroGravityAnimation setImage(int resId) { 81 | this.mImageResId = resId; 82 | return this; 83 | } 84 | 85 | /** 86 | * Sets the image scaling value. 87 | * @param scale 88 | * @return 89 | */ 90 | public ZeroGravityAnimation setScalingFactor(float scale) { 91 | this.mScalingFactor = scale; 92 | return this; 93 | } 94 | 95 | public ZeroGravityAnimation setAnimationListener(Animation.AnimationListener listener) { 96 | this.mAnimationListener = listener; 97 | return this; 98 | } 99 | 100 | public ZeroGravityAnimation setCount(int count) { 101 | this.mCount = count; 102 | return this; 103 | } 104 | 105 | 106 | /** 107 | * Starts the Zero gravity animation by creating an OTT and attach it to th given ViewGroup 108 | * @param activity 109 | * @param ottParent 110 | */ 111 | public void play(Activity activity, ViewGroup ottParent) { 112 | 113 | DirectionGenerator generator = new DirectionGenerator(); 114 | 115 | if(mCount > 0) { 116 | 117 | for (int i = 0; i < mCount; i++) { 118 | 119 | 120 | final int iDupe = i; 121 | 122 | Direction origin = mOriginationDirection == Direction.RANDOM ? generator.getRandomDirection() : mOriginationDirection; 123 | Direction destination = mDestinationDirection == Direction.RANDOM ? generator.getRandomDirection(origin) : mDestinationDirection; 124 | 125 | int startingPoints[] = generator.getPointsInDirection(activity, origin); 126 | int endPoints[] = generator.getPointsInDirection(activity,destination); 127 | 128 | 129 | Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), mImageResId); 130 | 131 | Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * mScalingFactor), (int) (bitmap.getHeight() * mScalingFactor), false); 132 | 133 | switch (origin) { 134 | case LEFT: 135 | startingPoints[0] -= scaledBitmap.getWidth(); 136 | break; 137 | 138 | case RIGHT: 139 | startingPoints[0] += scaledBitmap.getWidth(); 140 | break; 141 | 142 | case TOP: 143 | startingPoints[1] -= scaledBitmap.getHeight(); 144 | break; 145 | case BOTTOM: 146 | startingPoints[1] += scaledBitmap.getHeight(); 147 | break; 148 | } 149 | 150 | switch (destination) { 151 | case LEFT: 152 | endPoints[0] -= scaledBitmap.getWidth(); 153 | break; 154 | 155 | case RIGHT: 156 | endPoints[0] += scaledBitmap.getWidth(); 157 | break; 158 | 159 | case TOP: 160 | endPoints[1] -= scaledBitmap.getHeight(); 161 | break; 162 | case BOTTOM: 163 | endPoints[1] += scaledBitmap.getHeight(); 164 | break; 165 | } 166 | 167 | 168 | final OverTheTopLayer layer = new OverTheTopLayer(); 169 | 170 | FrameLayout ottLayout = layer.with(activity) 171 | .scale(mScalingFactor) 172 | .attachTo(ottParent) 173 | .setBitmap(scaledBitmap, startingPoints) 174 | .create(); 175 | 176 | 177 | switch (origin) { 178 | case LEFT: 179 | 180 | } 181 | 182 | int deltaX = endPoints[0] - startingPoints[0]; 183 | int deltaY = endPoints[1] - startingPoints[1]; 184 | 185 | int duration = mDuration; 186 | if (duration == RANDOM_DURATION) { 187 | duration = RandomUtil.generateRandomBetween(3500, 12500); 188 | } 189 | 190 | TranslateAnimation animation = new TranslateAnimation(0, deltaX, 0, deltaY); 191 | animation.setDuration(duration); 192 | animation.setAnimationListener(new Animation.AnimationListener() { 193 | @Override 194 | public void onAnimationStart(Animation animation) { 195 | 196 | if (iDupe == 0) { 197 | if (mAnimationListener != null) { 198 | mAnimationListener.onAnimationStart(animation); 199 | } 200 | } 201 | } 202 | 203 | @Override 204 | public void onAnimationEnd(Animation animation) { 205 | 206 | layer.destroy(); 207 | 208 | if (iDupe == (mCount - 1)) { 209 | if (mAnimationListener != null) { 210 | mAnimationListener.onAnimationEnd(animation); 211 | } 212 | } 213 | 214 | } 215 | 216 | @Override 217 | public void onAnimationRepeat(Animation animation) { 218 | 219 | } 220 | }); 221 | layer.applyAnimation(animation); 222 | } 223 | } 224 | else { 225 | 226 | Log.e(ZeroGravityAnimation.class.getSimpleName(),"Count was not provided, animation was not started"); 227 | } 228 | } 229 | 230 | /** 231 | * Takes the content view as view parent for laying the animation objects and starts the animation. 232 | * @param activity - activity on which the zero gravity animation should take place. 233 | */ 234 | public void play(Activity activity) { 235 | 236 | play(activity,null); 237 | 238 | } 239 | } -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/direction/Direction.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation.direction; 2 | 3 | /** 4 | * Created by Harish Sridharan on July 20 2015 5 | */ 6 | public enum Direction { 7 | 8 | TOP, LEFT, RIGHT, BOTTOM,RANDOM 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/direction/DirectionGenerator.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation.direction; 2 | 3 | import android.app.Activity; 4 | 5 | import java.util.Random; 6 | 7 | /** 8 | * Created by Harish Sridharan on July 20 2015 9 | */ 10 | public class DirectionGenerator { 11 | 12 | 13 | /** 14 | * Gets the random pixel points in the given direction of the screen 15 | * @param activity - activity from where you are referring the random value. 16 | * @param direction - on among LEFT,RIGHT,TOP,BOTTOM,RANDOM 17 | * @return a pixel point {x,y} in the given direction. 18 | */ 19 | public int[] getPointsInDirection(Activity activity, Direction direction) { 20 | 21 | switch (direction) { 22 | 23 | case LEFT: 24 | return getRandomLeft(activity); 25 | case RIGHT: 26 | return getRandomRight(activity); 27 | case BOTTOM: 28 | return getRandomBottom(activity); 29 | case TOP: 30 | return getRandomTop(activity); 31 | 32 | default: 33 | Direction[] allDirections = new Direction[]{Direction.LEFT,Direction.TOP,Direction.BOTTOM,Direction.RIGHT}; 34 | int index = new Random().nextInt(allDirections.length); 35 | return getPointsInDirection(activity, allDirections[index]); 36 | 37 | } 38 | 39 | } 40 | 41 | /** 42 | * Gets the random pixel points in the left direction of the screen. The value will be of {0,y} where y will be a random value. 43 | * @param activity - activity from where you are referring the random value. 44 | * @return a pixel point {x,y}. 45 | */ 46 | public int[] getRandomLeft(Activity activity) { 47 | 48 | int x = 0; 49 | 50 | int height = activity.getResources().getDisplayMetrics().heightPixels; 51 | 52 | Random random = new Random(); 53 | int y = random.nextInt(height); 54 | 55 | return new int[]{x, y}; 56 | } 57 | 58 | /** 59 | * Gets the random pixel points in the top direction of the screen. The value will be of {x,0} where x will be a random value. 60 | * @param activity - activity from where you are referring the random value. 61 | * @return a pixel point {x,y}. 62 | */ 63 | public int[] getRandomTop(Activity activity) { 64 | 65 | int y = 0; 66 | 67 | int width = activity.getResources().getDisplayMetrics().widthPixels; 68 | 69 | Random random = new Random(); 70 | int x = random.nextInt(width); 71 | 72 | return new int[]{x, y}; 73 | } 74 | 75 | /** 76 | * Gets the random pixel points in the right direction of the screen. The value will be of {screen_width,y} where y will be a random value. 77 | * @param activity - activity from where you are referring the random value. 78 | * @return a pixel point {x,y}. 79 | */ 80 | public int[] getRandomRight(Activity activity) { 81 | 82 | 83 | int width = activity.getResources().getDisplayMetrics().widthPixels; 84 | int height = activity.getResources().getDisplayMetrics().heightPixels; 85 | 86 | int x = width ; 87 | 88 | Random random = new Random(); 89 | int y = random.nextInt(height); 90 | 91 | return new int[]{x, y}; 92 | } 93 | 94 | /** 95 | * Gets the random pixel points in the bottom direction of the screen. The value will be of {x,screen_height} where x will be a random value. 96 | * @param activity - activity from where you are referring the random value. 97 | * @return a pixel point {x,y}. 98 | */ 99 | public int[] getRandomBottom(Activity activity) { 100 | 101 | 102 | int width = activity.getResources().getDisplayMetrics().widthPixels; 103 | int height = activity.getResources().getDisplayMetrics().heightPixels; 104 | 105 | 106 | int y = height ; 107 | Random random = new Random(); 108 | int x = random.nextInt(width); 109 | 110 | return new int[]{x, y}; 111 | } 112 | 113 | /** 114 | * Gets a random direction. 115 | * @return one among LEFT,RIGHT,BOTTOM,TOP 116 | */ 117 | public Direction getRandomDirection() { 118 | Direction[] allDirections = new Direction[]{Direction.LEFT,Direction.TOP,Direction.BOTTOM,Direction.RIGHT}; 119 | int index = new Random().nextInt(allDirections.length); 120 | return (allDirections[index]); 121 | } 122 | 123 | /** 124 | * Gets a random direction skipping the given direction. 125 | * @param toSkip a direction which should not be returned by this method. 126 | * @return one among LEFT,RIGHT,BOTTOM if TOP is provided as direction to skip, 127 | * one among TOP,RIGHT,BOTTOM if LEFT is provided as direction to skip 128 | * and so on. 129 | */ 130 | public Direction getRandomDirection(Direction toSkip) { 131 | Direction[] allExceptionalDirections; 132 | switch (toSkip) { 133 | 134 | case LEFT: 135 | allExceptionalDirections = new Direction[]{Direction.TOP,Direction.BOTTOM,Direction.RIGHT}; 136 | break; 137 | case RIGHT: 138 | allExceptionalDirections = new Direction[]{Direction.TOP,Direction.BOTTOM,Direction.LEFT}; 139 | break; 140 | case BOTTOM: 141 | allExceptionalDirections = new Direction[]{Direction.TOP,Direction.LEFT,Direction.RIGHT}; 142 | break; 143 | case TOP: 144 | allExceptionalDirections = new Direction[]{Direction.LEFT,Direction.BOTTOM,Direction.RIGHT}; 145 | break; 146 | 147 | default: 148 | allExceptionalDirections = new Direction[]{Direction.LEFT,Direction.TOP,Direction.BOTTOM,Direction.RIGHT}; 149 | 150 | 151 | } 152 | 153 | int index = new Random().nextInt(allExceptionalDirections.length); 154 | return (allExceptionalDirections[index]); 155 | } 156 | 157 | } 158 | -------------------------------------------------------------------------------- /app/src/main/java/com/cooltechworks/zerogravityanimation/ott/OverTheTopLayer.java: -------------------------------------------------------------------------------- 1 | package com.cooltechworks.zerogravityanimation.ott; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.res.Resources; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.graphics.Color; 9 | import android.graphics.Rect; 10 | import android.graphics.drawable.Drawable; 11 | import android.util.Log; 12 | import android.view.Gravity; 13 | import android.view.View; 14 | import android.view.ViewGroup; 15 | import android.view.WindowManager; 16 | import android.view.animation.Animation; 17 | import android.widget.FrameLayout; 18 | import android.widget.ImageView; 19 | import android.widget.TextView; 20 | 21 | import java.lang.ref.WeakReference; 22 | 23 | /** 24 | * Created by Harish Sridharan on July-20-2015 AD. 25 | */ 26 | public class OverTheTopLayer { 27 | 28 | public static class OverTheTopLayerException extends RuntimeException { 29 | public OverTheTopLayerException(String msg) { 30 | super(msg); 31 | } 32 | } 33 | 34 | private WeakReference mWeakActivity; 35 | private WeakReference mWeakRootView; 36 | private FrameLayout mCreatedOttLayer; 37 | private float mScalingFactor = 1.0f; 38 | private int[] mDrawLocation = {0, 0}; 39 | private Bitmap mBitmap; 40 | 41 | 42 | public OverTheTopLayer() { 43 | } 44 | 45 | /** 46 | * To create a layer on the top of activity 47 | * 48 | * @param weakReferenceActivity 49 | * @return 50 | */ 51 | public OverTheTopLayer with(Activity weakReferenceActivity) { 52 | mWeakActivity = new WeakReference(weakReferenceActivity); 53 | return this; 54 | } 55 | 56 | /** 57 | * Draws the image as per the drawable resource id on the given location pixels. 58 | * 59 | * @param resources 60 | * @param drawableResId 61 | * @param mScalingFactor 62 | * @param location 63 | * @return 64 | */ 65 | public OverTheTopLayer generateBitmap(Resources resources, int drawableResId, float mScalingFactor, int[] location) { 66 | 67 | if (location == null) { 68 | location = new int[]{0, 0}; 69 | } else if (location.length != 2) { 70 | throw new OverTheTopLayerException("Requires location as an array of length 2 - [x,y]"); 71 | } 72 | 73 | Bitmap bitmap = BitmapFactory.decodeResource(resources, drawableResId); 74 | 75 | Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * mScalingFactor), (int) (bitmap.getHeight() * mScalingFactor), false); 76 | 77 | this.mBitmap = scaledBitmap; 78 | 79 | this.mDrawLocation = location; 80 | return this; 81 | } 82 | 83 | public OverTheTopLayer setBitmap(Bitmap bitmap, int[] location) { 84 | 85 | if (location == null) { 86 | location = new int[]{0, 0}; 87 | } else if (location.length != 2) { 88 | throw new OverTheTopLayerException("Requires location as an array of length 2 - [x,y]"); 89 | } 90 | 91 | this.mBitmap = bitmap; 92 | this.mDrawLocation = location; 93 | return this; 94 | } 95 | 96 | 97 | /** 98 | * Holds the scaling factor for the image. 99 | * 100 | * @param scale 101 | * @return 102 | */ 103 | public OverTheTopLayer scale(float scale) { 104 | 105 | if (scale <= 0) { 106 | throw new OverTheTopLayerException("Scaling should be > 0"); 107 | 108 | } 109 | this.mScalingFactor = scale; 110 | 111 | 112 | return this; 113 | } 114 | 115 | /** 116 | * Attach the OTT layer as the child of the given root view. 117 | * @return 118 | */ 119 | public OverTheTopLayer attachTo(ViewGroup rootView) { 120 | this.mWeakRootView = new WeakReference(rootView); 121 | return this; 122 | } 123 | 124 | /** 125 | * Creates an OTT. 126 | * @return 127 | */ 128 | public FrameLayout create() { 129 | 130 | 131 | if(mCreatedOttLayer != null) { 132 | destroy(); 133 | } 134 | 135 | if (mWeakActivity == null) { 136 | throw new OverTheTopLayerException("Could not create the layer as not activity reference was provided."); 137 | } 138 | 139 | Activity activity = mWeakActivity.get(); 140 | 141 | if (activity != null) { 142 | ViewGroup attachingView = null; 143 | 144 | 145 | if (mWeakRootView != null && mWeakRootView.get() != null) { 146 | attachingView = mWeakRootView.get(); 147 | } else { 148 | attachingView = (ViewGroup) activity.findViewById(android.R.id.content); 149 | } 150 | 151 | 152 | ImageView imageView = new ImageView(activity); 153 | 154 | imageView.setImageBitmap(mBitmap); 155 | 156 | 157 | int minWidth = mBitmap.getWidth(); 158 | int minHeight = mBitmap.getHeight(); 159 | 160 | imageView.measure(View.MeasureSpec.makeMeasureSpec(minWidth, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(minHeight, View.MeasureSpec.AT_MOST)); 161 | 162 | FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) imageView.getLayoutParams(); 163 | 164 | if (params == null) { 165 | params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP); 166 | imageView.setLayoutParams(params); 167 | } 168 | 169 | int xPosition = mDrawLocation[0]; 170 | int yPosition = mDrawLocation[1]; 171 | 172 | params.width = minWidth; 173 | params.height = minHeight; 174 | 175 | params.leftMargin = xPosition; 176 | params.topMargin = yPosition; 177 | 178 | imageView.setLayoutParams(params); 179 | 180 | FrameLayout ottLayer = new FrameLayout(activity); 181 | FrameLayout.LayoutParams topLayerParam = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT, Gravity.TOP); 182 | 183 | ottLayer.setLayoutParams(topLayerParam); 184 | 185 | ottLayer.addView(imageView); 186 | 187 | attachingView.addView(ottLayer); 188 | 189 | mCreatedOttLayer = ottLayer; 190 | 191 | 192 | } else { 193 | Log.e(OverTheTopLayer.class.getSimpleName(), "Could not create the layer. Reference to the activity was lost"); 194 | } 195 | 196 | return mCreatedOttLayer; 197 | 198 | } 199 | 200 | /** 201 | * Kills the OTT 202 | */ 203 | public void destroy() { 204 | 205 | 206 | if (mWeakActivity == null) { 207 | throw new OverTheTopLayerException("Could not create the layer as not activity reference was provided."); 208 | } 209 | 210 | Activity activity = mWeakActivity.get(); 211 | 212 | if (activity != null) { 213 | ViewGroup attachingView = null; 214 | 215 | 216 | if (mWeakRootView != null && mWeakRootView.get() != null) { 217 | attachingView = mWeakRootView.get(); 218 | } else { 219 | attachingView = (ViewGroup) activity.findViewById(android.R.id.content); 220 | } 221 | 222 | if (mCreatedOttLayer != null) { 223 | 224 | attachingView.removeView(mCreatedOttLayer); 225 | mCreatedOttLayer = null; 226 | } 227 | 228 | 229 | } else { 230 | 231 | Log.e(OverTheTopLayer.class.getSimpleName(), "Could not destroy the layer as the layer was never created."); 232 | 233 | } 234 | 235 | } 236 | 237 | /** 238 | * Applies the animation to the image view present in OTT. 239 | * @param animation 240 | */ 241 | public void applyAnimation(Animation animation) { 242 | 243 | if(mCreatedOttLayer != null) { 244 | ImageView drawnImageView = (ImageView) mCreatedOttLayer.getChildAt(0); 245 | drawnImageView.startAnimation(animation); 246 | } 247 | } 248 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-hdpi/star.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/starglow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-hdpi/starglow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-mdpi/star.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/starglow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-mdpi/starglow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-xhdpi/star.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/starglow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable-xhdpi/starglow.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_space.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable/bg_space.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/earth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable/earth.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/meteor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable/meteor.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/round_rectangle_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 11 | 16 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/satellite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/drawable/satellite.png -------------------------------------------------------------------------------- /app/src/main/res/layout/act_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 25 | 26 | 27 | 28 | 33 | 34 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12dp 5 | 16dp 6 | 7 | 8 | 8dp 9 | -8dp 10 | 5dp 11 | 3px 12 | 4dp 13 | 16dp 14 | 24sp 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ZeroGravityAnimation 3 | EXPLORE 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /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:1.2.2' 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 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sharish/ZeroGravityAnimation/d6d45b13788331794bbf5a8cf2054dfdb94b827d/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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.2.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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /local.properties: -------------------------------------------------------------------------------- 1 | ## This file is automatically generated by Android Studio. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file should *NOT* be checked into Version Control Systems, 5 | # as it contains information specific to your local configuration. 6 | # 7 | # Location of the SDK. This is only used by Gradle. 8 | # For customization when using a Version Control System, please read the 9 | # header note. 10 | sdk.dir=/Users/sharish/ADT_BASE/adt-bundle-mac-x86_64-20130729/sdk -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------