Skip to content

Commit

Permalink
Added bounce animation.
Browse files Browse the repository at this point in the history
Updated README.md
  • Loading branch information
amitjangid80 committed May 21, 2018
1 parent e355988 commit c20ed08
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 14 deletions.
157 changes: 147 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

>**Add it in your root build.gradle at the end of repositories:**
```markdown
```
allprojects{
repositories {
...
Expand All @@ -19,16 +19,16 @@ allprojects{

#### Step 2. Add the dependency

```markdown
```
dependencies {
...
implementation 'com.github.amitjangid80:multiutillib:v1.2.6'
implementation 'com.github.amitjangid80:multiutillib:v1.2.7'
}
```

#### Using maven:

```markdown
```
<repositories>
<repository>
<id>jitpack.io</id>
Expand All @@ -39,11 +39,11 @@ dependencies {

#### Step 2. Add the dependency

```markdown
```
<dependency>
<groupId>com.github.amitjangid80</groupId>
<artifactId>multiutillib</artifactId>
<version>v1.2.6</version>
<version>v1.2.7</version>
<dependency>
```

Expand Down Expand Up @@ -75,7 +75,7 @@ public class ProjectApplication extends Application

### SharedPreferenceData

```markdown
```java
// use it in the activity or class you want to.
SharedPreferenceData sharedPreferenceData = new SharedPreferenceData(context);

Expand Down Expand Up @@ -613,7 +613,7 @@ UiUtils.setMaxLength(textInputEditText, maxLength);
**Usage**

```aidl
```java
/**
* is Sd Card Mounted
* this method will check if sd card is mounted or not
Expand Down Expand Up @@ -710,6 +710,143 @@ Utils.getSha512Hash(byte[] dataToHash);
**Usage**

```aidl
```java

// for making an activity slide from right to left
AnimUtil.slideActivityFromRightToLeft(context);

// for making an activity slide from left to right
AnimUtil.slideActivityFromLeftToRight(context);

// for making an activity slide from right to left
AnimUtil.slideActivityFromRightToLeft(context);

// for making an activity fade in fade out
AnimUtil.activityFadeInFadeOut(context);

// for making an activity from left with stay
AnimUtil.slideActivityFromLeftWithStay(context);

// for making an activity from right with stay
AnimUtil.slideActivityFromRightWithStay(context);

// for making an activity bottom with stay
AnimUtil.slideActivityFromBottomWithStay(context);

// for making an activity from top with stay
AnimUtil.slideActivityFromUpWithStay(context);

// for making an activity from bottom to up
AnimUtil.slideActivityFromBottomToUp(context);

// for making an activity from up to bottom
AnimUtil.slideActivityFromUpToBottom(context);

// for making an activity from up to bottom
AnimUtil.slideActivityFromUpToBottom(context);

// this method will make an view group to explode or rise
AnimUtil.explodeTransition(Context context, ViewGroup viewGroup, int duration);

// this method will make and view to slide from right
AnimUtil.slideAnimFromRight(@NonNull Context context, View view, int duration);

// this method will make and view to slide from left
AnimUtil.slideAnimFromLeft(@NonNull Context context, View view, int duration);

// Use your own animation in this method the way you want.
AnimUtil.slideAnim(@NonNull Context context, View view, int duration, @AnimRes int animResId);

// Use this method to make a button or a view bounce
AnimUtil.bounceAnim(Context context, View view);
```

###Social Buttons

>**Use Social buttons like you use normal button.**
**Usage**

```xml
<!-- Currently Facebook, Google, Twitter, LinkedIn buttons are available. -->

<!-- Square button with icon and color background and normal usage -->
<com.amit.ui.GoogleButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in with Google"
android:textAlignment="center"
android:textColor="@color/black"
app:iconSize="30dp"
app:iconPadding="30dp"
tools:ignore="HardcodedText" />

<!-- Round Button with icon only and color background -->
<com.amit.ui.GoogleButton
android:layout_width="75dp"
android:layout_height="75dp"
app:iconSize="30dp"
app:roundedCorner="true"
app:roundedCornerRadius="75dp" />

<!-- With Rounded corners and text -->
<com.amit.ui.GoogleButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in with Google"
android:textAlignment="center"
android:textColor="@color/black"
app:iconCenterAligned="false"
app:iconSize="30dp"
app:roundedCorner="true" />

<!-- Square button with only icon -->
<com.amit.ui.GoogleButton
android:layout_width="75dp"
android:layout_height="75dp"
app:iconSize="30dp" />

<!-- Square button with transparent background -->
<com.amit.ui.GoogleButton
android:layout_width="75dp"
android:layout_height="75dp"
app:iconSize="30dp"
app:transparentBackground="true" />

<!-- Round button with transparent background -->
<com.amit.ui.GoogleButton
android:layout_width="75dp"
android:layout_height="75dp"
app:iconSize="30dp"
app:roundedCorner="true"
app:roundedCornerRadius="75dp"
app:transparentBackground="true" />
```

###Shine Button

>**Type of like button with some color explosion.**
**Usage**

```xml
<com.amit.shinebtn.ShineButton
android:id="@+id/shine_button"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="10dp"
android:src="@android:color/darker_gray"
app:allow_random_color="false"
app:big_shine_color="#FF6666"
app:btn_color="@android:color/darker_gray"
app:btn_fill_color="#FF6666"
app:click_animation_duration="200"
app:enable_flashing="false"
app:shine_animation_duration="1500"
app:shine_count="8"
app:shine_turn_angle="10"
app:siShape="@raw/heart"
app:small_shine_color="#CC9999"
app:small_shine_offset_angle="20" />
```

```
31 changes: 27 additions & 4 deletions app/src/main/java/com/amit/anim/AnimUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ public static void slideActivityFromUpWithStay(@NonNull Context context)
*
* @param context - context of the activity
**/
public static void slideFromBottomToUpAnim(@NonNull Context context)
public static void slideActivityFromBottomToUp(@NonNull Context context)
{
try
{
((Activity) context).overridePendingTransition(R.anim.bottom_to_up, R.anim.up_to_bottom1);
}
catch (Exception e)
{
Log.e(TAG, "slideFromBottomToUpAnim: exception while animating.");
Log.e(TAG, "slideActivityFromBottomToUp: exception while animating.");
e.printStackTrace();
}
}
Expand All @@ -180,15 +180,15 @@ public static void slideFromBottomToUpAnim(@NonNull Context context)
*
* @param context - context of the activity
**/
public static void slideFromUpToBottomAnim(@NonNull Context context)
public static void slideActivityFromUpToBottom(@NonNull Context context)
{
try
{
((Activity) context).overridePendingTransition(R.anim.up_to_bottom, R.anim.bottom_to_up1);
}
catch (Exception e)
{
Log.e(TAG, "slideFromUpToBottomAnim: exception while animating.");
Log.e(TAG, "slideActivityFromUpToBottom: exception while animating.");
e.printStackTrace();
}
}
Expand Down Expand Up @@ -311,4 +311,27 @@ public static void slideAnim(@NonNull Context context,
e.printStackTrace();
}
}

/**
* Bounce anim method
* this method will make a view bounce
*
* @param context - context of the application
* @param view - view to animate
**/
public static void bounceAnim(Context context, View view)
{
try
{
final Animation animation = AnimationUtils.loadAnimation(context, R.anim.bounce);
MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20);
animation.setInterpolator(interpolator);
view.startAnimation(animation);
}
catch (Exception e)
{
Log.e(TAG, "bounceAnim: exception while making bounce animation.");
e.printStackTrace();
}
}
}
20 changes: 20 additions & 0 deletions app/src/main/java/com/amit/anim/MyBounceInterpolator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.amit.anim;

import android.view.animation.Interpolator;

class MyBounceInterpolator implements Interpolator
{
private double mAmplitude = 1;
private double mFrequency = 10;

MyBounceInterpolator(double amplitude, double frequency)
{
this.mAmplitude = amplitude;
this.mFrequency = frequency;
}

public float getInterpolation(float time)
{
return (float) (-1 * Math.pow(Math.E, -time / mAmplitude) * Math.cos(mFrequency * time) + 1);
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/anim/bounce.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="2000"
android:fromXScale="0.3"
android:fromYScale="0.3"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>

0 comments on commit c20ed08

Please sign in to comment.