Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
compileSdkVersion 27
buildToolsVersion "27.0.1"

defaultConfig {
applicationId "com.waynell.leafanimation"
minSdkVersion 11
targetSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/waynell/leafanimation/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@

public class MainActivity extends Activity {

DropAnimationView mDropAnimation;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DropAnimationView view = (DropAnimationView) findViewById(R.id.drop_animation_view);
view.setDrawables(R.drawable.leaf_1,
mDropAnimation = findViewById(R.id.drop_animation_view);
mDropAnimation.setDrawables(R.drawable.leaf_1,
R.drawable.leaf_2,
R.drawable.leaf_3,
R.drawable.leaf_4,
R.drawable.leaf_5,
R.drawable.leaf_6);
view.startAnimation();
// mDropAnimation.setAnimationRate(200);
mDropAnimation.startAnimation();
}

@Override
Expand All @@ -41,6 +44,14 @@ public boolean onOptionsItemSelected(MenuItem item) {

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
if (mDropAnimation.isAnimating())
{
mDropAnimation.stopAnimation();
}
else
{
mDropAnimation.startAnimation();
}
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
6 changes: 3 additions & 3 deletions drop-animation-view/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ version '1.0'
group = 'com.waynell.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 27
buildToolsVersion "27.0.1"

defaultConfig {
minSdkVersion 11
targetSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DropAnimationView extends FrameLayout {

private final Random mRandom = new Random();

private boolean mStopAnimation;
private boolean animating;

private int mMinSize;

Expand Down Expand Up @@ -60,7 +60,7 @@ public class DropAnimationView extends FrameLayout {

@Override
public void run() {
if (mStopAnimation || (mMinSize == 0 && mMaxSize == 0)) {
if (!animating || (mMinSize == 0 && mMaxSize == 0)) {
return;
}

Expand Down Expand Up @@ -166,14 +166,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

public void startAnimation() {
if(mDrawables != null) {
mStopAnimation = false;
animating = true;
setVisibility(VISIBLE);
beginAnimate(false);
}
}

public void stopAnimation() {
mStopAnimation = true;
animating = false;
removeCallbacks(mRunnable);
setVisibility(GONE);
for (AnimatorSet as : mAnimatorSetList) {
Expand Down Expand Up @@ -220,6 +220,15 @@ public void setEnableRotationAnimation(boolean enableRotationAnimation) {
mEnableRotationAnimation = enableRotationAnimation;
}

public void setAnimationRate(int rate) {
mAnimationRate = rate;
}

public boolean isAnimating()
{
return animating;
}

private void beginAnimate(boolean delayed) {
postDelayed(mRunnable, delayed ? mRandom.nextInt(4) * 1000 : 0);
}
Expand Down
12 changes: 6 additions & 6 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Nov 08 16:52:06 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
#Mon Dec 11 20:22:15 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip