Skip to content

Commit

Permalink
Merge pull request RohitSurwase#4 from RohitSurwase/develop
Browse files Browse the repository at this point in the history
added demo app for global animations.
  • Loading branch information
RohitSurwase authored Sep 22, 2017
2 parents c9be386 + 29eb589 commit 6ee0337
Show file tree
Hide file tree
Showing 32 changed files with 553 additions and 1 deletion.
1 change: 1 addition & 0 deletions animations-simplified/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
33 changes: 33 additions & 0 deletions animations-simplified/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"

defaultConfig {
applicationId "com.rohitss.animationssimplified"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
25 changes: 25 additions & 0 deletions animations-simplified/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Soft_Dev\Android_SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.rohitss.animationssimplified;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.rohitss.animationssimplified", appContext.getPackageName());
}
}
23 changes: 23 additions & 0 deletions animations-simplified/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rohitss.animationssimplified">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FirstActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".SecondActivity">
</activity>
</application>

</manifest>
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();
}
}
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.rohitss.animationssimplified;

import android.os.Bundle;

public class SecondActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
}
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
));
}
}

8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_from_left.xml
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>
8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_from_right.xml
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>
8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_from_top.xml
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>
8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_to_bottom.xml
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>
8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_to_left.xml
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>
8 changes: 8 additions & 0 deletions animations-simplified/src/main/res/anim/slide_to_right.xml
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>
Loading

0 comments on commit 6ee0337

Please sign in to comment.