forked from RohitSurwase/AndroidDesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added demo app for global animations
- Loading branch information
-global
committed
Sep 22, 2017
1 parent
9b61a2d
commit 29eb589
Showing
14 changed files
with
402 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
animations-simplified/src/main/java/com/rohitss/animationssimplified/BaseActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.rohitss.animationssimplified; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* Created by JayYogeshwar on 22-09-2017. | ||
*/ | ||
public class BaseActivity extends AppCompatActivity { | ||
@Override | ||
public void finish() { | ||
super.finish(); | ||
overridePendingTransitionExit(); | ||
} | ||
|
||
@Override | ||
public void startActivity(Intent intent) { | ||
super.startActivity(intent); | ||
overridePendingTransitionEnter(); | ||
} | ||
|
||
/** | ||
* Overrides the pending Activity transition by performing the "Enter" animation. | ||
*/ | ||
protected void overridePendingTransitionEnter() { | ||
overridePendingTransition(R.anim.slide_from_right, R.anim.slide_to_left); | ||
} | ||
|
||
/** | ||
* Overrides the pending Activity transition by performing the "Exit" animation. | ||
*/ | ||
protected void overridePendingTransitionExit() { | ||
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
super.onBackPressed(); | ||
overridePendingTransitionExit(); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
animations-simplified/src/main/java/com/rohitss/animationssimplified/FirstActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.rohitss.animationssimplified; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class FirstActivity extends BaseActivity implements View.OnClickListener { | ||
private TextView textViewRight; | ||
private TextView textViewLeft; | ||
private TextView textViewTop; | ||
private Button buttonActivity; | ||
private Button buttonAddRight; | ||
private Button buttonRemoveLeft; | ||
private Button buttonAddLeft; | ||
private Button buttonRemoveRight; | ||
private Button buttonAddTop; | ||
private Button buttonRemoveBottom; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_first); | ||
textViewRight = (TextView) findViewById(R.id.textViewRight); | ||
textViewLeft = (TextView) findViewById(R.id.textViewLeft); | ||
textViewTop = (TextView) findViewById(R.id.textViewTop); | ||
buttonActivity = (Button) findViewById(R.id.buttonActivity); | ||
buttonAddRight = (Button) findViewById(R.id.buttonAddRight); | ||
buttonRemoveLeft = (Button) findViewById(R.id.buttonRemoveLeft); | ||
buttonAddLeft = (Button) findViewById(R.id.buttonAddLeft); | ||
buttonRemoveRight = (Button) findViewById(R.id.buttonRemoveRight); | ||
buttonAddTop = (Button) findViewById(R.id.buttonAddTop); | ||
buttonRemoveBottom = (Button) findViewById(R.id.buttonRemoveBottom); | ||
buttonActivity.setOnClickListener(this); | ||
buttonAddRight.setOnClickListener(this); | ||
buttonAddLeft.setOnClickListener(this); | ||
buttonAddTop.setOnClickListener(this); | ||
buttonRemoveRight.setOnClickListener(this); | ||
buttonRemoveLeft.setOnClickListener(this); | ||
buttonRemoveBottom.setOnClickListener(this); | ||
textViewRight.setVisibility(View.INVISIBLE); | ||
textViewLeft.setVisibility(View.INVISIBLE); | ||
textViewTop.setVisibility(View.INVISIBLE); | ||
} | ||
|
||
@Override | ||
public void onClick(View view) { | ||
switch (view.getId()) { | ||
case R.id.buttonActivity: | ||
startActivity(new Intent(FirstActivity.this, SecondActivity.class)); | ||
break; | ||
case R.id.buttonAddRight: | ||
textViewRight.setVisibility(View.VISIBLE); | ||
SlideAnimationUtil.slideInFromRight(this, textViewRight); | ||
break; | ||
case R.id.buttonRemoveLeft: | ||
textViewRight.setVisibility(View.INVISIBLE); | ||
SlideAnimationUtil.slideOutToLeft(this, textViewRight); | ||
break; | ||
case R.id.buttonAddLeft: | ||
textViewLeft.setVisibility(View.VISIBLE); | ||
SlideAnimationUtil.slideInFromLeft(this, textViewLeft); | ||
break; | ||
case R.id.buttonRemoveRight: | ||
textViewLeft.setVisibility(View.INVISIBLE); | ||
SlideAnimationUtil.slideOutToRight(this, textViewLeft); | ||
break; | ||
case R.id.buttonAddTop: | ||
textViewTop.setVisibility(View.VISIBLE); | ||
SlideAnimationUtil.slideInFromTop(this, textViewTop); | ||
break; | ||
case R.id.buttonRemoveBottom: | ||
textViewTop.setVisibility(View.INVISIBLE); | ||
SlideAnimationUtil.slideOutToBottom(this, textViewTop); | ||
break; | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
...imationssimplified/AnimationActivity.java → .../animationssimplified/SecondActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package com.rohitss.animationssimplified; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
public class AnimationActivity extends AppCompatActivity { | ||
public class SecondActivity extends BaseActivity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_animation); | ||
setContentView(R.layout.activity_second); | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
animations-simplified/src/main/java/com/rohitss/animationssimplified/SlideAnimationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.rohitss.animationssimplified; | ||
|
||
import android.content.Context; | ||
import android.view.View; | ||
import android.view.animation.AnimationUtils; | ||
|
||
/** | ||
* <b></b> | ||
* <p>This class is used to </p> | ||
* Animate any view using "SlideAnimationUtil.slideInFromLeft(context, view);" | ||
* Created by Rohit. | ||
*/ | ||
public class SlideAnimationUtil { | ||
/** | ||
* Animates a view so that it slides in from the left of it's container. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideInFromLeft(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_from_left); | ||
} | ||
|
||
/** | ||
* Animates a view so that it slides from its current position, out of view to the left. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideOutToLeft(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_to_left); | ||
} | ||
|
||
/** | ||
* Animates a view so that it slides in the from the right of it's container. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideInFromRight(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_from_right); | ||
} | ||
|
||
/** | ||
* Animates a view so that it slides from its current position, out of view to the right. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideOutToRight(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_to_right); | ||
} | ||
|
||
/** | ||
* Animates a view so that it slides in the from the right of it's container. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideInFromTop(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_from_top); | ||
} | ||
|
||
/** | ||
* Animates a view so that it slides from its current position, out of view to the right. | ||
* | ||
* @param context | ||
* @param view | ||
*/ | ||
public static void slideOutToBottom(Context context, View view) { | ||
runSimpleAnimation(context, view, R.anim.slide_to_bottom); | ||
} | ||
|
||
/** | ||
* Runs a simple animation on a View with no extra parameters. | ||
* | ||
* @param context | ||
* @param view | ||
* @param animationId | ||
*/ | ||
private static void runSimpleAnimation(Context context, View view, int animationId) { | ||
view.startAnimation(AnimationUtils.loadAnimation( | ||
context, animationId | ||
)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromXDelta="-100%p" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toXDelta="0"/> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromXDelta="100%p" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toXDelta="0"/> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromYDelta="-100%" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toYDelta="0"/> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromYDelta="0" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toYDelta="-100%p"/> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromXDelta="0" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toXDelta="-100%p"/> | ||
</set> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<translate | ||
android:duration="300" | ||
android:fromXDelta="0" | ||
android:interpolator="@android:anim/accelerate_decelerate_interpolator" | ||
android:toXDelta="100%p"/> | ||
</set> |
19 changes: 0 additions & 19 deletions
19
animations-simplified/src/main/res/layout/activity_animation.xml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.