├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── bounceviewsample │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── bounceviewsample │ │ │ ├── CustomDialog.java │ │ │ ├── CustomPagerAdapter.java │ │ │ ├── FragmentCoolAnims.java │ │ │ ├── FragmentDialogs.java │ │ │ ├── FragmentRecyclerView.java │ │ │ ├── MainActivity.java │ │ │ └── RecyclerViewAdapter.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ ├── phone_forwarded_white_24x24.png │ │ ├── phone_missed_white_24x24.png │ │ └── phone_white_24x24.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── cool_anims_fragment.xml │ │ ├── custom_dialog.xml │ │ ├── custom_popup.xml │ │ ├── dialogs_fragment.xml │ │ ├── list_item.xml │ │ ├── recycler_view_fragment.xml │ │ └── tab_layout.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── bounceviewsample │ └── ExampleUnitTest.java ├── bounceview-android ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── github │ │ └── hariprasanths │ │ └── bounceview │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── hariprasanths │ │ │ └── bounceview │ │ │ ├── BounceView.java │ │ │ └── BounceViewAnim.java │ └── res │ │ ├── anim │ │ └── bounce_anim.xml │ │ └── values │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── github │ └── hariprasanths │ └── bounceview │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── scripts ├── publish-module.gradle └── publish-root.gradle └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | 11 | # IntelliJ IDEA 12 | .idea 13 | *.iml 14 | *.ipl 15 | *.iws 16 | classes/ 17 | idea-classes/ 18 | coverage-error.log 19 | 20 | # Android 21 | gen 22 | bin 23 | project.properties 24 | out -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bounceview-Android 2 | 3 | Customizable bounce animation for any view updation 4 | 5 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Bounceview--Android-green.svg?style=flat)](https://android-arsenal.com/details/1/7148) 6 | 7 |
8 | sample screenshot 9 |
10 | 11 | # Getting Started 12 |

In your build.gradle

13 | 14 | Maven Central 15 | ```groovy 16 | dependencies { 17 | implementation 'io.github.hariprasanths:bounceview-android:0.2.0' 18 | } 19 | ``` 20 | 21 | jcenter 22 | ```groovy 23 | dependencies { 24 | implementation 'hari.bounceview:bounceview:0.2.0' 25 | } 26 | ``` 27 | 28 |

Usage

29 | 30 |
Add animations to any views like so:
31 | 32 | ```java 33 | Button button = view.findViewById(R.id.button); 34 | BounceView.addAnimTo(button); 35 | ``` 36 | 37 |
Use BounceView with dialogs:
38 | 39 | ```java 40 | CustomDialog customDialog = new CustomDialog(getActivity()); 41 | //Add animation to custom dialog 42 | BounceView.addAnimTo(customDialog); //Call before showing the dialog 43 | customDialog.show(); 44 | 45 | PopupWindow popupWindow; 46 | ... 47 | //Add animation to popup window 48 | BounceView.addAnimTo(popupWindow); //Call before showing the popup 49 | popupWindow.showAtLocation(parentView, Gravity.CENTER, 0, 0); 50 | 51 | AlertDialog dialog = builder.create(); 52 | //Add animation to alert dialog 53 | BounceView.addAnimTo(dialog); //Call before showing the dialog 54 | dialog.show(); 55 | ``` 56 | 57 |
Some cool animations:
58 | 59 | ```java 60 | //Bounce animation 61 | BounceView.addAnimTo(button1) 62 | .setScaleForPopOutAnim(1.1f, 1.1f); 63 | 64 | //Horizontal flip animation 65 | BounceView.addAnimTo(button2) 66 | .setScaleForPopOutAnim(1f, 0f); 67 | 68 | //Vertical flip animation 69 | BounceView.addAnimTo(button3) 70 | .setScaleForPopOutAnim(0f, 1f); 71 | 72 | //Flicker animation 73 | BounceView.addAnimTo(button4) 74 | .setScaleForPopOutAnim(0f, 0f); 75 | ``` 76 | 77 |
Customize BounceView properties:
78 | 79 | ```java 80 | Button button = view.findViewById(R.id.button); 81 | BounceView.addAnimTo(button) 82 | //Default push in scalex: 0.9f , scaley: 0.9f 83 | .setScaleForPushInAnim(BounceView.PUSH_IN_SCALE_X, BounceView.PUSH_IN_SCALE_Y) 84 | //Default pop out scalex: 1.1f, scaley: 1.1f 85 | .setScaleForPopOutAnim(BounceView.POP_OUT_SCALE_X, BounceView.POP_OUT_SCALE_Y) 86 | //Default push in anim duration: 100 (in milliseconds) 87 | .setPushInAnimDuration(BounceView.PUSH_IN_ANIM_DURATION) 88 | //Default pop out anim duration: 100 (in milliseconds) 89 | .setPopOutAnimDuration(BounceView.POP_OUT_ANIM_DURATION) 90 | //Default interpolator: AccelerateDecelerateInterpolator() 91 | .setInterpolatorPushIn(BounceView.DEFAULT_INTERPOLATOR) 92 | .setInterpolatorPopOut(BounceView.DEFAULT_INTERPOLATOR); 93 | ``` 94 | 95 | ## Credits 96 | Inspired by and thanks to [TheKhaeng's Push Down Animation Click](https://github.com/TheKhaeng/pushdown-anim-click) 97 | 98 | ## Show your support 99 | 100 | Give a :star: if this project helped you! 101 | 102 | ## License 103 | 104 | Copyright :copyright: 2018 [Hariprasanth S](https://github.com/hariprasanths) 105 | 106 | This project is licensed under [the Apache License, Version 2.0](https://github.com/hariprasanths/Bounceview-Android/blob/master/LICENSE) 107 |
You may also obtain a copy of the License at 108 | 109 | http://www.apache.org/licenses/LICENSE-2.0 -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 30 5 | defaultConfig { 6 | applicationId "hari.bounceviewsample" 7 | minSdkVersion 15 8 | targetSdkVersion 30 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'androidx.appcompat:appcompat:1.1.0' 24 | implementation 'com.google.android.material:material:1.1.0' 25 | implementation 'androidx.annotation:annotation:1.1.0' 26 | testImplementation 'junit:junit:4.12' 27 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 28 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 29 | androidTestImplementation 'androidx.annotation:annotation:1.1.0' 30 | // implementation 'io.github.hariprasanths:bounceview-android:0.2.0' 31 | implementation(project(':bounceview-android')) 32 | } 33 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/bounceviewsample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("hari.bounceviewsample", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/CustomDialog.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.app.Activity; 4 | import android.app.Dialog; 5 | import android.os.Build; 6 | import android.os.Bundle; 7 | import androidx.annotation.RequiresApi; 8 | import android.view.View; 9 | import android.view.Window; 10 | import android.view.WindowManager; 11 | import android.widget.Button; 12 | 13 | import com.github.hariprasanths.bounceview.BounceView; 14 | 15 | /** 16 | * Created by hari on 8/6/18. 17 | */ 18 | 19 | public class CustomDialog extends Dialog implements 20 | View.OnClickListener { 21 | 22 | public Activity c; 23 | public Dialog d; 24 | public Button yes, no; 25 | 26 | public CustomDialog(Activity a) { 27 | super(a); 28 | this.c = a; 29 | } 30 | 31 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) 32 | @Override 33 | protected void onStart() { 34 | super.onStart(); 35 | } 36 | 37 | @Override 38 | protected void onCreate(Bundle savedInstanceState) { 39 | super.onCreate(savedInstanceState); 40 | requestWindowFeature(Window.FEATURE_NO_TITLE); 41 | setContentView(R.layout.custom_dialog); 42 | yes = (Button) findViewById(R.id.btn_yes); 43 | no = (Button) findViewById(R.id.btn_no); 44 | 45 | BounceView.addAnimTo(yes); 46 | BounceView.addAnimTo(no); 47 | 48 | yes.setOnClickListener(this); 49 | no.setOnClickListener(this); 50 | 51 | WindowManager.LayoutParams lp = getWindow().getAttributes(); 52 | lp.dimAmount = 0.0F; 53 | getWindow().setAttributes(lp); 54 | 55 | } 56 | 57 | @Override 58 | public void onClick(View v) { 59 | switch (v.getId()) { 60 | case R.id.btn_yes: 61 | c.finish(); 62 | break; 63 | case R.id.btn_no: 64 | dismiss(); 65 | break; 66 | default: 67 | break; 68 | } 69 | dismiss(); 70 | } 71 | } -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/CustomPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import androidx.fragment.app.Fragment; 4 | import androidx.fragment.app.FragmentManager; 5 | import androidx.fragment.app.FragmentPagerAdapter; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by hari on 8/6/18. 12 | */ 13 | 14 | public class CustomPagerAdapter extends FragmentPagerAdapter { 15 | 16 | private List mFragments; 17 | private List mFragmentTitles; 18 | 19 | public CustomPagerAdapter(FragmentManager fm) { 20 | super(fm); 21 | mFragments = new ArrayList<>(); 22 | mFragmentTitles = new ArrayList<>(); 23 | } 24 | 25 | public void addFragment(Fragment fragment, String title) { 26 | mFragments.add(fragment); 27 | mFragmentTitles.add(title); 28 | } 29 | 30 | public void addFragmentsList(List fragments, List titles) { 31 | mFragments = fragments; 32 | mFragmentTitles = titles; 33 | } 34 | 35 | @Override 36 | public Fragment getItem(int position) { 37 | return mFragments.get(position); 38 | } 39 | 40 | @Override 41 | public int getCount() { 42 | return mFragments.size(); 43 | } 44 | 45 | @Override 46 | public CharSequence getPageTitle(int position) { 47 | return mFragmentTitles.get(position); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/FragmentCoolAnims.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.os.Bundle; 4 | import androidx.fragment.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.Button; 9 | import android.widget.TextView; 10 | 11 | import com.github.hariprasanths.bounceview.BounceView; 12 | 13 | /** 14 | * Created by hari on 8/6/18. 15 | */ 16 | 17 | public class FragmentCoolAnims extends Fragment { 18 | 19 | TextView titleView; 20 | 21 | public FragmentCoolAnims() { 22 | super(); 23 | } 24 | 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 27 | 28 | View view = inflater.inflate(R.layout.cool_anims_fragment, container, false); 29 | String title = "Fragment"; 30 | if (getArguments() != null) { 31 | title = getArguments().getString("title"); 32 | } 33 | titleView = view.findViewById(R.id.fragmentTitle); 34 | titleView.setText(title); 35 | 36 | Button button1 = view.findViewById(R.id.button1); 37 | Button button2 = view.findViewById(R.id.button2); 38 | Button button3 = view.findViewById(R.id.button3); 39 | Button button4 = view.findViewById(R.id.button4); 40 | 41 | button1.setOnClickListener(new View.OnClickListener() { 42 | @Override 43 | public void onClick(View v) { 44 | //Do something here 45 | } 46 | }); 47 | 48 | //Bounce animation 49 | BounceView.addAnimTo(button1) 50 | .setScaleForPushInAnim(BounceView.PUSH_IN_SCALE_X, BounceView.PUSH_IN_SCALE_Y) 51 | .setScaleForPopOutAnim(BounceView.POP_OUT_SCALE_X, BounceView.POP_OUT_SCALE_Y) 52 | .setPushInAnimDuration(BounceView.PUSH_IN_ANIM_DURATION) 53 | .setPopOutAnimDuration(BounceView.POP_OUT_ANIM_DURATION) 54 | .setInterpolatorPushIn(BounceView.DEFAULT_INTERPOLATOR) 55 | .setInterpolatorPopOut(BounceView.DEFAULT_INTERPOLATOR); 56 | 57 | //Horizontal flip animation 58 | BounceView.addAnimTo(button2) 59 | .setScaleForPopOutAnim(1f, 0f); 60 | 61 | //Vertical flip animation 62 | BounceView.addAnimTo(button3) 63 | .setScaleForPopOutAnim(0f, 1f); 64 | 65 | //Flicker animation 66 | BounceView.addAnimTo(button4) 67 | .setScaleForPopOutAnim(0f, 0f); 68 | 69 | 70 | return view; 71 | } 72 | 73 | public static FragmentCoolAnims newInstance(String title) { 74 | 75 | Bundle args = new Bundle(); 76 | args.putString("title", title); 77 | FragmentCoolAnims fragment = new FragmentCoolAnims(); 78 | fragment.setArguments(args); 79 | return fragment; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/FragmentDialogs.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.content.DialogInterface; 4 | import android.graphics.drawable.BitmapDrawable; 5 | import android.os.Bundle; 6 | import androidx.fragment.app.Fragment; 7 | import androidx.appcompat.app.AlertDialog; 8 | import android.view.Gravity; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.Button; 13 | import android.widget.LinearLayout; 14 | import android.widget.PopupWindow; 15 | import android.widget.TextView; 16 | 17 | import com.github.hariprasanths.bounceview.BounceView; 18 | 19 | /** 20 | * Created by hari on 8/6/18. 21 | */ 22 | 23 | public class FragmentDialogs extends Fragment { 24 | 25 | TextView titleView; 26 | 27 | public FragmentDialogs() { 28 | super(); 29 | } 30 | 31 | @Override 32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 33 | 34 | final View view = inflater.inflate(R.layout.dialogs_fragment, container, false); 35 | String title = "Fragment"; 36 | if (getArguments() != null) { 37 | title = getArguments().getString("title"); 38 | } 39 | titleView = view.findViewById(R.id.fragmentTitle); 40 | titleView.setText(title); 41 | 42 | Button button1 = view.findViewById(R.id.button1); 43 | Button button2 = view.findViewById(R.id.button2); 44 | Button button3 = view.findViewById(R.id.button3); 45 | 46 | //Add animation to the buttons 47 | BounceView.addAnimTo(button1); 48 | BounceView.addAnimTo(button2); 49 | BounceView.addAnimTo(button3); 50 | 51 | button1.setOnClickListener(new View.OnClickListener() { 52 | @Override 53 | public void onClick(View v) { 54 | CustomDialog customDialog = new CustomDialog(getActivity()); 55 | 56 | //Add animation to custom dialog 57 | BounceView.addAnimTo(customDialog); //Call before showing the dialog 58 | 59 | customDialog.show(); 60 | } 61 | }); 62 | 63 | button2.setOnClickListener(new View.OnClickListener() { 64 | @Override 65 | public void onClick(View v) { 66 | PopupWindow popupWindow; 67 | View menuView = getLayoutInflater().inflate(R.layout.custom_popup, null); 68 | popupWindow = new PopupWindow(menuView, LinearLayout.LayoutParams.WRAP_CONTENT, 69 | LinearLayout.LayoutParams.WRAP_CONTENT, false); 70 | int[] location = new int[2]; 71 | view.getLocationOnScreen(location); 72 | popupWindow.setBackgroundDrawable(new BitmapDrawable()); 73 | popupWindow.setOutsideTouchable(true); 74 | 75 | //Add animation to popup window 76 | BounceView.addAnimTo(popupWindow); //Call before showing the popup 77 | 78 | popupWindow.showAtLocation(view, Gravity.CENTER, 79 | 0, 0); 80 | 81 | } 82 | }); 83 | 84 | button3.setOnClickListener(new View.OnClickListener() { 85 | @Override 86 | public void onClick(View v) { 87 | DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { 88 | @Override 89 | public void onClick(DialogInterface dialog, int which) { 90 | switch (which) { 91 | case DialogInterface.BUTTON_POSITIVE: 92 | getActivity().finish(); 93 | break; 94 | 95 | case DialogInterface.BUTTON_NEGATIVE: 96 | dialog.dismiss(); 97 | break; 98 | } 99 | } 100 | }; 101 | 102 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); 103 | builder.setTitle("Alert Dialog") 104 | .setMessage("Do you want to exit?") 105 | .setPositiveButton("Yes", dialogClickListener) 106 | .setNegativeButton("No", dialogClickListener); 107 | AlertDialog dialog = builder.create(); 108 | 109 | //Add animation to alert dialog 110 | BounceView.addAnimTo(dialog); //Call before showing the dialog 111 | 112 | dialog.show(); 113 | } 114 | }); 115 | 116 | return view; 117 | } 118 | 119 | public static FragmentDialogs newInstance(String title) { 120 | 121 | Bundle args = new Bundle(); 122 | args.putString("title", title); 123 | FragmentDialogs fragment = new FragmentDialogs(); 124 | fragment.setArguments(args); 125 | return fragment; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/FragmentRecyclerView.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import androidx.fragment.app.Fragment; 6 | import androidx.recyclerview.widget.LinearLayoutManager; 7 | import androidx.recyclerview.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | /** 17 | * Created by hari on 8/6/18. 18 | */ 19 | 20 | public class FragmentRecyclerView extends Fragment { 21 | 22 | Context context; 23 | TextView titleView; 24 | RecyclerView recyclerView; 25 | List list; 26 | 27 | RecyclerViewAdapter adapter; 28 | 29 | public FragmentRecyclerView() { 30 | super(); 31 | } 32 | 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 35 | 36 | View view = inflater.inflate(R.layout.recycler_view_fragment, container, false); 37 | String title = "Fragment"; 38 | if (getArguments() != null) { 39 | title = getArguments().getString("title"); 40 | } 41 | titleView = view.findViewById(R.id.fragmentTitle); 42 | recyclerView = view.findViewById(R.id.recyclerView); 43 | titleView.setText(title); 44 | 45 | list = new ArrayList<>(); 46 | list.add("Item 1"); 47 | list.add("Item 2"); 48 | list.add("Item 3"); 49 | list.add("Item 4"); 50 | 51 | adapter = new RecyclerViewAdapter(getContext(), list); 52 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); 53 | recyclerView.setAdapter(adapter); 54 | return view; 55 | } 56 | 57 | public static FragmentRecyclerView newInstance(String title) { 58 | 59 | Bundle args = new Bundle(); 60 | args.putString("title", title); 61 | FragmentRecyclerView fragment = new FragmentRecyclerView(); 62 | fragment.setArguments(args); 63 | return fragment; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import com.google.android.material.tabs.TabLayout; 6 | import androidx.viewpager.widget.ViewPager; 7 | import androidx.appcompat.app.AppCompatActivity; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.TextView; 12 | 13 | import com.github.hariprasanths.bounceview.BounceView; 14 | 15 | public class MainActivity extends AppCompatActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | 22 | 23 | final ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); 24 | 25 | final TabLayout tabLayout = findViewById(R.id.tabs); 26 | 27 | if (viewPager != null) { 28 | setupViewPager(viewPager); 29 | tabLayout.setupWithViewPager(viewPager); 30 | } 31 | 32 | //Add animation to tabs in the tab layout 33 | BounceView.addAnimTo(tabLayout); 34 | 35 | tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { 36 | @Override 37 | public void onTabSelected(TabLayout.Tab tab) { 38 | View tabView = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(tab.getPosition()); 39 | tabView.setBackgroundColor(Color.parseColor("#404e4e")); 40 | } 41 | 42 | @Override 43 | public void onTabUnselected(TabLayout.Tab tab) { 44 | View tabView = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(tab.getPosition()); 45 | tabView.setBackgroundColor(Color.parseColor("#5a7374")); 46 | } 47 | 48 | @Override 49 | public void onTabReselected(TabLayout.Tab tab) { 50 | } 51 | }); 52 | 53 | int[] iconsList = {R.drawable.phone_white_24x24, R.drawable.phone_forwarded_white_24x24, R.drawable.phone_missed_white_24x24}; 54 | 55 | for (int i = 0; i < tabLayout.getTabCount(); i++) { 56 | 57 | final TabLayout.Tab tab = tabLayout.getTabAt(i); 58 | View tabView = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(i); 59 | 60 | TextView tabTabText = (TextView) LayoutInflater.from(this).inflate(R.layout.tab_layout, null); 61 | tabTabText.setText("Tab " + (i + 1)); 62 | tabTabText.setCompoundDrawablesWithIntrinsicBounds(0, iconsList[i], 0, 0); 63 | tabLayout.getTabAt(i).setCustomView(tabTabText); 64 | 65 | if (tab.isSelected()) { 66 | tabView.setBackgroundColor(Color.parseColor("#404e4e")); 67 | } else { 68 | tabView.setBackgroundColor(Color.parseColor("#5a7374")); 69 | } 70 | } 71 | } 72 | 73 | private void setupViewPager(ViewPager viewPager) { 74 | 75 | CustomPagerAdapter adapter = new CustomPagerAdapter(getSupportFragmentManager()); 76 | 77 | adapter.addFragment(FragmentRecyclerView.newInstance("Recycler View"), "Recycler View"); 78 | adapter.addFragment(FragmentDialogs.newInstance("Dialogs"), "Dialogs"); 79 | adapter.addFragment(FragmentCoolAnims.newInstance("Cool anims"), "Cool anims"); 80 | 81 | viewPager.setAdapter(adapter); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/bounceviewsample/RecyclerViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.bounceviewsample; 2 | 3 | import android.content.Context; 4 | import androidx.recyclerview.widget.RecyclerView; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.RelativeLayout; 9 | import android.widget.TextView; 10 | import android.widget.Toast; 11 | 12 | import java.util.List; 13 | 14 | import com.github.hariprasanths.bounceview.BounceView; 15 | 16 | /** 17 | * Created by hari on 8/6/18. 18 | */ 19 | 20 | public class RecyclerViewAdapter extends RecyclerView.Adapter{ 21 | Context context; 22 | List menus; 23 | boolean isOutside = false; 24 | 25 | public RecyclerViewAdapter(Context context, List list) { 26 | this.context = context; 27 | this.menus = list; 28 | } 29 | 30 | @Override 31 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 32 | View view = LayoutInflater.from(context).inflate(R.layout.list_item,parent,false); 33 | return new ViewHolder(view); 34 | } 35 | 36 | @Override 37 | public void onBindViewHolder(final ViewHolder holder, final int position) { 38 | 39 | holder.textView.setText(menus.get(position)); 40 | 41 | //Add animation to a view inside recycler view 42 | BounceView.addAnimTo(holder.listItem) 43 | .setPopOutAnimDuration(150) 44 | .setScaleForPushInAnim(.95f,.9f) 45 | .setScaleForPopOutAnim(1.05f,1.1f); 46 | 47 | } 48 | 49 | @Override 50 | public int getItemCount() { 51 | return menus.size(); 52 | } 53 | 54 | public class ViewHolder extends RecyclerView.ViewHolder { 55 | 56 | RelativeLayout listItem; 57 | TextView textView; 58 | 59 | public ViewHolder(View view) { 60 | super(view); 61 | listItem = view.findViewById(R.id.relativeLayoutListItem); 62 | textView = view.findViewById(R.id.textViewListItem); 63 | } 64 | } 65 | 66 | void onClickListItem(View view, int position) { 67 | Toast.makeText(context, menus.get(position) + " clicked",Toast.LENGTH_SHORT).show(); 68 | } 69 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/phone_forwarded_white_24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/drawable/phone_forwarded_white_24x24.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/phone_missed_white_24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/drawable/phone_missed_white_24x24.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/phone_white_24x24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/drawable/phone_white_24x24.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 17 | 18 | 26 | 27 | 28 | 29 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/layout/cool_anims_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 18 | 26 | 27 | 28 | 29 | 30 | 31 | 38 | 39 |