├── .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 | [](https://android-arsenal.com/details/1/7148)
6 |
7 |
8 |
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 |
48 |
49 |
58 |
59 |
68 |
69 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
23 |
24 |
35 |
36 |
45 |
46 |
55 |
56 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_popup.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialogs_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
26 |
27 |
28 |
29 |
30 |
31 |
38 |
39 |
48 |
49 |
58 |
59 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/recycler_view_fragment.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/tab_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #5a7374
4 | #404e4e
5 | #d21e1e
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BounceView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/bounceviewsample/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.bounceviewsample;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/bounceview-android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/bounceview-android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'bounceview'
6 |
7 | publishedGroupId = 'io.github.hariprasanths'
8 | libraryName = 'bounceview-android'
9 | artifact = 'bounceview'
10 |
11 | libraryDescription = 'Customizable bounce animation for any view updation'
12 |
13 | siteUrl = 'https://github.com/hariprasanths/Bounceview-Android'
14 | gitUrl = 'https://github.com/hariprasanths/Bounceview-Android.git'
15 |
16 | libraryVersion = '0.2.0'
17 |
18 | developerId = 'hariprasanths'
19 | developerName = 'Hariprasanth S'
20 | developerEmail = 'shhariprasanth@gmail.com'
21 |
22 | licenseName = 'The Apache Software License, Version 2.0'
23 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
24 | allLicenses = ["Apache-2.0"]
25 |
26 | PUBLISH_GROUP_ID = publishedGroupId
27 | PUBLISH_VERSION = libraryVersion
28 | PUBLISH_ARTIFACT_ID = libraryName
29 | }
30 |
31 | apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"
32 |
33 | android {
34 | compileSdkVersion 30
35 |
36 | defaultConfig {
37 | minSdkVersion 15
38 | targetSdkVersion 30
39 | versionCode 1
40 | versionName "1.0"
41 |
42 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
43 |
44 | }
45 |
46 | buildTypes {
47 | release {
48 | minifyEnabled false
49 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
50 | }
51 | }
52 |
53 | }
54 |
55 | dependencies {
56 | implementation fileTree(dir: 'libs', include: ['*.jar'])
57 |
58 | implementation 'androidx.appcompat:appcompat:1.2.0'
59 | implementation 'com.google.android.material:material:1.3.0'
60 | testImplementation 'junit:junit:4.12'
61 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
62 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
63 | }
64 |
65 | group = publishedGroupId // Maven Group ID for the artifact
66 | version = libraryVersion
--------------------------------------------------------------------------------
/bounceview-android/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 |
--------------------------------------------------------------------------------
/bounceview-android/src/androidTest/java/com/github/hariprasanths/bounceview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.github.hariprasanths.bounceview;
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("com.github.hariprasanths.bounceview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/java/com/github/hariprasanths/bounceview/BounceView.java:
--------------------------------------------------------------------------------
1 | package com.github.hariprasanths.bounceview;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.ObjectAnimator;
5 | import android.app.Dialog;
6 | import com.google.android.material.tabs.TabLayout;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.Window;
11 | import android.view.animation.AccelerateDecelerateInterpolator;
12 | import android.widget.PopupWindow;
13 |
14 | import java.lang.ref.WeakReference;
15 |
16 | /**
17 | * Created by hari on 7/6/18.
18 | */
19 |
20 | public class BounceView implements BounceViewAnim {
21 |
22 | public static final float PUSH_IN_SCALE_X = 0.9f;
23 | public static final float PUSH_IN_SCALE_Y = 0.9f;
24 | public static final float POP_OUT_SCALE_X = 1.1f;
25 | public static final float POP_OUT_SCALE_Y = 1.1f;
26 | public static final int PUSH_IN_ANIM_DURATION = 100;
27 | public static final int POP_OUT_ANIM_DURATION = 100;
28 | public static final AccelerateDecelerateInterpolator DEFAULT_INTERPOLATOR
29 | = new AccelerateDecelerateInterpolator();
30 |
31 | private WeakReference view;
32 | private WeakReference dialog;
33 | private WeakReference popup;
34 | private WeakReference tabLayout;
35 | private boolean isTouchInsideView = true;
36 | private float pushInScaleX = PUSH_IN_SCALE_X;
37 | private float pushInScaleY = PUSH_IN_SCALE_Y;
38 | private float popOutScaleX = POP_OUT_SCALE_X;
39 | private float popOutScaleY = POP_OUT_SCALE_Y;
40 | private int pushInAnimDuration = PUSH_IN_ANIM_DURATION;
41 | private int popOutAnimDuration = POP_OUT_ANIM_DURATION;
42 | private AccelerateDecelerateInterpolator pushInInterpolator = DEFAULT_INTERPOLATOR;
43 | private AccelerateDecelerateInterpolator popOutInterpolator = DEFAULT_INTERPOLATOR;
44 |
45 | private BounceView(View view) {
46 | this.view = new WeakReference(view);
47 | if (this.view.get() != null) {
48 | if(!this.view.get().hasOnClickListeners()) {
49 | this.view.get().setOnClickListener(new View.OnClickListener() {
50 | @Override
51 | public void onClick(View v) {
52 |
53 | }
54 | });
55 | }
56 | }
57 | }
58 |
59 | private BounceView(Dialog dialog) {
60 | this.dialog = new WeakReference(dialog);
61 | }
62 |
63 | private BounceView(PopupWindow popup) {
64 | this.popup = new WeakReference(popup);
65 | }
66 |
67 | private BounceView(TabLayout tabLayout) {
68 | this.tabLayout = new WeakReference(tabLayout);
69 | }
70 |
71 |
72 | public static BounceView addAnimTo(View view) {
73 | BounceView bounceAnim = new BounceView(view);
74 | bounceAnim.setAnimToView();
75 | return bounceAnim;
76 | }
77 |
78 | public static void addAnimTo(Dialog dialog) {
79 | BounceView bounceAnim = new BounceView(dialog);
80 | bounceAnim.setAnimToDialog();
81 | }
82 |
83 | public static void addAnimTo(PopupWindow popupWindow) {
84 | BounceView bounceAnim = new BounceView(popupWindow);
85 | bounceAnim.setAnimToPopup();
86 | }
87 |
88 | public static BounceView addAnimTo(TabLayout tabLayout) {
89 | BounceView bounceAnim = new BounceView(tabLayout);
90 | bounceAnim.setAnimToTabLayout();
91 | return bounceAnim;
92 | }
93 |
94 | @Override
95 | public BounceViewAnim setScaleForPushInAnim(float scaleX, float scaleY) {
96 | this.pushInScaleX = scaleX;
97 | this.pushInScaleY = scaleY;
98 | return this;
99 | }
100 |
101 | @Override
102 | public BounceViewAnim setScaleForPopOutAnim(float scaleX, float scaleY) {
103 | this.popOutScaleX = scaleX;
104 | this.popOutScaleY = scaleY;
105 | return this;
106 | }
107 |
108 | @Override
109 | public BounceViewAnim setPushInAnimDuration(int timeInMillis) {
110 | this.pushInAnimDuration = timeInMillis;
111 | return this;
112 | }
113 |
114 | @Override
115 | public BounceViewAnim setPopOutAnimDuration(int timeInMillis) {
116 | this.popOutAnimDuration = timeInMillis;
117 | return this;
118 | }
119 |
120 | @Override
121 | public BounceViewAnim setInterpolatorPushIn(AccelerateDecelerateInterpolator interpolatorPushIn) {
122 | this.pushInInterpolator = interpolatorPushIn;
123 | return this;
124 | }
125 |
126 | @Override
127 | public BounceViewAnim setInterpolatorPopOut(AccelerateDecelerateInterpolator interpolatorPopOut) {
128 | this.popOutInterpolator = interpolatorPopOut;
129 | return this;
130 | }
131 |
132 | private void setAnimToView() {
133 | if (view != null) {
134 | view.get().setOnTouchListener(new View.OnTouchListener() {
135 | @Override
136 | public boolean onTouch(final View v, MotionEvent motionEvent) {
137 | int action = motionEvent.getAction();
138 |
139 | if (action == MotionEvent.ACTION_DOWN) {
140 | isTouchInsideView = true;
141 |
142 | startAnimScale(v, pushInScaleX, pushInScaleY, pushInAnimDuration, pushInInterpolator, 0);
143 |
144 | } else if (action == MotionEvent.ACTION_UP) {
145 | if (isTouchInsideView) {
146 | v.animate().cancel();
147 |
148 | startAnimScale(v, popOutScaleX, popOutScaleY, popOutAnimDuration, popOutInterpolator, 0);
149 |
150 | startAnimScale(v, 1f, 1f, popOutAnimDuration, popOutInterpolator, popOutAnimDuration + 1);
151 |
152 | return false;
153 | }
154 | } else if (action == MotionEvent.ACTION_CANCEL) {
155 | if (isTouchInsideView) {
156 | v.animate().cancel();
157 |
158 | startAnimScale(v, 1f, 1f, popOutAnimDuration, DEFAULT_INTERPOLATOR, 0);
159 |
160 | }
161 |
162 | return true;
163 | } else if (action == MotionEvent.ACTION_MOVE) {
164 | if (isTouchInsideView) {
165 | float currentX = motionEvent.getX();
166 | float currentY = motionEvent.getY();
167 | float currentPosX = currentX + v.getLeft();
168 | float currentPosY = currentY + v.getTop();
169 | float viewLeft = v.getLeft();
170 | float viewTop = v.getTop();
171 | float viewRight = v.getRight();
172 | float viewBottom = v.getBottom();
173 | if (!(currentPosX > viewLeft && currentPosX < viewRight
174 | && currentPosY > viewTop && currentPosY < viewBottom)) {
175 | isTouchInsideView = false;
176 | v.animate().cancel();
177 |
178 | startAnimScale(v, 1f, 1f, popOutAnimDuration, DEFAULT_INTERPOLATOR, 0);
179 | }
180 |
181 | return true;
182 | }
183 | }
184 |
185 | return false;
186 | }
187 | });
188 | }
189 | }
190 |
191 | private void startAnimScale(View view, float scaleX, float scaleY,
192 | int animDuration,
193 | AccelerateDecelerateInterpolator interpolator,
194 | int startDelay) {
195 | ObjectAnimator animX = ObjectAnimator.ofFloat(view, "scaleX", scaleX);
196 | ObjectAnimator animY = ObjectAnimator.ofFloat(view, "scaleY", scaleY);
197 | AnimatorSet animatorSet = new AnimatorSet();
198 | animX.setDuration(animDuration);
199 | animX.setInterpolator(interpolator);
200 | animY.setDuration(animDuration);
201 | animY.setInterpolator(interpolator);
202 |
203 | animatorSet.playTogether(animX, animY);
204 | animatorSet.setStartDelay(startDelay);
205 | animatorSet.start();
206 | }
207 |
208 | private void setAnimToDialog() {
209 | if (dialog.get() != null) {
210 | Window dialogWindow = dialog.get().getWindow();
211 | dialogWindow.setWindowAnimations(R.style.CustomDialogAnimation);
212 | }
213 | }
214 |
215 | private void setAnimToPopup() {
216 | if (popup.get() != null) {
217 | popup.get().setAnimationStyle(R.style.CustomDialogAnimation);
218 | }
219 | }
220 |
221 | private void setAnimToTabLayout() {
222 | if (tabLayout.get() != null) {
223 |
224 | for(int i = 0; i < tabLayout.get().getTabCount(); i++) {
225 |
226 | final TabLayout.Tab tab = tabLayout.get().getTabAt(i);
227 | View tabView = ((ViewGroup) tabLayout.get().getChildAt(0)).getChildAt(i);
228 |
229 | tabView.setOnTouchListener(new View.OnTouchListener() {
230 | @Override
231 | public boolean onTouch(View v, MotionEvent motionEvent) {
232 |
233 | int action = motionEvent.getAction();
234 |
235 | if (action == MotionEvent.ACTION_DOWN) {
236 | isTouchInsideView = true;
237 |
238 | startAnimScale(v, pushInScaleX, pushInScaleY, pushInAnimDuration, pushInInterpolator, 0);
239 |
240 | return true;
241 |
242 | } else if (action == MotionEvent.ACTION_UP) {
243 | if (isTouchInsideView) {
244 | v.animate().cancel();
245 |
246 | startAnimScale(v, popOutScaleX, popOutScaleY, popOutAnimDuration, popOutInterpolator, 0);
247 |
248 | startAnimScale(v, 1f, 1f, popOutAnimDuration, popOutInterpolator, popOutAnimDuration + 1);
249 |
250 | tab.select();
251 |
252 | return false;
253 | }
254 | } else if (action == MotionEvent.ACTION_CANCEL) {
255 | if (isTouchInsideView) {
256 | v.animate().cancel();
257 |
258 | startAnimScale(v, 1f, 1f, popOutAnimDuration, DEFAULT_INTERPOLATOR, 0);
259 |
260 | }
261 |
262 | return true;
263 | } else if (action == MotionEvent.ACTION_MOVE) {
264 | if (isTouchInsideView) {
265 | float currentX = motionEvent.getX();
266 | float currentY = motionEvent.getY();
267 | float currentPosX = currentX + v.getLeft();
268 | float currentPosY = currentY + v.getTop();
269 | float viewLeft = v.getLeft();
270 | float viewTop = v.getTop();
271 | float viewRight = v.getRight();
272 | float viewBottom = v.getBottom();
273 | if (!(currentPosX > viewLeft && currentPosX < viewRight
274 | && currentPosY > viewTop && currentPosY < viewBottom)) {
275 | isTouchInsideView = false;
276 | v.animate().cancel();
277 |
278 | startAnimScale(v, 1f, 1f, popOutAnimDuration, DEFAULT_INTERPOLATOR, 0);
279 | }
280 |
281 | return true;
282 | }
283 | }
284 |
285 | return false;
286 | }
287 | });
288 | }
289 | }
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/java/com/github/hariprasanths/bounceview/BounceViewAnim.java:
--------------------------------------------------------------------------------
1 | package com.github.hariprasanths.bounceview;
2 |
3 | import android.view.animation.AccelerateDecelerateInterpolator;
4 |
5 | /**
6 | * Created by hari on 7/6/18.
7 | */
8 |
9 | public interface BounceViewAnim {
10 |
11 | BounceViewAnim setScaleForPushInAnim(float scaleX, float scaleY);
12 |
13 | BounceViewAnim setScaleForPopOutAnim(float scaleX, float scaleY);
14 |
15 | BounceViewAnim setPushInAnimDuration(int timeInMillis);
16 |
17 | BounceViewAnim setPopOutAnimDuration(int timeInMillis);
18 |
19 | BounceViewAnim setInterpolatorPushIn(AccelerateDecelerateInterpolator interpolatorPushIn);
20 |
21 | BounceViewAnim setInterpolatorPopOut(AccelerateDecelerateInterpolator interpolatorPopOut);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/res/anim/bounce_anim.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
25 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | bounceview
3 |
4 |
--------------------------------------------------------------------------------
/bounceview-android/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/bounceview-android/src/test/java/com/github/hariprasanths/bounceview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.github.hariprasanths.bounceview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 |
4 | buildscript {
5 |
6 | repositories {
7 | google()
8 | mavenCentral()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:4.2.0'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | plugins {
19 | id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
20 | id("org.jetbrains.dokka") version "1.4.32"
21 | }
22 |
23 | apply from: "${rootDir}/scripts/publish-root.gradle"
24 |
25 | allprojects {
26 | repositories {
27 | google()
28 | mavenCentral()
29 | }
30 | }
31 |
32 | task clean(type: Delete) {
33 | delete rootProject.buildDir
34 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hariprasanths/Bounceview-Android/82b08e46f5c8cab2377b13901572f9576ed83d36/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun May 09 21:15:42 IST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/scripts/publish-module.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 | apply plugin: 'org.jetbrains.dokka'
4 |
5 | task androidSourcesJar(type: Jar) {
6 | archiveClassifier.set('sources')
7 | if (project.plugins.findPlugin("com.android.library")) {
8 | // For Android libraries
9 | from android.sourceSets.main.java.srcDirs
10 | // from android.sourceSets.main.kotlin.srcDirs
11 | } else {
12 | // For pure Kotlin libraries, in case you have them
13 | from sourceSets.main.java.srcDirs
14 | from sourceSets.main.kotlin.srcDirs
15 | }
16 | }
17 |
18 | tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
19 | pluginsMapConfiguration.set(
20 | ["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
21 | )
22 | }
23 |
24 | task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
25 | archiveClassifier.set('javadoc')
26 | from dokkaJavadoc.outputDirectory
27 | }
28 |
29 | artifacts {
30 | archives androidSourcesJar
31 | archives javadocJar
32 | }
33 |
34 | group = PUBLISH_GROUP_ID
35 | version = PUBLISH_VERSION
36 |
37 | afterEvaluate {
38 | publishing {
39 | publications {
40 | release(MavenPublication) {
41 | // The coordinates of the library, being set from variables that
42 | // we'll set up later
43 | groupId PUBLISH_GROUP_ID
44 | artifactId PUBLISH_ARTIFACT_ID
45 | version PUBLISH_VERSION
46 |
47 | // Two artifacts, the `aar` (or `jar`) and the sources
48 | if (project.plugins.findPlugin("com.android.library")) {
49 | from components.release
50 | } else {
51 | artifact("$buildDir/libs/${project.getName()}-${version}.jar")
52 | }
53 |
54 | artifact androidSourcesJar
55 | artifact javadocJar
56 |
57 | // Mostly self-explanatory metadata
58 | pom {
59 | // packaging 'aar'
60 | // groupId publishedGroupId
61 | // artifactId artifact
62 |
63 | // Add your description here
64 | name = libraryName
65 | description = libraryDescription
66 | url = siteUrl
67 |
68 | // Set your license
69 | licenses {
70 | license {
71 | name = licenseName
72 | url = licenseUrl
73 | }
74 | }
75 | developers {
76 | developer {
77 | id = developerId
78 | name = developerName
79 | email = developerEmail
80 | }
81 | }
82 | scm {
83 | connection = gitUrl
84 | developerConnection = gitUrl
85 | url = siteUrl
86 | }
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
93 | ext["signing.keyId"] = rootProject.ext["signing.keyId"]
94 | ext["signing.password"] = rootProject.ext["signing.password"]
95 | ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
96 |
97 | signing {
98 | sign publishing.publications
99 | }
--------------------------------------------------------------------------------
/scripts/publish-root.gradle:
--------------------------------------------------------------------------------
1 | // Create variables with empty default values
2 | ext["ossrhUsername"] = ''
3 | ext["ossrhPassword"] = ''
4 | ext["sonatypeStagingProfileId"] = ''
5 | ext["signing.keyId"] = ''
6 | ext["signing.password"] = ''
7 | ext["signing.secretKeyRingFile"] = ''
8 |
9 | File secretPropsFile = project.rootProject.file('local.properties')
10 | if (secretPropsFile.exists()) {
11 | // Read local.properties file first if it exists
12 | Properties p = new Properties()
13 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
14 | p.each { name, value -> ext[name] = value }
15 | } else {
16 | // Use system environment variables
17 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
18 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
19 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
20 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
21 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
22 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
23 | }
24 |
25 | // Set up Sonatype repository
26 | nexusPublishing {
27 | repositories {
28 | sonatype {
29 | stagingProfileId = sonatypeStagingProfileId
30 | username = ossrhUsername
31 | password = ossrhPassword
32 | nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
33 | snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
34 |
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':bounceview-android'
2 |
--------------------------------------------------------------------------------