Skip to content

Commit c20ed08

Browse files
committed
Added bounce animation.
Updated README.md
1 parent e355988 commit c20ed08

File tree

4 files changed

+205
-14
lines changed

4 files changed

+205
-14
lines changed

README.md

Lines changed: 147 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
>**Add it in your root build.gradle at the end of repositories:**
1010
11-
```markdown
11+
```
1212
allprojects{
1313
repositories {
1414
...
@@ -19,16 +19,16 @@ allprojects{
1919

2020
#### Step 2. Add the dependency
2121

22-
```markdown
22+
```
2323
dependencies {
2424
...
25-
implementation 'com.github.amitjangid80:multiutillib:v1.2.6'
25+
implementation 'com.github.amitjangid80:multiutillib:v1.2.7'
2626
}
2727
```
2828

2929
#### Using maven:
3030

31-
```markdown
31+
```
3232
<repositories>
3333
<repository>
3434
<id>jitpack.io</id>
@@ -39,11 +39,11 @@ dependencies {
3939

4040
#### Step 2. Add the dependency
4141

42-
```markdown
42+
```
4343
<dependency>
4444
<groupId>com.github.amitjangid80</groupId>
4545
<artifactId>multiutillib</artifactId>
46-
<version>v1.2.6</version>
46+
<version>v1.2.7</version>
4747
<dependency>
4848
```
4949

@@ -75,7 +75,7 @@ public class ProjectApplication extends Application
7575

7676
### SharedPreferenceData
7777

78-
```markdown
78+
```java
7979
// use it in the activity or class you want to.
8080
SharedPreferenceData sharedPreferenceData = new SharedPreferenceData(context);
8181

@@ -613,7 +613,7 @@ UiUtils.setMaxLength(textInputEditText, maxLength);
613613
614614
**Usage**
615615

616-
```aidl
616+
```java
617617
/**
618618
* is Sd Card Mounted
619619
* this method will check if sd card is mounted or not
@@ -710,6 +710,143 @@ Utils.getSha512Hash(byte[] dataToHash);
710710
711711
**Usage**
712712

713-
```aidl
713+
```java
714+
715+
// for making an activity slide from right to left
716+
AnimUtil.slideActivityFromRightToLeft(context);
717+
718+
// for making an activity slide from left to right
719+
AnimUtil.slideActivityFromLeftToRight(context);
720+
721+
// for making an activity slide from right to left
722+
AnimUtil.slideActivityFromRightToLeft(context);
723+
724+
// for making an activity fade in fade out
725+
AnimUtil.activityFadeInFadeOut(context);
726+
727+
// for making an activity from left with stay
728+
AnimUtil.slideActivityFromLeftWithStay(context);
729+
730+
// for making an activity from right with stay
731+
AnimUtil.slideActivityFromRightWithStay(context);
732+
733+
// for making an activity bottom with stay
734+
AnimUtil.slideActivityFromBottomWithStay(context);
735+
736+
// for making an activity from top with stay
737+
AnimUtil.slideActivityFromUpWithStay(context);
738+
739+
// for making an activity from bottom to up
740+
AnimUtil.slideActivityFromBottomToUp(context);
741+
742+
// for making an activity from up to bottom
743+
AnimUtil.slideActivityFromUpToBottom(context);
744+
745+
// for making an activity from up to bottom
746+
AnimUtil.slideActivityFromUpToBottom(context);
747+
748+
// this method will make an view group to explode or rise
749+
AnimUtil.explodeTransition(Context context, ViewGroup viewGroup, int duration);
750+
751+
// this method will make and view to slide from right
752+
AnimUtil.slideAnimFromRight(@NonNull Context context, View view, int duration);
753+
754+
// this method will make and view to slide from left
755+
AnimUtil.slideAnimFromLeft(@NonNull Context context, View view, int duration);
756+
757+
// Use your own animation in this method the way you want.
758+
AnimUtil.slideAnim(@NonNull Context context, View view, int duration, @AnimRes int animResId);
759+
760+
// Use this method to make a button or a view bounce
761+
AnimUtil.bounceAnim(Context context, View view);
762+
```
763+
764+
###Social Buttons
765+
766+
>**Use Social buttons like you use normal button.**
767+
768+
**Usage**
769+
770+
```xml
771+
<!-- Currently Facebook, Google, Twitter, LinkedIn buttons are available. -->
772+
773+
<!-- Square button with icon and color background and normal usage -->
774+
<com.amit.ui.GoogleButton
775+
android:layout_width="match_parent"
776+
android:layout_height="wrap_content"
777+
android:text="Sign in with Google"
778+
android:textAlignment="center"
779+
android:textColor="@color/black"
780+
app:iconSize="30dp"
781+
app:iconPadding="30dp"
782+
tools:ignore="HardcodedText" />
783+
784+
<!-- Round Button with icon only and color background -->
785+
<com.amit.ui.GoogleButton
786+
android:layout_width="75dp"
787+
android:layout_height="75dp"
788+
app:iconSize="30dp"
789+
app:roundedCorner="true"
790+
app:roundedCornerRadius="75dp" />
791+
792+
<!-- With Rounded corners and text -->
793+
<com.amit.ui.GoogleButton
794+
android:layout_width="match_parent"
795+
android:layout_height="wrap_content"
796+
android:text="Sign in with Google"
797+
android:textAlignment="center"
798+
android:textColor="@color/black"
799+
app:iconCenterAligned="false"
800+
app:iconSize="30dp"
801+
app:roundedCorner="true" />
802+
803+
<!-- Square button with only icon -->
804+
<com.amit.ui.GoogleButton
805+
android:layout_width="75dp"
806+
android:layout_height="75dp"
807+
app:iconSize="30dp" />
808+
809+
<!-- Square button with transparent background -->
810+
<com.amit.ui.GoogleButton
811+
android:layout_width="75dp"
812+
android:layout_height="75dp"
813+
app:iconSize="30dp"
814+
app:transparentBackground="true" />
815+
816+
<!-- Round button with transparent background -->
817+
<com.amit.ui.GoogleButton
818+
android:layout_width="75dp"
819+
android:layout_height="75dp"
820+
app:iconSize="30dp"
821+
app:roundedCorner="true"
822+
app:roundedCornerRadius="75dp"
823+
app:transparentBackground="true" />
824+
```
825+
826+
###Shine Button
827+
828+
>**Type of like button with some color explosion.**
829+
830+
**Usage**
831+
832+
```xml
833+
<com.amit.shinebtn.ShineButton
834+
android:id="@+id/shine_button"
835+
android:layout_width="50dp"
836+
android:layout_height="50dp"
837+
android:layout_marginBottom="10dp"
838+
android:src="@android:color/darker_gray"
839+
app:allow_random_color="false"
840+
app:big_shine_color="#FF6666"
841+
app:btn_color="@android:color/darker_gray"
842+
app:btn_fill_color="#FF6666"
843+
app:click_animation_duration="200"
844+
app:enable_flashing="false"
845+
app:shine_animation_duration="1500"
846+
app:shine_count="8"
847+
app:shine_turn_angle="10"
848+
app:siShape="@raw/heart"
849+
app:small_shine_color="#CC9999"
850+
app:small_shine_offset_angle="20" />
851+
```
714852

715-
```

app/src/main/java/com/amit/anim/AnimUtil.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ public static void slideActivityFromUpWithStay(@NonNull Context context)
161161
*
162162
* @param context - context of the activity
163163
**/
164-
public static void slideFromBottomToUpAnim(@NonNull Context context)
164+
public static void slideActivityFromBottomToUp(@NonNull Context context)
165165
{
166166
try
167167
{
168168
((Activity) context).overridePendingTransition(R.anim.bottom_to_up, R.anim.up_to_bottom1);
169169
}
170170
catch (Exception e)
171171
{
172-
Log.e(TAG, "slideFromBottomToUpAnim: exception while animating.");
172+
Log.e(TAG, "slideActivityFromBottomToUp: exception while animating.");
173173
e.printStackTrace();
174174
}
175175
}
@@ -180,15 +180,15 @@ public static void slideFromBottomToUpAnim(@NonNull Context context)
180180
*
181181
* @param context - context of the activity
182182
**/
183-
public static void slideFromUpToBottomAnim(@NonNull Context context)
183+
public static void slideActivityFromUpToBottom(@NonNull Context context)
184184
{
185185
try
186186
{
187187
((Activity) context).overridePendingTransition(R.anim.up_to_bottom, R.anim.bottom_to_up1);
188188
}
189189
catch (Exception e)
190190
{
191-
Log.e(TAG, "slideFromUpToBottomAnim: exception while animating.");
191+
Log.e(TAG, "slideActivityFromUpToBottom: exception while animating.");
192192
e.printStackTrace();
193193
}
194194
}
@@ -311,4 +311,27 @@ public static void slideAnim(@NonNull Context context,
311311
e.printStackTrace();
312312
}
313313
}
314+
315+
/**
316+
* Bounce anim method
317+
* this method will make a view bounce
318+
*
319+
* @param context - context of the application
320+
* @param view - view to animate
321+
**/
322+
public static void bounceAnim(Context context, View view)
323+
{
324+
try
325+
{
326+
final Animation animation = AnimationUtils.loadAnimation(context, R.anim.bounce);
327+
MyBounceInterpolator interpolator = new MyBounceInterpolator(0.2, 20);
328+
animation.setInterpolator(interpolator);
329+
view.startAnimation(animation);
330+
}
331+
catch (Exception e)
332+
{
333+
Log.e(TAG, "bounceAnim: exception while making bounce animation.");
334+
e.printStackTrace();
335+
}
336+
}
314337
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.amit.anim;
2+
3+
import android.view.animation.Interpolator;
4+
5+
class MyBounceInterpolator implements Interpolator
6+
{
7+
private double mAmplitude = 1;
8+
private double mFrequency = 10;
9+
10+
MyBounceInterpolator(double amplitude, double frequency)
11+
{
12+
this.mAmplitude = amplitude;
13+
this.mFrequency = frequency;
14+
}
15+
16+
public float getInterpolation(float time)
17+
{
18+
return (float) (-1 * Math.pow(Math.E, -time / mAmplitude) * Math.cos(mFrequency * time) + 1);
19+
}
20+
}

app/src/main/res/anim/bounce.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
<scale
4+
android:duration="2000"
5+
android:fromXScale="0.3"
6+
android:fromYScale="0.3"
7+
android:pivotX="50%"
8+
android:pivotY="50%"
9+
android:toXScale="1.0"
10+
android:toYScale="1.0" />
11+
</set>

0 commit comments

Comments
 (0)