├── .gitignore
├── .idea
├── assetWizardSettings.xml
├── compiler.xml
├── encodings.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── CHANGELOG.md
├── CircleIndicator.iml
├── LICENSE
├── LoopingViewPager
├── .gitignore
├── README.md
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── imbryk
│ └── viewPager
│ ├── LoopPagerAdapterWrapper.java
│ └── LoopViewPager.java
├── README.md
├── apk
└── sample.apk
├── build.gradle
├── circleindicator
├── .gitignore
├── build.gradle
├── gradle.properties
├── proguard-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── me
│ │ │ └── relex
│ │ │ └── circleindicator
│ │ │ ├── BaseCircleIndicator.java
│ │ │ ├── CircleIndicator.java
│ │ │ ├── CircleIndicator2.java
│ │ │ ├── CircleIndicator3.java
│ │ │ ├── Config.java
│ │ │ └── SnackbarBehavior.java
│ │ └── res
│ │ ├── animator
│ │ └── scale_with_alpha.xml
│ │ ├── drawable
│ │ └── white_radius.xml
│ │ └── values
│ │ └── attrs.xml
├── upload-jcenter.gradle
├── upload-maven-plugin.gradle
└── upload-maven.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── sample
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── me
│ │ └── relex
│ │ └── circleindicator
│ │ └── sample
│ │ ├── LoopRecyclerAdapter.java
│ │ ├── SampleActivity.java
│ │ ├── SamplePagerAdapter.java
│ │ ├── SampleRecyclerAdapter.java
│ │ └── fragment
│ │ ├── ChangeDrawableFragment.java
│ │ ├── CustomAnimationFragment.java
│ │ ├── DefaultFragment.java
│ │ ├── DynamicAdapterFragment.java
│ │ ├── LoopRecyclerViewFragment.java
│ │ ├── LoopViewPagerFragment.java
│ │ ├── RecyclerViewFragment.java
│ │ ├── ResetAdapterFragment.java
│ │ ├── SnackbarBehaviorFragment.java
│ │ └── ViewPager2Fragment.java
│ └── res
│ ├── animator
│ ├── indicator_animator.xml
│ ├── indicator_animator_reverse.xml
│ └── indicator_no_animator.xml
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ ├── black_radius.xml
│ ├── black_radius_square.xml
│ ├── ic_launcher_background.xml
│ └── white_radius.xml
│ ├── layout
│ ├── activity_sample.xml
│ ├── fragment_sample_change_drawable.xml
│ ├── fragment_sample_custom_animation.xml
│ ├── fragment_sample_default.xml
│ ├── fragment_sample_dynamic_adapter.xml
│ ├── fragment_sample_loop_recycer_view.xml
│ ├── fragment_sample_loop_viewpager.xml
│ ├── fragment_sample_recycler_view.xml
│ ├── fragment_sample_reset_adapter.xml
│ ├── fragment_sample_snackbar_behavior.xml
│ ├── fragment_sample_viewpager2.xml
│ └── item_view.xml
│ ├── mipmap-anydpi-v26
│ └── ic_launcher.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ ├── colors.xml
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
├── screenshot.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | /.idea/caches
7 | /.idea/dictionaries
8 | .DS_Store
9 | /build
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ChangeLog
2 | --------
3 | ##### 2.X
4 | * [Releases](https://github.com/ongakuer/CircleIndicator/releases)
5 |
6 | ##### 1.2.2
7 | * Fix bug ([#69](https://github.com/ongakuer/CircleIndicator/issues/69))
8 | * Add SnackbarBehavior ([@daniellAlgar](https://github.com/daniellAlgar))
9 |
10 | ##### 1.2.1
11 | * Fix bug ([#57](https://github.com/ongakuer/CircleIndicator/issues/57)), Rename properties: ```orientation```->```ci_orientation``` , ```gravity```->```ci_gravity```
12 |
13 | ##### 1.2.0
14 | * Add properties : ```orientation```(default:horizontal) , ```gravity```(default:center)
15 | * Remove auto register DataSetObserver. [#54](https://github.com/ongakuer/CircleIndicator/issues/54)
16 |
17 | Please change like this if you used dynamic adapter:
18 | ```java
19 | viewpager.setAdapter(mAdapter);
20 | indicator.setViewPager(viewpager);
21 | mAdapter.registerDataSetObserver(indicator.getDataSetObserver());
22 | ```
23 |
24 | ##### 1.1.9 (2016-04-16)
25 | * Fix bug ([#51](https://github.com/ongakuer/CircleIndicator/issues/51))
26 | * Add Reset Adapter Sample
27 | * Add LoopViewPager Sample
28 |
29 | ##### 1.1.8 (2016-01-15)
30 | * Fix bug ([#43](https://github.com/ongakuer/CircleIndicator/pull/43))
31 |
32 | ##### 1.1.7 (2015-12-21)
33 | * Fix bug ([#41](https://github.com/ongakuer/CircleIndicator/issues/41))
34 |
35 | ##### 1.1.6 (2015-12-03)
36 | * Support Dynamic Adapter
37 | * Fix bugs
38 | * Rewrite Samples
39 |
40 | ##### 1.1.5 (2015-06-28)
41 | * Fix bug ([#22](https://github.com/ongakuer/CircleIndicator/issues/22))
42 |
43 | ##### 1.1.4 (2015-06-03)
44 | * Fix bug ([#17](https://github.com/ongakuer/CircleIndicator/issues/17))
45 | * SetOnPageChangeListener is deprecated, Please use ViewPager addOnPageChangeListener (v4 support lirbray revision 22.2.0)
46 | * ```minSdkVersion="11"```
47 |
48 | ##### 1.1.3 (2015-04-15)
49 | * Fix bug ([#12](https://github.com/ongakuer/CircleIndicator/issues/12))
50 |
51 | ##### 1.1.2 (2015-03-10)
52 | * Fix bug ([#9](https://github.com/ongakuer/CircleIndicator/pull/9))
53 | * Add a property : ```ci_drawable_unselected``` ([#6](https://github.com/ongakuer/CircleIndicator/pull/6))
54 |
55 | ##### 1.1.1 (2015-01-08)
56 | * Fix default animator
57 | * Add a property : ```ci_animator_reverse```
58 |
59 | ##### 1.1.0 (2014-12-29)
60 | * Remove NineOldAndroids dependency
61 | * ```minSdkVersion="14"```
62 |
63 | ##### 1.0.0 (2014-08-01)
64 | * Initial release. (```minSdkVersion="8"```)
--------------------------------------------------------------------------------
/CircleIndicator.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/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.
202 |
--------------------------------------------------------------------------------
/LoopingViewPager/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/LoopingViewPager/README.md:
--------------------------------------------------------------------------------
1 | [LoopingViewPager](https://github.com/imbryk/LoopingViewPager)
2 | ================
3 |
4 | An android ViewPager extension allowing infinite scrolling.
5 |
--------------------------------------------------------------------------------
/LoopingViewPager/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 29
5 |
6 | defaultConfig {
7 | minSdkVersion 14
8 | targetSdkVersion 29
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | compileOptions {
19 | sourceCompatibility = '1.8'
20 | targetCompatibility = '1.8'
21 | }
22 | }
23 |
24 | dependencies {
25 | implementation 'androidx.viewpager:viewpager:1.0.0'
26 | implementation 'androidx.fragment:fragment:1.2.5'
27 | }
28 |
--------------------------------------------------------------------------------
/LoopingViewPager/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/relex/android-sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/LoopingViewPager/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LoopingViewPager/src/main/java/com/imbryk/viewPager/LoopPagerAdapterWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Leszek Mzyk
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.imbryk.viewPager;
17 |
18 | import android.os.Parcelable;
19 | import androidx.annotation.NonNull;
20 | import androidx.fragment.app.FragmentPagerAdapter;
21 | import androidx.fragment.app.FragmentStatePagerAdapter;
22 | import androidx.viewpager.widget.PagerAdapter;
23 | import android.util.SparseArray;
24 | import android.view.View;
25 | import android.view.ViewGroup;
26 |
27 | public class LoopPagerAdapterWrapper extends PagerAdapter {
28 |
29 | private final PagerAdapter mAdapter;
30 |
31 | private SparseArray mToDestroy = new SparseArray<>();
32 |
33 | private static final boolean DEFAULT_BOUNDARY_CASHING = true;
34 | private static final boolean DEFAULT_BOUNDARY_LOOPING = true;
35 |
36 | private boolean mBoundaryCaching = DEFAULT_BOUNDARY_CASHING;
37 | private boolean mBoundaryLooping = DEFAULT_BOUNDARY_LOOPING;
38 |
39 | void setBoundaryCaching(boolean flag) {
40 | mBoundaryCaching = flag;
41 | }
42 |
43 | void setBoundaryLooping(boolean flag) {
44 | mBoundaryLooping = flag;
45 | }
46 |
47 | LoopPagerAdapterWrapper(PagerAdapter adapter) {
48 | this.mAdapter = adapter;
49 | }
50 |
51 | @Override public void notifyDataSetChanged() {
52 | mToDestroy = new SparseArray<>();
53 | super.notifyDataSetChanged();
54 | }
55 |
56 | int toRealPosition(int position) {
57 | int realPosition = position;
58 | int realCount = getRealCount();
59 | if (realCount == 0) {
60 | return 0;
61 | }
62 | if (mBoundaryLooping) {
63 | realPosition = (position - 1) % realCount;
64 | if (realPosition < 0) {
65 | realPosition += realCount;
66 | }
67 | }
68 |
69 | return realPosition;
70 | }
71 |
72 | public int toInnerPosition(int realPosition) {
73 | int position = (realPosition + 1);
74 | return mBoundaryLooping ? position : realPosition;
75 | }
76 |
77 | private int getRealFirstPosition() {
78 | return mBoundaryLooping ? 1 : 0;
79 | }
80 |
81 | private int getRealLastPosition() {
82 | return getRealFirstPosition() + getRealCount() - 1;
83 | }
84 |
85 | @Override public int getCount() {
86 | int count = getRealCount();
87 | return mBoundaryLooping ? count + 2 : count;
88 | }
89 |
90 | public int getRealCount() {
91 | return mAdapter.getCount();
92 | }
93 |
94 | public PagerAdapter getRealAdapter() {
95 | return mAdapter;
96 | }
97 |
98 | @NonNull @Override public Object instantiateItem(@NonNull ViewGroup container, int position) {
99 | int realPosition = (mAdapter instanceof FragmentPagerAdapter
100 | || mAdapter instanceof FragmentStatePagerAdapter) ? position
101 | : toRealPosition(position);
102 |
103 | if (mBoundaryCaching) {
104 | ToDestroy toDestroy = mToDestroy.get(position);
105 | if (toDestroy != null) {
106 | mToDestroy.remove(position);
107 | return toDestroy.object;
108 | }
109 | }
110 | return mAdapter.instantiateItem(container, realPosition);
111 | }
112 |
113 | @Override
114 | public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
115 | int realFirst = getRealFirstPosition();
116 | int realLast = getRealLastPosition();
117 | int realPosition = (mAdapter instanceof FragmentPagerAdapter
118 | || mAdapter instanceof FragmentStatePagerAdapter) ? position
119 | : toRealPosition(position);
120 |
121 | if (mBoundaryCaching && (position == realFirst || position == realLast)) {
122 | mToDestroy.put(position, new ToDestroy(container, realPosition, object));
123 | } else {
124 | mAdapter.destroyItem(container, realPosition, object);
125 | }
126 | }
127 |
128 | /*
129 | * Delegate rest of methods directly to the inner adapter.
130 | */
131 |
132 | @Override public void finishUpdate(@NonNull ViewGroup container) {
133 | mAdapter.finishUpdate(container);
134 | }
135 |
136 | @Override public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
137 | return mAdapter.isViewFromObject(view, object);
138 | }
139 |
140 | @Override public void restoreState(Parcelable bundle, ClassLoader classLoader) {
141 | mAdapter.restoreState(bundle, classLoader);
142 | }
143 |
144 | @Override public Parcelable saveState() {
145 | return mAdapter.saveState();
146 | }
147 |
148 | @Override public void startUpdate(@NonNull ViewGroup container) {
149 | mAdapter.startUpdate(container);
150 | }
151 |
152 | @Override
153 | public void setPrimaryItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
154 | mAdapter.setPrimaryItem(container, position, object);
155 | }
156 |
157 | /*
158 | * End delegation
159 | */
160 |
161 | /**
162 | * Container class for caching the boundary views
163 | */
164 | static class ToDestroy {
165 | final ViewGroup container;
166 | final int position;
167 | final Object object;
168 |
169 | ToDestroy(ViewGroup container, int position, Object object) {
170 | this.container = container;
171 | this.position = position;
172 | this.object = object;
173 | }
174 | }
175 | }
--------------------------------------------------------------------------------
/LoopingViewPager/src/main/java/com/imbryk/viewPager/LoopViewPager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2013 Leszek Mzyk
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.imbryk.viewPager;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import androidx.annotation.NonNull;
21 | import androidx.viewpager.widget.PagerAdapter;
22 | import androidx.viewpager.widget.ViewPager;
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | public class LoopViewPager extends ViewPager {
27 | private static final boolean DEFAULT_BOUNDARY_CASHING = false;
28 | private static final boolean DEFAULT_BOUNDARY_LOOPING = true;
29 |
30 | private LoopPagerAdapterWrapper mAdapter;
31 | private boolean mBoundaryCaching = DEFAULT_BOUNDARY_CASHING;
32 | private boolean mBoundaryLooping = DEFAULT_BOUNDARY_LOOPING;
33 | private List mOnPageChangeListeners;
34 |
35 | /**
36 | * helper function which may be used when implementing FragmentPagerAdapter
37 | *
38 | * @return (position - 1)%count
39 | */
40 | public static int toRealPosition(int position, int count) {
41 | position = position - 1;
42 | if (position < 0) {
43 | position += count;
44 | } else {
45 | position = position % count;
46 | }
47 | return position;
48 | }
49 |
50 | /**
51 | * If set to true, the boundary views (i.e. first and last) will never be
52 | * destroyed This may help to prevent "blinking" of some views
53 | */
54 | public void setBoundaryCaching(boolean flag) {
55 | mBoundaryCaching = flag;
56 | if (mAdapter != null) {
57 | mAdapter.setBoundaryCaching(flag);
58 | }
59 | }
60 |
61 | public void setBoundaryLooping(boolean flag) {
62 | mBoundaryLooping = flag;
63 | if (mAdapter != null) {
64 | mAdapter.setBoundaryLooping(flag);
65 | }
66 | }
67 |
68 | @Override public void setAdapter(PagerAdapter adapter) {
69 | mAdapter = new LoopPagerAdapterWrapper(adapter);
70 | mAdapter.setBoundaryCaching(mBoundaryCaching);
71 | mAdapter.setBoundaryLooping(mBoundaryLooping);
72 | super.setAdapter(mAdapter);
73 | setCurrentItem(0, false);
74 | }
75 |
76 | @Override public PagerAdapter getAdapter() {
77 | return mAdapter != null ? mAdapter.getRealAdapter() : null;
78 | }
79 |
80 | @Override public int getCurrentItem() {
81 | return mAdapter != null ? mAdapter.toRealPosition(super.getCurrentItem()) : 0;
82 | }
83 |
84 | @Override public void setCurrentItem(int item, boolean smoothScroll) {
85 | int realItem = mAdapter.toInnerPosition(item);
86 | super.setCurrentItem(realItem, smoothScroll);
87 | }
88 |
89 | @Override public void setCurrentItem(int item) {
90 | if (getCurrentItem() != item) {
91 | setCurrentItem(item, true);
92 | }
93 | }
94 |
95 | @Override public void addOnPageChangeListener(@NonNull OnPageChangeListener listener) {
96 | if (mOnPageChangeListeners == null) {
97 | mOnPageChangeListeners = new ArrayList<>();
98 | }
99 | mOnPageChangeListeners.add(listener);
100 | }
101 |
102 | @Override public void removeOnPageChangeListener(@NonNull OnPageChangeListener listener) {
103 | if (mOnPageChangeListeners != null) {
104 | mOnPageChangeListeners.remove(listener);
105 | }
106 | }
107 |
108 | @Override public void clearOnPageChangeListeners() {
109 | if (mOnPageChangeListeners != null) {
110 | mOnPageChangeListeners.clear();
111 | }
112 | }
113 |
114 | public LoopViewPager(Context context) {
115 | super(context);
116 | init(context);
117 | }
118 |
119 | public LoopViewPager(Context context, AttributeSet attrs) {
120 | super(context, attrs);
121 | init(context);
122 | }
123 |
124 | private void init(Context context) {
125 | super.removeOnPageChangeListener(onPageChangeListener);
126 | super.addOnPageChangeListener(onPageChangeListener);
127 | }
128 |
129 | private final OnPageChangeListener onPageChangeListener = new OnPageChangeListener() {
130 | private float mPreviousOffset = -1;
131 | private float mPreviousPosition = -1;
132 |
133 | @Override public void onPageSelected(int position) {
134 |
135 | int realPosition = mAdapter.toRealPosition(position);
136 | if (mPreviousPosition != realPosition) {
137 | mPreviousPosition = realPosition;
138 |
139 | if (mOnPageChangeListeners != null) {
140 | for (int i = 0; i < mOnPageChangeListeners.size(); i++) {
141 | OnPageChangeListener listener = mOnPageChangeListeners.get(i);
142 | if (listener != null) {
143 | listener.onPageSelected(realPosition);
144 | }
145 | }
146 | }
147 | }
148 | }
149 |
150 | @Override
151 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
152 | int realPosition = position;
153 | if (mAdapter != null) {
154 | realPosition = mAdapter.toRealPosition(position);
155 |
156 | if (positionOffset == 0 && mPreviousOffset == 0 && (position == 0
157 | || position == mAdapter.getCount() - 1)) {
158 | setCurrentItem(realPosition, false);
159 | }
160 | }
161 |
162 | mPreviousOffset = positionOffset;
163 |
164 | if (mOnPageChangeListeners != null) {
165 | for (int i = 0; i < mOnPageChangeListeners.size(); i++) {
166 | OnPageChangeListener listener = mOnPageChangeListeners.get(i);
167 | if (listener != null) {
168 | if (realPosition != mAdapter.getRealCount() - 1) {
169 | listener.onPageScrolled(realPosition, positionOffset,
170 | positionOffsetPixels);
171 | } else {
172 | if (positionOffset > .5) {
173 | listener.onPageScrolled(0, 0, 0);
174 | } else {
175 | listener.onPageScrolled(realPosition, 0, 0);
176 | }
177 | }
178 | }
179 | }
180 | }
181 | }
182 |
183 | @Override public void onPageScrollStateChanged(int state) {
184 | if (mAdapter != null) {
185 | int position = LoopViewPager.super.getCurrentItem();
186 | int realPosition = mAdapter.toRealPosition(position);
187 | if (state == ViewPager.SCROLL_STATE_IDLE && (position == 0
188 | || position == mAdapter.getCount() - 1)) {
189 | setCurrentItem(realPosition, false);
190 | }
191 | }
192 |
193 | if (mOnPageChangeListeners != null) {
194 | for (int i = 0; i < mOnPageChangeListeners.size(); i++) {
195 | OnPageChangeListener listener = mOnPageChangeListeners.get(i);
196 | if (listener != null) {
197 | listener.onPageScrollStateChanged(state);
198 | }
199 | }
200 | }
201 | }
202 | };
203 | }
204 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CircleIndicator
2 | ===============
3 | A lightweight indicator like in nexus 5 launcher
4 |
5 | [  ](https://bintray.com/ongakuer/maven/CircleIndicator/_latestVersion)
6 |
7 | [](https://maven-badges.herokuapp.com/maven-central/me.relex/circleindicator)
8 |
9 |
10 |
11 |
12 |
13 | Gradle
14 | ------------
15 |
16 |
17 | ##### AndroidX
18 | ```groovy
19 | dependencies {
20 | implementation 'me.relex:circleindicator:2.1.6'
21 | }
22 | ```
23 |
24 | ##### Android Support Library
25 | ```groovy
26 | dependencies {
27 | implementation 'me.relex:circleindicator:1.3.2'
28 | }
29 | ```
30 |
31 |
32 | Usage
33 | --------
34 |
35 | | Class | Widget |
36 | | --------------------------------------------- | ----------------------------- |
37 | | me.relex.circleindicator.CircleIndicator | ViewPager |
38 | | me.relex.circleindicator.CircleIndicator2 | RecyclerView |
39 | | me.relex.circleindicator.CircleIndicator3 | ViewPager2 *(AndroidX)* |
40 |
41 |
42 |
43 |
44 | ##### ViewPager (CircleIndicator)
45 |
46 |
47 | ```java
48 | ViewPager viewpager = (ViewPager) view.findViewById(R.id.viewpager);
49 | viewpager.setAdapter(adapter);
50 |
51 | CircleIndicator indicator = (CircleIndicator) view.findViewById(R.id.indicator);
52 | indicator.setViewPager(viewpager);
53 |
54 | // optional
55 | adapter.registerDataSetObserver(indicator.getDataSetObserver());
56 | ```
57 |
58 |
59 | ##### RecyclerView (CircleIndicator2)
60 |
61 |
62 | ```java
63 | RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
64 | recyclerView.setLayoutManager(layoutManager);
65 | recyclerView.setAdapter(adapter);
66 |
67 | PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
68 | pagerSnapHelper.attachToRecyclerView(recyclerView);
69 |
70 | CircleIndicator2 indicator = view.findViewById(R.id.indicator);
71 | indicator.attachToRecyclerView(recyclerView, pagerSnapHelper);
72 |
73 | // optional
74 | adapter.registerAdapterDataObserver(indicator.getAdapterDataObserver());
75 | ```
76 |
77 |
78 | ##### ViewPager2 (CircleIndicator3)
79 |
80 | ```java
81 | ViewPager2 viewpager = view.findViewById(R.id.viewpager);
82 | viewpager.setAdapter(mAdapter);
83 |
84 | CircleIndicator3 indicator = view.findViewById(R.id.indicator);
85 | indicator.setViewPager(viewpager);
86 |
87 | // optional
88 | adapter.registerAdapterDataObserver(indicator.getAdapterDataObserver());
89 | ```
90 |
91 | ##### Manual control
92 | ```java
93 | CircleIndicator indicator = view.findViewById(R.id.indicator);
94 | indicator.createIndicators(5,0);
95 |
96 | indicator.animatePageSelected(2)
97 | ```
98 |
99 |
100 |
101 | XML Properties
102 | --------
103 |
104 | ```xml
105 |
109 | ```
110 |
111 | | Properties | Default Value |
112 | | ----------------------------- | ----------------------------- |
113 | | app:ci_width | 5dp |
114 | | app:ci_height | 5dp |
115 | | app:ci_margin | 5dp |
116 | | app:ci_drawable | R.drawable.white_radius |
117 | | app:ci_drawable_unselected | R.drawable.white_radius |
118 | | app:ci_animator | R.animator.scale_with_alpha |
119 | | app:ci_animator_reverse | 0 |
120 | | app:ci_orientation | horizontal |
121 | | app:ci_gravity | center |
122 |
--------------------------------------------------------------------------------
/apk/sample.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/apk/sample.apk
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:4.1.2'
11 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | mavenCentral()
19 | google()
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/circleindicator/.gitignore:
--------------------------------------------------------------------------------
1 | /circleindicator.iml
2 | /build
3 |
--------------------------------------------------------------------------------
/circleindicator/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | version = "2.1.6"
4 |
5 | android {
6 | compileSdkVersion 29
7 |
8 | defaultConfig {
9 | minSdkVersion 14
10 | targetSdkVersion 29
11 | versionCode 216
12 | versionName version
13 | }
14 |
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | compileOptions {
22 | sourceCompatibility = '1.8'
23 | targetCompatibility = '1.8'
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation 'androidx.core:core:1.3.2'
29 | implementation 'androidx.annotation:annotation:1.1.0'
30 | compileOnly 'androidx.viewpager:viewpager:1.0.0'
31 | compileOnly 'androidx.recyclerview:recyclerview:1.1.0'
32 | compileOnly 'com.google.android.material:material:1.2.1'
33 | compileOnly 'androidx.viewpager2:viewpager2:1.0.0'
34 | }
35 |
36 | //apply from: "upload-maven-plugin.gradle"
--------------------------------------------------------------------------------
/circleindicator/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | POM_NAME=CircleIndicator
21 | POM_ARTIFACT_ID=circleindicator
22 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/circleindicator/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/circleindicator/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/BaseCircleIndicator.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorInflater;
5 | import android.annotation.TargetApi;
6 | import android.content.Context;
7 | import android.content.res.ColorStateList;
8 | import android.content.res.TypedArray;
9 | import android.graphics.drawable.Drawable;
10 | import android.os.Build;
11 | import android.util.AttributeSet;
12 | import android.util.TypedValue;
13 | import android.view.Gravity;
14 | import android.view.View;
15 | import android.view.animation.Interpolator;
16 | import android.widget.LinearLayout;
17 | import androidx.annotation.ColorInt;
18 | import androidx.annotation.DrawableRes;
19 | import androidx.annotation.Nullable;
20 | import androidx.core.content.ContextCompat;
21 | import androidx.core.graphics.drawable.DrawableCompat;
22 | import androidx.core.view.ViewCompat;
23 |
24 | class BaseCircleIndicator extends LinearLayout {
25 |
26 | private final static int DEFAULT_INDICATOR_WIDTH = 5;
27 |
28 | protected int mIndicatorMargin = -1;
29 | protected int mIndicatorWidth = -1;
30 | protected int mIndicatorHeight = -1;
31 |
32 | protected int mIndicatorBackgroundResId;
33 | protected int mIndicatorUnselectedBackgroundResId;
34 |
35 | protected ColorStateList mIndicatorTintColor;
36 | protected ColorStateList mIndicatorTintUnselectedColor;
37 |
38 | protected Animator mAnimatorOut;
39 | protected Animator mAnimatorIn;
40 | protected Animator mImmediateAnimatorOut;
41 | protected Animator mImmediateAnimatorIn;
42 |
43 | protected int mLastPosition = -1;
44 |
45 | @Nullable private IndicatorCreatedListener mIndicatorCreatedListener;
46 |
47 | public BaseCircleIndicator(Context context) {
48 | super(context);
49 | init(context, null);
50 | }
51 |
52 | public BaseCircleIndicator(Context context, AttributeSet attrs) {
53 | super(context, attrs);
54 | init(context, attrs);
55 | }
56 |
57 | public BaseCircleIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
58 | super(context, attrs, defStyleAttr);
59 | init(context, attrs);
60 | }
61 |
62 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
63 | public BaseCircleIndicator(Context context, AttributeSet attrs, int defStyleAttr,
64 | int defStyleRes) {
65 | super(context, attrs, defStyleAttr, defStyleRes);
66 | init(context, attrs);
67 | }
68 |
69 | private void init(Context context, AttributeSet attrs) {
70 | Config config = handleTypedArray(context, attrs);
71 | initialize(config);
72 |
73 | if (isInEditMode()) {
74 | createIndicators(3, 1);
75 | }
76 | }
77 |
78 | private Config handleTypedArray(Context context, AttributeSet attrs) {
79 | Config config = new Config();
80 | if (attrs == null) {
81 | return config;
82 | }
83 | TypedArray typedArray =
84 | context.obtainStyledAttributes(attrs, R.styleable.BaseCircleIndicator);
85 | config.width =
86 | typedArray.getDimensionPixelSize(R.styleable.BaseCircleIndicator_ci_width, -1);
87 | config.height =
88 | typedArray.getDimensionPixelSize(R.styleable.BaseCircleIndicator_ci_height, -1);
89 | config.margin =
90 | typedArray.getDimensionPixelSize(R.styleable.BaseCircleIndicator_ci_margin, -1);
91 | config.animatorResId = typedArray.getResourceId(R.styleable.BaseCircleIndicator_ci_animator,
92 | R.animator.scale_with_alpha);
93 | config.animatorReverseResId =
94 | typedArray.getResourceId(R.styleable.BaseCircleIndicator_ci_animator_reverse, 0);
95 | config.backgroundResId =
96 | typedArray.getResourceId(R.styleable.BaseCircleIndicator_ci_drawable,
97 | R.drawable.white_radius);
98 | config.unselectedBackgroundId =
99 | typedArray.getResourceId(R.styleable.BaseCircleIndicator_ci_drawable_unselected,
100 | config.backgroundResId);
101 | config.orientation = typedArray.getInt(R.styleable.BaseCircleIndicator_ci_orientation, -1);
102 | config.gravity = typedArray.getInt(R.styleable.BaseCircleIndicator_ci_gravity, -1);
103 | typedArray.recycle();
104 |
105 | return config;
106 | }
107 |
108 | public void initialize(Config config) {
109 | int miniSize = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
110 | DEFAULT_INDICATOR_WIDTH, getResources().getDisplayMetrics()) + 0.5f);
111 | mIndicatorWidth = (config.width < 0) ? miniSize : config.width;
112 | mIndicatorHeight = (config.height < 0) ? miniSize : config.height;
113 | mIndicatorMargin = (config.margin < 0) ? miniSize : config.margin;
114 |
115 | mAnimatorOut = createAnimatorOut(config);
116 | mImmediateAnimatorOut = createAnimatorOut(config);
117 | mImmediateAnimatorOut.setDuration(0);
118 |
119 | mAnimatorIn = createAnimatorIn(config);
120 | mImmediateAnimatorIn = createAnimatorIn(config);
121 | mImmediateAnimatorIn.setDuration(0);
122 |
123 | mIndicatorBackgroundResId =
124 | (config.backgroundResId == 0) ? R.drawable.white_radius : config.backgroundResId;
125 | mIndicatorUnselectedBackgroundResId =
126 | (config.unselectedBackgroundId == 0) ? config.backgroundResId
127 | : config.unselectedBackgroundId;
128 |
129 | setOrientation(config.orientation == VERTICAL ? VERTICAL : HORIZONTAL);
130 | setGravity(config.gravity >= 0 ? config.gravity : Gravity.CENTER);
131 | }
132 |
133 | public void tintIndicator(@ColorInt int indicatorColor) {
134 | tintIndicator(indicatorColor, indicatorColor);
135 | }
136 |
137 | public void tintIndicator(@ColorInt int indicatorColor,
138 | @ColorInt int unselectedIndicatorColor) {
139 | mIndicatorTintColor = ColorStateList.valueOf(indicatorColor);
140 | mIndicatorTintUnselectedColor = ColorStateList.valueOf(unselectedIndicatorColor);
141 | changeIndicatorBackground();
142 | }
143 |
144 | public void changeIndicatorResource(@DrawableRes int indicatorResId) {
145 | changeIndicatorResource(indicatorResId, indicatorResId);
146 | }
147 |
148 | public void changeIndicatorResource(@DrawableRes int indicatorResId,
149 | @DrawableRes int indicatorUnselectedResId) {
150 | mIndicatorBackgroundResId = indicatorResId;
151 | mIndicatorUnselectedBackgroundResId = indicatorUnselectedResId;
152 | changeIndicatorBackground();
153 | }
154 |
155 | public interface IndicatorCreatedListener {
156 | /**
157 | * IndicatorCreatedListener
158 | *
159 | * @param view internal indicator view
160 | * @param position position
161 | */
162 | void onIndicatorCreated(View view, int position);
163 | }
164 |
165 | public void setIndicatorCreatedListener(
166 | @Nullable IndicatorCreatedListener indicatorCreatedListener) {
167 | mIndicatorCreatedListener = indicatorCreatedListener;
168 | }
169 |
170 | protected Animator createAnimatorOut(Config config) {
171 | return AnimatorInflater.loadAnimator(getContext(), config.animatorResId);
172 | }
173 |
174 | protected Animator createAnimatorIn(Config config) {
175 | Animator animatorIn;
176 | if (config.animatorReverseResId == 0) {
177 | animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorResId);
178 | animatorIn.setInterpolator(new ReverseInterpolator());
179 | } else {
180 | animatorIn = AnimatorInflater.loadAnimator(getContext(), config.animatorReverseResId);
181 | }
182 | return animatorIn;
183 | }
184 |
185 | public void createIndicators(int count, int currentPosition) {
186 | if (mImmediateAnimatorOut.isRunning()) {
187 | mImmediateAnimatorOut.end();
188 | mImmediateAnimatorOut.cancel();
189 | }
190 |
191 | if (mImmediateAnimatorIn.isRunning()) {
192 | mImmediateAnimatorIn.end();
193 | mImmediateAnimatorIn.cancel();
194 | }
195 |
196 | // Diff View
197 | int childViewCount = getChildCount();
198 | if (count < childViewCount) {
199 | removeViews(count, childViewCount - count);
200 | } else if (count > childViewCount) {
201 | int addCount = count - childViewCount;
202 | int orientation = getOrientation();
203 | for (int i = 0; i < addCount; i++) {
204 | addIndicator(orientation);
205 | }
206 | }
207 |
208 | // Bind Style
209 | View indicator;
210 | for (int i = 0; i < count; i++) {
211 | indicator = getChildAt(i);
212 | if (currentPosition == i) {
213 | bindIndicatorBackground(indicator, mIndicatorBackgroundResId, mIndicatorTintColor);
214 | mImmediateAnimatorOut.setTarget(indicator);
215 | mImmediateAnimatorOut.start();
216 | mImmediateAnimatorOut.end();
217 | } else {
218 |
219 | bindIndicatorBackground(indicator, mIndicatorUnselectedBackgroundResId,
220 | mIndicatorTintUnselectedColor);
221 |
222 | mImmediateAnimatorIn.setTarget(indicator);
223 | mImmediateAnimatorIn.start();
224 | mImmediateAnimatorIn.end();
225 | }
226 |
227 | if (mIndicatorCreatedListener != null) {
228 | mIndicatorCreatedListener.onIndicatorCreated(indicator, i);
229 | }
230 | }
231 |
232 | mLastPosition = currentPosition;
233 | }
234 |
235 | protected void addIndicator(int orientation) {
236 | View indicator = new View(getContext());
237 | final LayoutParams params = generateDefaultLayoutParams();
238 | params.width = mIndicatorWidth;
239 | params.height = mIndicatorHeight;
240 | if (orientation == HORIZONTAL) {
241 | params.leftMargin = mIndicatorMargin;
242 | params.rightMargin = mIndicatorMargin;
243 | } else {
244 | params.topMargin = mIndicatorMargin;
245 | params.bottomMargin = mIndicatorMargin;
246 | }
247 | addView(indicator, params);
248 | }
249 |
250 | public void animatePageSelected(int position) {
251 |
252 | if (mLastPosition == position) {
253 | return;
254 | }
255 |
256 | if (mAnimatorIn.isRunning()) {
257 | mAnimatorIn.end();
258 | mAnimatorIn.cancel();
259 | }
260 |
261 | if (mAnimatorOut.isRunning()) {
262 | mAnimatorOut.end();
263 | mAnimatorOut.cancel();
264 | }
265 |
266 | View currentIndicator;
267 | if (mLastPosition >= 0 && (currentIndicator = getChildAt(mLastPosition)) != null) {
268 | bindIndicatorBackground(currentIndicator, mIndicatorUnselectedBackgroundResId,
269 | mIndicatorTintUnselectedColor);
270 | mAnimatorIn.setTarget(currentIndicator);
271 | mAnimatorIn.start();
272 | }
273 |
274 | View selectedIndicator = getChildAt(position);
275 | if (selectedIndicator != null) {
276 | bindIndicatorBackground(selectedIndicator, mIndicatorBackgroundResId,
277 | mIndicatorTintColor);
278 |
279 | mAnimatorOut.setTarget(selectedIndicator);
280 | mAnimatorOut.start();
281 | }
282 | mLastPosition = position;
283 | }
284 |
285 | protected void changeIndicatorBackground() {
286 | int count = getChildCount();
287 | if (count <= 0) {
288 | return;
289 | }
290 | View currentIndicator;
291 | for (int i = 0; i < count; i++) {
292 | currentIndicator = getChildAt(i);
293 | if (i == mLastPosition) {
294 | bindIndicatorBackground(currentIndicator, mIndicatorBackgroundResId,
295 | mIndicatorTintColor);
296 | } else {
297 | bindIndicatorBackground(currentIndicator, mIndicatorUnselectedBackgroundResId,
298 | mIndicatorTintUnselectedColor);
299 | }
300 | }
301 | }
302 |
303 | private void bindIndicatorBackground(View view, @DrawableRes int drawableRes,
304 | @Nullable ColorStateList tintColor) {
305 | if (tintColor != null) {
306 | Drawable indicatorDrawable = DrawableCompat.wrap(
307 | ContextCompat.getDrawable(getContext(), drawableRes).mutate());
308 | DrawableCompat.setTintList(indicatorDrawable, tintColor);
309 | ViewCompat.setBackground(view, indicatorDrawable);
310 | } else {
311 | view.setBackgroundResource(drawableRes);
312 | }
313 | }
314 |
315 | protected static class ReverseInterpolator implements Interpolator {
316 | @Override public float getInterpolation(float value) {
317 | return Math.abs(1.0f - value);
318 | }
319 | }
320 | }
321 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/CircleIndicator.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.database.DataSetObserver;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import androidx.annotation.Nullable;
9 | import androidx.viewpager.widget.PagerAdapter;
10 | import androidx.viewpager.widget.ViewPager;
11 |
12 | /**
13 | * CircleIndicator work with ViewPager
14 | */
15 | public class CircleIndicator extends BaseCircleIndicator {
16 |
17 | private ViewPager mViewpager;
18 |
19 | public CircleIndicator(Context context) {
20 | super(context);
21 | }
22 |
23 | public CircleIndicator(Context context, AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | public CircleIndicator(Context context, AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | }
30 |
31 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
32 | public CircleIndicator(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
33 | super(context, attrs, defStyleAttr, defStyleRes);
34 | }
35 |
36 | public void setViewPager(@Nullable ViewPager viewPager) {
37 | mViewpager = viewPager;
38 | if (mViewpager != null && mViewpager.getAdapter() != null) {
39 | mLastPosition = -1;
40 | createIndicators();
41 | mViewpager.removeOnPageChangeListener(mInternalPageChangeListener);
42 | mViewpager.addOnPageChangeListener(mInternalPageChangeListener);
43 | mInternalPageChangeListener.onPageSelected(mViewpager.getCurrentItem());
44 | }
45 | }
46 |
47 | private void createIndicators() {
48 | PagerAdapter adapter = mViewpager.getAdapter();
49 | int count;
50 | if (adapter == null) {
51 | count = 0;
52 | } else {
53 | count = adapter.getCount();
54 | }
55 | createIndicators(count, mViewpager.getCurrentItem());
56 | }
57 |
58 | private final ViewPager.OnPageChangeListener mInternalPageChangeListener =
59 | new ViewPager.OnPageChangeListener() {
60 |
61 | @Override public void onPageScrolled(int position, float positionOffset,
62 | int positionOffsetPixels) {
63 | }
64 |
65 | @Override public void onPageSelected(int position) {
66 |
67 | if (mViewpager.getAdapter() == null
68 | || mViewpager.getAdapter().getCount() <= 0) {
69 | return;
70 | }
71 | animatePageSelected(position);
72 | }
73 |
74 | @Override public void onPageScrollStateChanged(int state) {
75 | }
76 | };
77 |
78 | public DataSetObserver getDataSetObserver() {
79 | return mInternalDataSetObserver;
80 | }
81 |
82 | private final DataSetObserver mInternalDataSetObserver = new DataSetObserver() {
83 | @Override public void onChanged() {
84 | super.onChanged();
85 | if (mViewpager == null) {
86 | return;
87 | }
88 | PagerAdapter adapter = mViewpager.getAdapter();
89 | int newCount = adapter != null ? adapter.getCount() : 0;
90 | int currentCount = getChildCount();
91 | if (newCount == currentCount) {
92 | // No change
93 | return;
94 | } else if (mLastPosition < newCount) {
95 | mLastPosition = mViewpager.getCurrentItem();
96 | } else {
97 | mLastPosition = -1;
98 | }
99 | createIndicators();
100 | }
101 | };
102 |
103 | /**
104 | * @deprecated User ViewPager addOnPageChangeListener
105 | */
106 | @Deprecated public void setOnPageChangeListener(
107 | ViewPager.OnPageChangeListener onPageChangeListener) {
108 | if (mViewpager == null) {
109 | throw new NullPointerException("can not find Viewpager , setViewPager first");
110 | }
111 | mViewpager.removeOnPageChangeListener(onPageChangeListener);
112 | mViewpager.addOnPageChangeListener(onPageChangeListener);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/CircleIndicator2.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.util.AttributeSet;
7 | import android.view.View;
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.recyclerview.widget.RecyclerView;
11 | import androidx.recyclerview.widget.SnapHelper;
12 |
13 | /**
14 | * CircleIndicator2 work with RecyclerView and SnapHelper
15 | */
16 | public class CircleIndicator2 extends BaseCircleIndicator {
17 |
18 | private RecyclerView mRecyclerView;
19 | private SnapHelper mSnapHelper;
20 |
21 | public CircleIndicator2(Context context) {
22 | super(context);
23 | }
24 |
25 | public CircleIndicator2(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | }
28 |
29 | public CircleIndicator2(Context context, AttributeSet attrs, int defStyleAttr) {
30 | super(context, attrs, defStyleAttr);
31 | }
32 |
33 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
34 | public CircleIndicator2(Context context, AttributeSet attrs, int defStyleAttr,
35 | int defStyleRes) {
36 | super(context, attrs, defStyleAttr, defStyleRes);
37 | }
38 |
39 | public void attachToRecyclerView(@NonNull RecyclerView recyclerView,
40 | @NonNull SnapHelper snapHelper) {
41 | mRecyclerView = recyclerView;
42 | mSnapHelper = snapHelper;
43 | mLastPosition = -1;
44 | createIndicators();
45 | recyclerView.removeOnScrollListener(mInternalOnScrollListener);
46 | recyclerView.addOnScrollListener(mInternalOnScrollListener);
47 | }
48 |
49 | private void createIndicators() {
50 | RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
51 | int count;
52 | if (adapter == null) {
53 | count = 0;
54 | } else {
55 | count = adapter.getItemCount();
56 | }
57 | createIndicators(count, getSnapPosition(mRecyclerView.getLayoutManager()));
58 | }
59 |
60 | public int getSnapPosition(@Nullable RecyclerView.LayoutManager layoutManager) {
61 | if (layoutManager == null) {
62 | return RecyclerView.NO_POSITION;
63 | }
64 | View snapView = mSnapHelper.findSnapView(layoutManager);
65 | if (snapView == null) {
66 | return RecyclerView.NO_POSITION;
67 | }
68 | return layoutManager.getPosition(snapView);
69 | }
70 |
71 | private final RecyclerView.OnScrollListener mInternalOnScrollListener =
72 | new RecyclerView.OnScrollListener() {
73 | @Override
74 | public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
75 | super.onScrolled(recyclerView, dx, dy);
76 |
77 | int position = getSnapPosition(recyclerView.getLayoutManager());
78 | if (position == RecyclerView.NO_POSITION) {
79 | return;
80 | }
81 | animatePageSelected(position);
82 | }
83 | };
84 |
85 | private final RecyclerView.AdapterDataObserver mAdapterDataObserver =
86 | new RecyclerView.AdapterDataObserver() {
87 | @Override public void onChanged() {
88 | super.onChanged();
89 | if (mRecyclerView == null) {
90 | return;
91 | }
92 | RecyclerView.Adapter adapter = mRecyclerView.getAdapter();
93 | int newCount = adapter != null ? adapter.getItemCount() : 0;
94 | int currentCount = getChildCount();
95 | if (newCount == currentCount) {
96 | // No change
97 | return;
98 | } else if (mLastPosition < newCount) {
99 | mLastPosition = getSnapPosition(mRecyclerView.getLayoutManager());
100 | } else {
101 | mLastPosition = RecyclerView.NO_POSITION;
102 | }
103 | createIndicators();
104 | }
105 |
106 | @Override public void onItemRangeChanged(int positionStart, int itemCount) {
107 | super.onItemRangeChanged(positionStart, itemCount);
108 | onChanged();
109 | }
110 |
111 | @Override public void onItemRangeChanged(int positionStart, int itemCount,
112 | @Nullable Object payload) {
113 | super.onItemRangeChanged(positionStart, itemCount, payload);
114 | onChanged();
115 | }
116 |
117 | @Override public void onItemRangeInserted(int positionStart, int itemCount) {
118 | super.onItemRangeInserted(positionStart, itemCount);
119 | onChanged();
120 | }
121 |
122 | @Override public void onItemRangeRemoved(int positionStart, int itemCount) {
123 | super.onItemRangeRemoved(positionStart, itemCount);
124 | onChanged();
125 | }
126 |
127 | @Override
128 | public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
129 | super.onItemRangeMoved(fromPosition, toPosition, itemCount);
130 | onChanged();
131 | }
132 | };
133 |
134 | public RecyclerView.AdapterDataObserver getAdapterDataObserver() {
135 | return mAdapterDataObserver;
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/CircleIndicator3.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.os.Build;
6 | import android.util.AttributeSet;
7 | import androidx.annotation.Nullable;
8 | import androidx.recyclerview.widget.RecyclerView;
9 | import androidx.viewpager2.widget.ViewPager2;
10 |
11 | /**
12 | * CircleIndicator work with ViewPager2
13 | */
14 | public class CircleIndicator3 extends BaseCircleIndicator {
15 |
16 | private ViewPager2 mViewpager;
17 |
18 | public CircleIndicator3(Context context) {
19 | super(context);
20 | }
21 |
22 | public CircleIndicator3(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | public CircleIndicator3(Context context, AttributeSet attrs, int defStyleAttr) {
27 | super(context, attrs, defStyleAttr);
28 | }
29 |
30 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
31 | public CircleIndicator3(Context context, AttributeSet attrs, int defStyleAttr,
32 | int defStyleRes) {
33 | super(context, attrs, defStyleAttr, defStyleRes);
34 | }
35 |
36 | public void setViewPager(@Nullable ViewPager2 viewPager) {
37 | mViewpager = viewPager;
38 | if (mViewpager != null && mViewpager.getAdapter() != null) {
39 | mLastPosition = -1;
40 | createIndicators();
41 | mViewpager.unregisterOnPageChangeCallback(mInternalPageChangeCallback);
42 | mViewpager.registerOnPageChangeCallback(mInternalPageChangeCallback);
43 | mInternalPageChangeCallback.onPageSelected(mViewpager.getCurrentItem());
44 | }
45 | }
46 |
47 | private void createIndicators() {
48 | RecyclerView.Adapter adapter = mViewpager.getAdapter();
49 | int count;
50 | if (adapter == null) {
51 | count = 0;
52 | } else {
53 | count = adapter.getItemCount();
54 | }
55 | createIndicators(count, mViewpager.getCurrentItem());
56 | }
57 |
58 | private final ViewPager2.OnPageChangeCallback mInternalPageChangeCallback =
59 | new ViewPager2.OnPageChangeCallback() {
60 | @Override public void onPageSelected(int position) {
61 | if (position == mLastPosition
62 | || mViewpager.getAdapter() == null
63 | || mViewpager.getAdapter().getItemCount() <= 0) {
64 | return;
65 | }
66 | animatePageSelected(position);
67 | }
68 | };
69 |
70 | private final RecyclerView.AdapterDataObserver mAdapterDataObserver =
71 | new RecyclerView.AdapterDataObserver() {
72 | @Override public void onChanged() {
73 | super.onChanged();
74 | if (mViewpager == null) {
75 | return;
76 | }
77 | RecyclerView.Adapter adapter = mViewpager.getAdapter();
78 | int newCount = adapter != null ? adapter.getItemCount() : 0;
79 | int currentCount = getChildCount();
80 | if (newCount == currentCount) {
81 | // No change
82 | return;
83 | } else if (mLastPosition < newCount) {
84 | mLastPosition = mViewpager.getCurrentItem();
85 | } else {
86 | mLastPosition = RecyclerView.NO_POSITION;
87 | }
88 | createIndicators();
89 | }
90 |
91 | @Override public void onItemRangeChanged(int positionStart, int itemCount) {
92 | super.onItemRangeChanged(positionStart, itemCount);
93 | onChanged();
94 | }
95 |
96 | @Override public void onItemRangeChanged(int positionStart, int itemCount,
97 | @Nullable Object payload) {
98 | super.onItemRangeChanged(positionStart, itemCount, payload);
99 | onChanged();
100 | }
101 |
102 | @Override public void onItemRangeInserted(int positionStart, int itemCount) {
103 | super.onItemRangeInserted(positionStart, itemCount);
104 | onChanged();
105 | }
106 |
107 | @Override public void onItemRangeRemoved(int positionStart, int itemCount) {
108 | super.onItemRangeRemoved(positionStart, itemCount);
109 | onChanged();
110 | }
111 |
112 | @Override
113 | public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
114 | super.onItemRangeMoved(fromPosition, toPosition, itemCount);
115 | onChanged();
116 | }
117 | };
118 |
119 | public RecyclerView.AdapterDataObserver getAdapterDataObserver() {
120 | return mAdapterDataObserver;
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/Config.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.view.Gravity;
4 | import android.widget.LinearLayout;
5 | import androidx.annotation.AnimatorRes;
6 | import androidx.annotation.DrawableRes;
7 |
8 | public class Config {
9 |
10 | int width = -1;
11 | int height = -1;
12 | int margin = -1;
13 | @AnimatorRes int animatorResId = R.animator.scale_with_alpha;
14 | @AnimatorRes int animatorReverseResId = 0;
15 | @DrawableRes int backgroundResId = R.drawable.white_radius;
16 | @DrawableRes int unselectedBackgroundId;
17 | int orientation = LinearLayout.HORIZONTAL;
18 | int gravity = Gravity.CENTER;
19 |
20 | Config() {
21 | }
22 |
23 | public static class Builder {
24 |
25 | private final Config mConfig;
26 |
27 | public Builder() {
28 | mConfig = new Config();
29 | }
30 |
31 | public Builder width(int width) {
32 | mConfig.width = width;
33 | return this;
34 | }
35 |
36 | public Builder height(int height) {
37 | mConfig.height = height;
38 | return this;
39 | }
40 |
41 | public Builder margin(int margin) {
42 | mConfig.margin = margin;
43 | return this;
44 | }
45 |
46 | public Builder animator(@AnimatorRes int animatorResId) {
47 | mConfig.animatorResId = animatorResId;
48 | return this;
49 | }
50 |
51 | public Builder animatorReverse(@AnimatorRes int animatorReverseResId) {
52 | mConfig.animatorReverseResId = animatorReverseResId;
53 | return this;
54 | }
55 |
56 | public Builder drawable(@DrawableRes int backgroundResId) {
57 | mConfig.backgroundResId = backgroundResId;
58 | return this;
59 | }
60 |
61 | public Builder drawableUnselected(@DrawableRes int unselectedBackgroundId) {
62 | mConfig.unselectedBackgroundId = unselectedBackgroundId;
63 | return this;
64 | }
65 |
66 | public Builder orientation(int orientation) {
67 | mConfig.orientation = orientation;
68 | return this;
69 | }
70 |
71 | public Builder gravity(int gravity) {
72 | mConfig.gravity = gravity;
73 | return this;
74 | }
75 |
76 | public Config build() {
77 | return mConfig;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/circleindicator/src/main/java/me/relex/circleindicator/SnackbarBehavior.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import androidx.annotation.NonNull;
7 | import androidx.coordinatorlayout.widget.CoordinatorLayout;
8 | import com.google.android.material.snackbar.Snackbar;
9 | import java.util.List;
10 |
11 | public class SnackbarBehavior extends CoordinatorLayout.Behavior {
12 |
13 | public SnackbarBehavior() {
14 | }
15 |
16 | public SnackbarBehavior(Context context, AttributeSet attributeSet) {
17 | super(context, attributeSet);
18 | }
19 |
20 | @Override public boolean layoutDependsOn(@NonNull CoordinatorLayout parent,
21 | @NonNull BaseCircleIndicator child, @NonNull View dependency) {
22 | return dependency instanceof Snackbar.SnackbarLayout;
23 | }
24 |
25 | @Override public boolean onDependentViewChanged(@NonNull CoordinatorLayout parent,
26 | @NonNull BaseCircleIndicator child, @NonNull View dependency) {
27 | float translationY = getTranslationYForSnackbar(parent, child);
28 | child.setTranslationY(translationY);
29 | return true;
30 | }
31 |
32 | private float getTranslationYForSnackbar(CoordinatorLayout parent, BaseCircleIndicator ci) {
33 | float minOffset = 0;
34 | final List dependencies = parent.getDependencies(ci);
35 | for (int i = 0, z = dependencies.size(); i < z; i++) {
36 | final View view = dependencies.get(i);
37 | if (view instanceof Snackbar.SnackbarLayout && parent.doViewsOverlap(ci, view)) {
38 | minOffset = Math.min(minOffset, view.getTranslationY() - view.getHeight());
39 | }
40 | }
41 |
42 | return minOffset;
43 | }
44 | }
--------------------------------------------------------------------------------
/circleindicator/src/main/res/animator/scale_with_alpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
16 |
17 |
22 |
--------------------------------------------------------------------------------
/circleindicator/src/main/res/drawable/white_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
--------------------------------------------------------------------------------
/circleindicator/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
45 |
46 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/circleindicator/upload-jcenter.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'com.jfrog.bintray'
3 |
4 | group = "me.relex"
5 |
6 | task sourcesJar(type: Jar) {
7 | from android.sourceSets.main.java.srcDirs
8 | classifier = 'sources'
9 | }
10 | task javadoc(type: Javadoc) {
11 | source = android.sourceSets.main.java.srcDirs
12 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
13 | }
14 | task javadocJar(type: Jar, dependsOn: javadoc) {
15 | classifier = 'javadoc'
16 | from javadoc.destinationDir
17 | }
18 | artifacts {
19 | archives javadocJar
20 | archives sourcesJar
21 | }
22 |
23 | afterEvaluate {
24 | publishing {
25 | publications {
26 | release(MavenPublication) {
27 | from components.release
28 | groupId = "me.relex"
29 | artifactId = 'circleindicator'
30 | version = this.version
31 | pom.withXml {
32 | def dependenciesNode = asNode()['dependencies'][0] ?: asNode().appendNode(
33 | 'dependencies')
34 | configurations.implementation.allDependencies.each {
35 | if (it.name != 'unspecified') {
36 | def dependencyNode = dependenciesNode.appendNode('dependency')
37 | dependencyNode.appendNode('groupId', it.group)
38 | dependencyNode.appendNode('artifactId', it.name)
39 | dependencyNode.appendNode('version', it.version)
40 | }
41 | }
42 | }
43 | }
44 | }
45 | }
46 | }
47 |
48 | bintray {
49 | user = bintrayUsername
50 | key = bintrayApiKey
51 | configurations = ['archives']
52 | publications = ['release']
53 | override = true
54 | pkg {
55 | repo = "maven"
56 | name = "CircleIndicator"
57 | websiteUrl = 'https://github.com/ongakuer/CircleIndicator'
58 | vcsUrl = 'https://github.com/ongakuer/CircleIndicator.git'
59 | licenses = ["Apache-2.0"]
60 | publish = true
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/circleindicator/upload-maven-plugin.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven-publish'
2 | apply plugin: 'signing'
3 |
4 | ext {
5 | PUBLISH_DEVELOPER = "Relex"
6 | PUBLISH_NAME = "CircleIndicator"
7 | PUBLISH_DESCRIPTION = "A lightweight indicator"
8 | PUBLISH_URL = "https://github.com/ongakuer/CircleIndicator"
9 | PUBLISH_GIT_URL = "https://github.com/ongakuer/CircleIndicator.git"
10 | PUBLISH_GROUP_ID = "me.relex"
11 | PUBLISH_ARTIFACT_ID = "circleindicator"
12 | PUBLISH_VERSION = android.defaultConfig.versionName
13 | }
14 |
15 | task androidJavadocs(type: Javadoc) {
16 | source = android.sourceSets.main.java.srcDirs
17 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
18 | android.libraryVariants.all { variant ->
19 | if (variant.name == 'release') {
20 | if (variant.hasProperty('javaCompileProvider')) {
21 | owner.classpath += variant.javaCompileProvider.get().classpath
22 | } else {
23 | owner.classpath += variant.javaCompiler.classpath
24 | }
25 | }
26 | }
27 | options {
28 | encoding 'utf-8'
29 | charSet 'utf-8'
30 | }
31 | exclude '**/R.html', '**/R.*.html', '**/index.html', '**/*.kt'
32 | }
33 |
34 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
35 | archiveClassifier.set('javadoc')
36 | from androidJavadocs.destinationDir
37 | }
38 |
39 | task androidSourcesJar(type: Jar) {
40 | archiveClassifier.set('sources')
41 | from android.sourceSets.main.java.srcDirs
42 | }
43 |
44 | project.artifacts {
45 | archives androidJavadocsJar, androidSourcesJar
46 | }
47 |
48 | afterEvaluate {
49 |
50 | publishing {
51 | publications {
52 | maven(MavenPublication) {
53 | groupId project.ext.PUBLISH_GROUP_ID
54 | artifactId project.ext.PUBLISH_ARTIFACT_ID
55 | version project.ext.PUBLISH_VERSION
56 |
57 | artifact bundleReleaseAar
58 | artifact androidJavadocsJar
59 | artifact androidSourcesJar
60 |
61 | pom {
62 | name = project.ext.PUBLISH_NAME
63 | description = project.ext.PUBLISH_DESCRIPTION
64 | url = project.ext.PUBLISH_URL
65 | licenses {
66 | license {
67 | name = 'The Apache License, Version 2.0'
68 | url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
69 | }
70 | }
71 | developers {
72 | developer {
73 | name = project.ext.PUBLISH_DEVELOPER
74 | }
75 | }
76 | scm {
77 | connection = "scm:git:${project.ext.PUBLISH_GIT_URL}"
78 | url = project.ext.PUBLISH_URL
79 | }
80 | }
81 |
82 | pom.withXml {
83 | final dependenciesNode = asNode().appendNode('dependencies')
84 | // Dependency
85 | ext.addDependency = { Dependency dep, String scope ->
86 | if (dep.group == null ||
87 | dep.version ==
88 | null ||
89 | dep.name ==
90 | null ||
91 | dep.name ==
92 | "unspecified") {
93 | return
94 | }
95 |
96 | final dependencyNode = dependenciesNode.appendNode('dependency')
97 | dependencyNode.appendNode('artifactId', dep.name)
98 |
99 | if (dep.version == 'unspecified') {
100 | return
101 | } else {
102 | dependencyNode.appendNode('groupId', dep.group)
103 | dependencyNode.appendNode('version', dep.version)
104 | System.println("${dep.group} ${dep.name} ${dep.version}")
105 | }
106 |
107 | dependencyNode.appendNode('scope', scope)
108 | def artifactsList = dep.properties['artifacts']
109 | if (artifactsList != null && artifactsList.size() > 0) {
110 | final artifact = artifactsList[0]
111 | dependencyNode.appendNode('type', artifact.getType())
112 | }
113 |
114 | if (!dep.transitive) {
115 | final exclusionNode = dependencyNode.
116 | appendNode('exclusions').
117 | appendNode('exclusion')
118 | exclusionNode.appendNode('groupId', '*')
119 | exclusionNode.appendNode('artifactId', '*')
120 | } else if (!dep.properties.excludeRules.empty) {
121 | final exclusions = dependencyNode.appendNode('exclusions')
122 | dep.properties.excludeRules.each { ExcludeRule rule ->
123 | final exclusionNode = exclusions.appendNode('exclusion')
124 | exclusionNode.appendNode('groupId', rule.group ?: '*')
125 | exclusionNode.appendNode('artifactId', rule.module ?: '*')
126 | }
127 | }
128 | }
129 | configurations.
130 | api.
131 | getDependencies().
132 | each { dep -> addDependency(dep, "compile") }
133 | configurations.
134 | implementation.
135 | getDependencies().
136 | each { dep -> addDependency(dep, "runtime") }
137 | }
138 | }
139 | }
140 |
141 | repositories {
142 | maven {
143 | url "$sonatypeRepo"
144 | credentials {
145 | username "$sonatypeUsername"
146 | password "$sonatypePassword"
147 | }
148 | }
149 | }
150 | }
151 |
152 | signing {
153 | sign publishing.publications.maven
154 | }
155 | }
156 |
157 | //task cleanBuildPublish(type: GradleBuild) {
158 | // tasks = ['clean', 'build', 'publish']
159 | //}
--------------------------------------------------------------------------------
/circleindicator/upload-maven.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'maven'
2 | apply plugin: 'signing'
3 |
4 | ext {
5 | PUBLISH_DEVELOPER = "Relex"
6 | PUBLISH_NAME = "CircleIndicator"
7 | PUBLISH_DESCRIPTION = "A lightweight indicator"
8 | PUBLISH_URL = "https://github.com/ongakuer/CircleIndicator"
9 | PUBLISH_GIT_URL = "https://github.com/ongakuer/CircleIndicator.git"
10 | PUBLISH_GROUP_ID = "me.relex"
11 | PUBLISH_ARTIFACT_ID = "circleindicator"
12 | PUBLISH_VERSION = android.defaultConfig.versionName
13 | }
14 |
15 | task androidJavadocs(type: Javadoc) {
16 | source = android.sourceSets.main.java.srcDirs
17 |
18 | android.libraryVariants.all { variant ->
19 | if (variant.name == 'release') {
20 | if (variant.hasProperty('javaCompileProvider')) {
21 | owner.classpath += variant.javaCompileProvider.get().classpath
22 | } else {
23 | owner.classpath += variant.javaCompiler.classpath
24 | }
25 | }
26 | }
27 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
28 | options {
29 | encoding 'utf-8'
30 | charSet 'utf-8'
31 | }
32 | exclude '**/R.html', '**/R.*.html', '**/index.html', '**/*.kt'
33 | }
34 |
35 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
36 | // classifier = 'javadoc'
37 | archiveClassifier.convention('javadoc')
38 | archiveClassifier.set('javadoc')
39 | from androidJavadocs.destinationDir
40 | }
41 |
42 | task androidSourcesJar(type: Jar) {
43 | // classifier = 'sources'
44 | archiveClassifier.convention('sources')
45 | archiveClassifier.set('sources')
46 | from android.sourceSets.main.java.srcDirs
47 | }
48 |
49 | artifacts {
50 | archives androidSourcesJar
51 | archives androidJavadocsJar
52 | }
53 |
54 | signing {
55 | // required { project.has("release") && gradle.taskGraph.hasTask("uploadArchives") }
56 | sign configurations.archives
57 | }
58 |
59 | uploadArchives {
60 | repositories {
61 | mavenDeployer {
62 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
63 |
64 | try {
65 | repository(url: "$sonatypeRepo") {
66 | authentication(userName: "$sonatypeUsername", password: "$sonatypePassword")
67 | }
68 | } catch (ignored) {
69 | throw new InvalidUserDataException("Missing authentication ")
70 | }
71 |
72 | pom.groupId = project.PUBLISH_GROUP_ID
73 | pom.artifactId = project.PUBLISH_ARTIFACT_ID
74 | pom.version = project.PUBLISH_VERSION
75 | pom.project {
76 | name project.PUBLISH_NAME
77 | description project.PUBLISH_DESCRIPTION
78 | url project.PUBLISH_URL
79 | scm {
80 | connection "scm:git:${project.PUBLISH_GIT_URL}"
81 | url project.PUBLISH_URL
82 | }
83 | licenses {
84 | license {
85 | name 'The Apache Software License, Version 2.0'
86 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
87 | }
88 | }
89 | developers {
90 | developer {
91 | name project.PUBLISH_DEVELOPER
92 | }
93 | }
94 | }
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Settings specified in this file will override any Gradle settings
4 | # configured through the IDE.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
10 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
11 | # When configured, Gradle will run in incubating parallel mode.
12 | # This option should only be used with decoupled projects. More details, visit
13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
14 | # org.gradle.parallel=true
15 | android.useAndroidX=true
16 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Sep 07 11:32:06 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/sample/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 29
5 |
6 | defaultConfig {
7 | applicationId "me.relex.circleindicator.sample"
8 | minSdkVersion 14
9 | targetSdkVersion 29
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 |
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 |
21 | lintOptions {
22 | abortOnError false
23 | }
24 | compileOptions {
25 | sourceCompatibility = '1.8'
26 | targetCompatibility = '1.8'
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation 'com.google.android.material:material:1.2.1'
32 | implementation 'androidx.appcompat:appcompat:1.2.0'
33 | implementation 'androidx.recyclerview:recyclerview:1.1.0'
34 | implementation 'androidx.viewpager:viewpager:1.0.0'
35 | implementation 'androidx.viewpager2:viewpager2:1.0.0'
36 |
37 | implementation 'me.relex:recyclerpager:1.0.4'
38 |
39 | api project(':circleindicator')
40 | api project(':LoopingViewPager')
41 | }
42 |
--------------------------------------------------------------------------------
/sample/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/LoopRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample;
2 |
3 | import androidx.annotation.NonNull;
4 |
5 | public class LoopRecyclerAdapter extends SampleRecyclerAdapter {
6 | public LoopRecyclerAdapter(int count) {
7 | super(count);
8 | }
9 |
10 | @Override public int getItemCount() {
11 | if (mCount > 1) {
12 | return mCount + 2;
13 | } else {
14 | return mCount;
15 | }
16 | }
17 |
18 | public int getRealItemCount() {
19 | return mCount;
20 | }
21 |
22 | public int getRealPosition(int position) {
23 | if (mCount <= 1) {
24 | return 0;
25 | } else {
26 | return position % mCount;
27 | }
28 | }
29 |
30 | public int getLoopPosition(int position) {
31 | int realPosition = getRealPosition(position);
32 | if (realPosition == 0) {
33 | return mCount;
34 | } else {
35 | return realPosition;
36 | }
37 | }
38 |
39 | @Override public void onBindViewHolder(@NonNull TextViewHolder holder, int position) {
40 | holder.bindView(getRealPosition(position));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/SampleActivity.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.appcompat.app.ActionBar;
11 | import androidx.appcompat.app.AppCompatActivity;
12 | import androidx.appcompat.widget.Toolbar;
13 | import androidx.fragment.app.Fragment;
14 | import androidx.fragment.app.FragmentTransaction;
15 | import androidx.recyclerview.widget.LinearLayoutManager;
16 | import androidx.recyclerview.widget.RecyclerView;
17 | import java.util.ArrayList;
18 | import java.util.List;
19 | import me.relex.circleindicator.sample.fragment.ChangeDrawableFragment;
20 | import me.relex.circleindicator.sample.fragment.CustomAnimationFragment;
21 | import me.relex.circleindicator.sample.fragment.DefaultFragment;
22 | import me.relex.circleindicator.sample.fragment.DynamicAdapterFragment;
23 | import me.relex.circleindicator.sample.fragment.LoopRecyclerViewFragment;
24 | import me.relex.circleindicator.sample.fragment.LoopViewPagerFragment;
25 | import me.relex.circleindicator.sample.fragment.RecyclerViewFragment;
26 | import me.relex.circleindicator.sample.fragment.ResetAdapterFragment;
27 | import me.relex.circleindicator.sample.fragment.SnackbarBehaviorFragment;
28 | import me.relex.circleindicator.sample.fragment.ViewPager2Fragment;
29 |
30 | public class SampleActivity extends AppCompatActivity {
31 |
32 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 |
35 | setContentView(R.layout.activity_sample);
36 |
37 | initToolbar();
38 |
39 | Fragment demoFragment = getSupportFragmentManager().getFragmentFactory()
40 | .instantiate(getClassLoader(), SampleListFragment.class.getName());
41 | FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
42 | fragmentTransaction.replace(R.id.fragment_container, demoFragment);
43 | fragmentTransaction.commit();
44 |
45 | getSupportFragmentManager().addOnBackStackChangedListener(() -> {
46 | int count = getSupportFragmentManager().getBackStackEntryCount();
47 | ActionBar actionbar = getSupportActionBar();
48 | if (actionbar != null) {
49 | actionbar.setDisplayHomeAsUpEnabled(count > 0);
50 | actionbar.setDisplayShowHomeEnabled(count > 0);
51 | }
52 | });
53 | }
54 |
55 | private void initToolbar() {
56 | Toolbar toolbar = findViewById(R.id.toolbar);
57 | setSupportActionBar(toolbar);
58 | toolbar.setNavigationOnClickListener(v -> onBackPressed());
59 | }
60 |
61 | public static class SampleListFragment extends Fragment {
62 |
63 | @Nullable @Override
64 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
65 | @Nullable Bundle savedInstanceState) {
66 | return new RecyclerView(getContext());
67 | }
68 |
69 | @Override
70 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
71 | SampleListAdapter adapter = new SampleListAdapter();
72 |
73 | RecyclerView recyclerView = (RecyclerView) view;
74 | recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
75 | recyclerView.setAdapter(adapter);
76 |
77 | adapter.add(new SampleInfo("Default", DefaultFragment.class.getName()));
78 | adapter.add(
79 | new SampleInfo("Custom Animation", CustomAnimationFragment.class.getName()));
80 | adapter.add(new SampleInfo("Change Drawable", ChangeDrawableFragment.class.getName()));
81 | adapter.add(new SampleInfo("Dynamic Adapter", DynamicAdapterFragment.class.getName()));
82 | adapter.add(new SampleInfo("Reset Adapter", ResetAdapterFragment.class.getName()));
83 | adapter.add(new SampleInfo("LoopViewPager", LoopViewPagerFragment.class.getName()));
84 | adapter.add(
85 | new SampleInfo("Snackbar Behavior", SnackbarBehaviorFragment.class.getName()));
86 | adapter.add(new SampleInfo("RecyclerView (CircleIndicator2)",
87 | RecyclerViewFragment.class.getName()));
88 | adapter.add(new SampleInfo("LoopRecyclerView (CircleIndicator2) and Manual control",
89 | LoopRecyclerViewFragment.class.getName()));
90 | adapter.add(new SampleInfo("AndroidX ViewPager2 (CircleIndicator3)",
91 | ViewPager2Fragment.class.getName()));
92 | }
93 |
94 | private class SampleListAdapter extends RecyclerView.Adapter {
95 |
96 | private final List mList = new ArrayList<>();
97 |
98 | @NonNull @Override
99 | public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
100 | return ItemViewHolder.create(parent);
101 | }
102 |
103 | @Override
104 | public void onBindViewHolder(@NonNull final ItemViewHolder holder, int position) {
105 | SampleInfo sample = mList.get(position);
106 | holder.bindView(sample.title);
107 | holder.itemView.setOnClickListener(new View.OnClickListener() {
108 | @Override public void onClick(View v) {
109 | navigateToFragment(mList.get(holder.getAdapterPosition()).fragmentName);
110 | }
111 | });
112 | }
113 |
114 | @Override public int getItemCount() {
115 | return mList.size();
116 | }
117 |
118 | public boolean add(SampleInfo object) {
119 | int lastIndex = mList.size();
120 | if (mList.add(object)) {
121 | notifyItemInserted(lastIndex);
122 | return true;
123 | } else {
124 | return false;
125 | }
126 | }
127 | }
128 |
129 | private void navigateToFragment(String fragmentName) {
130 | Fragment fragment = getFragmentManager().getFragmentFactory()
131 | .instantiate(getContext().getClassLoader(), fragmentName);
132 | FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
133 |
134 | fragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,
135 | android.R.anim.fade_in, android.R.anim.fade_out);
136 | fragmentTransaction.replace(R.id.fragment_container, fragment);
137 | fragmentTransaction.addToBackStack(fragmentName);
138 | fragmentTransaction.commit();
139 | }
140 |
141 | private static class ItemViewHolder extends RecyclerView.ViewHolder {
142 | ItemViewHolder(View itemView) {
143 | super(itemView);
144 | }
145 |
146 | void bindView(String title) {
147 | ((TextView) itemView).setText(title);
148 | }
149 |
150 | static ItemViewHolder create(ViewGroup viewGroup) {
151 | return new ItemViewHolder(LayoutInflater.from(viewGroup.getContext())
152 | .inflate(R.layout.item_view, viewGroup, false));
153 | }
154 | }
155 |
156 | private static class SampleInfo {
157 | public final String title;
158 | final String fragmentName;
159 |
160 | SampleInfo(String title, String fragmentName) {
161 | this.title = title;
162 | this.fragmentName = fragmentName;
163 | }
164 | }
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/SamplePagerAdapter.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample;
2 |
3 | import android.graphics.Color;
4 | import androidx.annotation.NonNull;
5 | import androidx.viewpager.widget.PagerAdapter;
6 | import android.view.Gravity;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 | import java.util.Random;
11 |
12 | public class SamplePagerAdapter extends PagerAdapter {
13 |
14 | private final Random random = new Random();
15 | private int mSize;
16 |
17 | public SamplePagerAdapter() {
18 | mSize = 5;
19 | }
20 |
21 | public SamplePagerAdapter(int count) {
22 | mSize = count;
23 | }
24 |
25 | @Override public int getCount() {
26 | return mSize;
27 | }
28 |
29 | @Override public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
30 | return view == object;
31 | }
32 |
33 | @Override
34 | public void destroyItem(@NonNull ViewGroup view, int position, @NonNull Object object) {
35 | view.removeView((View) object);
36 | }
37 |
38 | @NonNull @Override public Object instantiateItem(@NonNull ViewGroup view, int position) {
39 | TextView textView = new TextView(view.getContext());
40 | textView.setText(String.valueOf(position + 1));
41 | textView.setBackgroundColor(0xff000000 | random.nextInt(0x00ffffff));
42 | textView.setGravity(Gravity.CENTER);
43 | textView.setTextColor(Color.WHITE);
44 | textView.setTextSize(48);
45 | view.addView(textView, ViewGroup.LayoutParams.MATCH_PARENT,
46 | ViewGroup.LayoutParams.MATCH_PARENT);
47 | return textView;
48 | }
49 |
50 | public void addItem() {
51 | mSize++;
52 | notifyDataSetChanged();
53 | }
54 |
55 | public void removeItem() {
56 | mSize--;
57 | mSize = mSize < 0 ? 0 : mSize;
58 |
59 | notifyDataSetChanged();
60 | }
61 | }
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/SampleRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample;
2 |
3 | import android.graphics.Color;
4 | import android.view.Gravity;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 | import androidx.annotation.NonNull;
9 | import androidx.recyclerview.widget.RecyclerView;
10 | import java.util.Random;
11 |
12 | public class SampleRecyclerAdapter
13 | extends RecyclerView.Adapter {
14 |
15 | protected int mCount;
16 |
17 | public SampleRecyclerAdapter(int count) {
18 | mCount = count;
19 | }
20 |
21 | @NonNull @Override
22 | public TextViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
23 | return TextViewHolder.createViewHolder(parent);
24 | }
25 |
26 | @Override public void onBindViewHolder(@NonNull TextViewHolder holder, int position) {
27 | holder.bindView(position);
28 | }
29 |
30 | @Override public int getItemCount() {
31 | return mCount;
32 | }
33 |
34 | public void add() {
35 | int position = mCount;
36 | mCount++;
37 | notifyItemInserted(position);
38 | }
39 |
40 | public void remove() {
41 | if (mCount == 0) {
42 | return;
43 | }
44 | mCount--;
45 | int position = mCount;
46 | notifyItemRemoved(position);
47 | }
48 |
49 | static class TextViewHolder extends RecyclerView.ViewHolder {
50 |
51 | private final Random random = new Random();
52 |
53 | static TextViewHolder createViewHolder(@NonNull ViewGroup parent) {
54 | TextView textView = new TextView(parent.getContext());
55 | textView.setGravity(Gravity.CENTER);
56 | textView.setTextColor(Color.WHITE);
57 | textView.setTextSize(48);
58 | textView.setLayoutParams(
59 | new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT,
60 | RecyclerView.LayoutParams.MATCH_PARENT));
61 | return new TextViewHolder(textView);
62 | }
63 |
64 | TextViewHolder(@NonNull View itemView) {
65 | super(itemView);
66 | }
67 |
68 | void bindView(int position) {
69 | TextView textView = (TextView) itemView;
70 | textView.setText(String.valueOf(position + 1));
71 | textView.setBackgroundColor(0xff000000 | random.nextInt(0x00ffffff));
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/ChangeDrawableFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.fragment.app.Fragment;
11 | import androidx.viewpager.widget.ViewPager;
12 | import me.relex.circleindicator.CircleIndicator;
13 | import me.relex.circleindicator.sample.R;
14 | import me.relex.circleindicator.sample.SamplePagerAdapter;
15 |
16 | public class ChangeDrawableFragment extends Fragment {
17 |
18 | @Nullable @Override
19 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
20 | @Nullable Bundle savedInstanceState) {
21 | return inflater.inflate(R.layout.fragment_sample_change_drawable, container, false);
22 | }
23 |
24 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
25 | ViewPager viewpager = view.findViewById(R.id.viewpager);
26 | CircleIndicator indicator = view.findViewById(R.id.indicator);
27 | viewpager.setAdapter(new SamplePagerAdapter());
28 | indicator.setViewPager(viewpager);
29 |
30 | view.findViewById(R.id.change_drawable_view)
31 | .setOnClickListener(
32 | v -> indicator.changeIndicatorResource(R.drawable.black_radius,R.drawable.white_radius));
33 |
34 | view.findViewById(R.id.tint_view)
35 | .setOnClickListener(v -> indicator.tintIndicator(Color.RED, Color.BLUE));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/CustomAnimationFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.util.TypedValue;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.fragment.app.Fragment;
11 | import androidx.viewpager.widget.ViewPager;
12 | import me.relex.circleindicator.CircleIndicator;
13 | import me.relex.circleindicator.Config;
14 | import me.relex.circleindicator.sample.R;
15 | import me.relex.circleindicator.sample.SamplePagerAdapter;
16 |
17 | public class CustomAnimationFragment extends Fragment {
18 |
19 | @Nullable @Override
20 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
21 | @Nullable Bundle savedInstanceState) {
22 | return inflater.inflate(R.layout.fragment_sample_custom_animation, container, false);
23 | }
24 |
25 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
26 |
27 | int indicatorWidth = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
28 | getResources().getDisplayMetrics()) + 0.5f);
29 | int indicatorHeight = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4,
30 | getResources().getDisplayMetrics()) + 0.5f);
31 | int indicatorMargin = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6,
32 | getResources().getDisplayMetrics()) + 0.5f);
33 |
34 | ViewPager viewpager = view.findViewById(R.id.viewpager);
35 |
36 | CircleIndicator indicator = view.findViewById(R.id.indicator);
37 | Config config = new Config.Builder().width(indicatorWidth)
38 | .height(indicatorHeight)
39 | .margin(indicatorMargin)
40 | .animator(R.animator.indicator_animator)
41 | .animatorReverse(R.animator.indicator_animator_reverse)
42 | .drawable(R.drawable.black_radius_square)
43 | .build();
44 | indicator.initialize(config);
45 |
46 | viewpager.setAdapter(new SamplePagerAdapter());
47 | indicator.setViewPager(viewpager);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/DefaultFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.viewpager.widget.ViewPager;
11 | import me.relex.circleindicator.CircleIndicator;
12 | import me.relex.circleindicator.sample.R;
13 | import me.relex.circleindicator.sample.SamplePagerAdapter;
14 |
15 | public class DefaultFragment extends Fragment {
16 |
17 | @Nullable @Override
18 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
19 | @Nullable Bundle savedInstanceState) {
20 | return inflater.inflate(R.layout.fragment_sample_default, container, false);
21 | }
22 |
23 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
24 | ViewPager viewpager = view.findViewById(R.id.viewpager);
25 | CircleIndicator indicator = view.findViewById(R.id.indicator);
26 | viewpager.setAdapter(new SamplePagerAdapter());
27 | indicator.setViewPager(viewpager);
28 | viewpager.setCurrentItem(2);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/DynamicAdapterFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import androidx.fragment.app.Fragment;
7 | import androidx.viewpager.widget.ViewPager;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import me.relex.circleindicator.CircleIndicator;
12 | import me.relex.circleindicator.sample.R;
13 | import me.relex.circleindicator.sample.SamplePagerAdapter;
14 |
15 | public class DynamicAdapterFragment extends Fragment implements View.OnClickListener {
16 |
17 | private SamplePagerAdapter mAdapter;
18 |
19 | @Nullable @Override
20 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
21 | @Nullable Bundle savedInstanceState) {
22 | return inflater.inflate(R.layout.fragment_sample_dynamic_adapter, container, false);
23 | }
24 |
25 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
26 |
27 | view.findViewById(R.id.add).setOnClickListener(this);
28 | view.findViewById(R.id.remove).setOnClickListener(this);
29 |
30 | mAdapter = new SamplePagerAdapter(1) {
31 | @Override public int getItemPosition(@NonNull Object object) {
32 | return POSITION_NONE;
33 | }
34 | };
35 |
36 | ViewPager viewpager = view.findViewById(R.id.viewpager);
37 | CircleIndicator indicator = view.findViewById(R.id.indicator);
38 | viewpager.setAdapter(mAdapter);
39 | indicator.setViewPager(viewpager);
40 | mAdapter.registerDataSetObserver(indicator.getDataSetObserver());
41 | }
42 |
43 | @Override public void onClick(View v) {
44 | switch (v.getId()) {
45 | case R.id.add:
46 | mAdapter.addItem();
47 | break;
48 | case R.id.remove:
49 | mAdapter.removeItem();
50 | break;
51 | default:
52 | break;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/LoopRecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.recyclerview.widget.LinearLayoutManager;
11 | import androidx.recyclerview.widget.PagerSnapHelper;
12 | import androidx.recyclerview.widget.RecyclerView;
13 | import me.relex.circleindicator.CircleIndicator2;
14 | import me.relex.circleindicator.sample.LoopRecyclerAdapter;
15 | import me.relex.circleindicator.sample.R;
16 | import me.relex.recyclerpager.SnapPageScrollListener;
17 |
18 | public class LoopRecyclerViewFragment extends Fragment {
19 |
20 | private LoopRecyclerAdapter mAdapter;
21 | private CircleIndicator2 mIndicator;
22 |
23 | @Nullable @Override
24 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
25 | @Nullable Bundle savedInstanceState) {
26 | return inflater.inflate(R.layout.fragment_sample_loop_recycer_view, container, false);
27 | }
28 |
29 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
30 | mAdapter = new LoopRecyclerAdapter(5);
31 |
32 | mIndicator = view.findViewById(R.id.indicator);
33 | RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
34 |
35 | LinearLayoutManager layoutManager =
36 | new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
37 | recyclerView.setLayoutManager(layoutManager);
38 | recyclerView.setAdapter(mAdapter);
39 | mIndicator.createIndicators(mAdapter.getRealItemCount(), 0);
40 |
41 | PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
42 | pagerSnapHelper.attachToRecyclerView(recyclerView);
43 |
44 | recyclerView.addOnScrollListener(new SnapPageScrollListener() {
45 | @Override public void onPageSelected(int position) {
46 | mIndicator.animatePageSelected(mAdapter.getRealPosition(position));
47 | }
48 |
49 | @Override public void onPageScrolled(int position, float positionOffset,
50 | int positionOffsetPixels) {
51 | if (positionOffsetPixels == 0) {
52 | recyclerView.scrollToPosition(mAdapter.getLoopPosition(position));
53 | }
54 | }
55 | });
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/LoopViewPagerFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import androidx.fragment.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import com.imbryk.viewPager.LoopViewPager;
11 | import me.relex.circleindicator.CircleIndicator;
12 | import me.relex.circleindicator.sample.R;
13 | import me.relex.circleindicator.sample.SamplePagerAdapter;
14 |
15 | public class LoopViewPagerFragment extends Fragment {
16 |
17 | @Nullable @Override
18 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
19 | @Nullable Bundle savedInstanceState) {
20 | return inflater.inflate(R.layout.fragment_sample_loop_viewpager, container, false);
21 | }
22 |
23 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
24 | LoopViewPager viewpager = view.findViewById(R.id.viewpager);
25 | CircleIndicator indicator = view.findViewById(R.id.indicator);
26 | viewpager.setAdapter(new SamplePagerAdapter());
27 | indicator.setViewPager(viewpager);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/RecyclerViewFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.recyclerview.widget.LinearLayoutManager;
11 | import androidx.recyclerview.widget.PagerSnapHelper;
12 | import androidx.recyclerview.widget.RecyclerView;
13 | import me.relex.circleindicator.CircleIndicator2;
14 | import me.relex.circleindicator.sample.R;
15 | import me.relex.circleindicator.sample.SampleRecyclerAdapter;
16 |
17 | public class RecyclerViewFragment extends Fragment {
18 |
19 | private SampleRecyclerAdapter mAdapter;
20 |
21 | @Nullable @Override
22 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
23 | @Nullable Bundle savedInstanceState) {
24 | return inflater.inflate(R.layout.fragment_sample_recycler_view, container, false);
25 | }
26 |
27 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
28 | mAdapter = new SampleRecyclerAdapter(5);
29 |
30 | RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
31 |
32 | LinearLayoutManager layoutManager =
33 | new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
34 | recyclerView.setLayoutManager(layoutManager);
35 | recyclerView.setAdapter(mAdapter);
36 |
37 | PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
38 | pagerSnapHelper.attachToRecyclerView(recyclerView);
39 |
40 | // CircleIndicator2 for RecyclerView
41 | CircleIndicator2 indicator = view.findViewById(R.id.indicator);
42 | indicator.attachToRecyclerView(recyclerView, pagerSnapHelper);
43 |
44 | // Scroll To Position
45 | layoutManager.scrollToPosition(2);
46 |
47 | // Observe Data Change
48 | mAdapter.registerAdapterDataObserver(indicator.getAdapterDataObserver());
49 | view.findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
50 | @Override public void onClick(View v) {
51 | mAdapter.add();
52 | }
53 | });
54 | view.findViewById(R.id.remove).setOnClickListener(v -> {
55 | mAdapter.remove();
56 | });
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/ResetAdapterFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import androidx.fragment.app.Fragment;
7 | import androidx.viewpager.widget.ViewPager;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import java.util.Random;
12 | import me.relex.circleindicator.CircleIndicator;
13 | import me.relex.circleindicator.sample.R;
14 | import me.relex.circleindicator.sample.SamplePagerAdapter;
15 |
16 | public class ResetAdapterFragment extends Fragment {
17 |
18 | private final Random mRandom = new Random();
19 |
20 | private ViewPager mViewpager;
21 | private CircleIndicator mIndicator;
22 |
23 | @Nullable @Override
24 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
25 | @Nullable Bundle savedInstanceState) {
26 | return inflater.inflate(R.layout.fragment_sample_reset_adapter, container, false);
27 | }
28 |
29 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
30 | mViewpager = view.findViewById(R.id.viewpager);
31 | mIndicator = view.findViewById(R.id.indicator);
32 | mViewpager.setAdapter(new SamplePagerAdapter(5));
33 | mIndicator.setViewPager(mViewpager);
34 |
35 | view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
36 | @Override public void onClick(View v) {
37 | mViewpager.setAdapter(new SamplePagerAdapter(1 + mRandom.nextInt(5)));
38 | mIndicator.setViewPager(mViewpager);
39 | }
40 | });
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/SnackbarBehaviorFragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import androidx.annotation.NonNull;
5 | import androidx.annotation.Nullable;
6 | import com.google.android.material.snackbar.Snackbar;
7 | import androidx.fragment.app.Fragment;
8 | import androidx.viewpager.widget.ViewPager;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import me.relex.circleindicator.CircleIndicator;
13 | import me.relex.circleindicator.sample.R;
14 | import me.relex.circleindicator.sample.SamplePagerAdapter;
15 |
16 | public class SnackbarBehaviorFragment extends Fragment {
17 |
18 | private Snackbar mSnackbar;
19 |
20 | @Nullable @Override
21 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
22 | @Nullable Bundle savedInstanceState) {
23 | return inflater.inflate(R.layout.fragment_sample_snackbar_behavior, container, false);
24 | }
25 |
26 | @Override public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
27 | ViewPager viewpager = view.findViewById(R.id.viewpager);
28 | CircleIndicator indicator = view.findViewById(R.id.indicator);
29 | viewpager.setAdapter(new SamplePagerAdapter());
30 | indicator.setViewPager(viewpager);
31 |
32 | mSnackbar = Snackbar.make(view.findViewById(R.id.coordinator_layout), "Snackbar",
33 | Snackbar.LENGTH_SHORT);
34 |
35 | view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
36 | @Override public void onClick(View v) {
37 | if (!mSnackbar.isShown()) {
38 | mSnackbar.show();
39 | } else {
40 | mSnackbar.dismiss();
41 | }
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sample/src/main/java/me/relex/circleindicator/sample/fragment/ViewPager2Fragment.java:
--------------------------------------------------------------------------------
1 | package me.relex.circleindicator.sample.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.fragment.app.Fragment;
10 | import androidx.viewpager2.widget.ViewPager2;
11 | import me.relex.circleindicator.CircleIndicator3;
12 | import me.relex.circleindicator.sample.R;
13 | import me.relex.circleindicator.sample.SampleRecyclerAdapter;
14 |
15 | public class ViewPager2Fragment extends Fragment {
16 |
17 | private SampleRecyclerAdapter mAdapter;
18 |
19 | @Nullable @Override
20 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
21 | @Nullable Bundle savedInstanceState) {
22 | return inflater.inflate(R.layout.fragment_sample_viewpager2, container, false);
23 | }
24 |
25 | @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
26 | mAdapter = new SampleRecyclerAdapter(5);
27 |
28 | ViewPager2 viewpager = view.findViewById(R.id.viewpager);
29 | viewpager.setAdapter(mAdapter);
30 |
31 | // CircleIndicator3 for RecyclerView
32 | CircleIndicator3 indicator = view.findViewById(R.id.indicator);
33 | indicator.setViewPager(viewpager);
34 |
35 | // CurrentItem
36 | viewpager.setCurrentItem(2,false);
37 |
38 | // Observe Data Change
39 | mAdapter.registerAdapterDataObserver(indicator.getAdapterDataObserver());
40 | view.findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
41 | @Override public void onClick(View v) {
42 | mAdapter.add();
43 | }
44 | });
45 | view.findViewById(R.id.remove).setOnClickListener(v -> {
46 | mAdapter.remove();
47 | });
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sample/src/main/res/animator/indicator_animator.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
16 |
--------------------------------------------------------------------------------
/sample/src/main/res/animator/indicator_animator_reverse.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
--------------------------------------------------------------------------------
/sample/src/main/res/animator/indicator_no_animator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/black_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
7 |
8 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/black_radius_square.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable/white_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_change_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
21 |
22 |
23 |
29 |
30 |
37 |
38 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_custom_animation.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_dynamic_adapter.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
25 |
26 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_loop_recycer_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_loop_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
19 |
26 |
27 |
34 |
35 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_reset_adapter.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_snackbar_behavior.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
27 |
28 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/fragment_sample_viewpager2.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
17 |
18 |
25 |
26 |
33 |
34 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/sample/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/sample/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #424242
5 | #212121
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | CircleIndicator
4 | Add
5 | Remove
6 | Tint Drawable
7 | Change Drawable
8 | Random Reset
9 | Toggle Snackbar
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
22 |
23 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/screenshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ongakuer/CircleIndicator/7847a2262f109127e4e03ca77f56253c2b128ad4/screenshot.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':circleindicator', ':sample', ':LoopingViewPager'
2 |
--------------------------------------------------------------------------------