├── .gitignore
├── .gitmodules
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── build.gradle
├── checkstyle.xml
├── feature-graphic.png
├── gradle-bintray-push.gradle
├── gradle.properties
├── library-recyclerview
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── twotoasters
│ └── jazzylistview
│ └── recyclerview
│ └── JazzyRecyclerViewScrollListener.java
├── library
├── build.gradle
├── gradle.properties
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── twotoasters
│ │ └── jazzylistview
│ │ ├── JazzyEffect.java
│ │ ├── JazzyGridView.java
│ │ ├── JazzyHelper.java
│ │ ├── JazzyListView.java
│ │ └── effects
│ │ ├── CardsEffect.java
│ │ ├── CurlEffect.java
│ │ ├── FadeEffect.java
│ │ ├── FanEffect.java
│ │ ├── FlipEffect.java
│ │ ├── FlyEffect.java
│ │ ├── GrowEffect.java
│ │ ├── HelixEffect.java
│ │ ├── ReverseFlyEffect.java
│ │ ├── SlideInEffect.java
│ │ ├── StandardEffect.java
│ │ ├── TiltEffect.java
│ │ ├── TwirlEffect.java
│ │ ├── WaveEffect.java
│ │ └── ZipperEffect.java
│ └── res
│ └── values
│ └── attrs.xml
├── sample
├── build.gradle
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── twotoasters
│ │ │ └── jazzylistview
│ │ │ └── sample
│ │ │ ├── ActivityInfo.java
│ │ │ ├── GridViewActivity.java
│ │ │ ├── ListAdapter.java
│ │ │ ├── ListModel.java
│ │ │ ├── ListViewActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── RecyclerViewActivity.java
│ │ │ ├── SampleRecyclerViewAdapter.java
│ │ │ └── Utils.java
│ │ └── res
│ │ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── drawable-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── layout
│ │ ├── activity_grid.xml
│ │ ├── activity_list.xml
│ │ ├── activity_recyclerview.xml
│ │ ├── grid_item.xml
│ │ ├── grid_item_taller.xml
│ │ └── item.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
└── web_hi_res_512.png
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | #Android generated
2 | bin
3 | gen
4 | lint.xml
5 |
6 | #Eclipse
7 | .project
8 | .classpath
9 | .settings
10 | .checkstyle
11 | project.properties
12 |
13 | #IntelliJ IDEA
14 | .idea
15 | *.iml
16 | *.ipr
17 | *.iws
18 | classes
19 | gen-external-apklibs
20 |
21 | # Gradle
22 | .gradle
23 | build
24 | gradle
25 | gradlew
26 | gradlew.bat
27 |
28 | #Maven
29 | target
30 | release.properties
31 | pom.xml.*
32 |
33 | #Ant
34 | build.xml
35 | ant.properties
36 | local.properties
37 | proguard.cfg
38 | proguard-project.txt
39 |
40 | #Other
41 | .DS_Store
42 | tmp
43 |
44 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/.gitmodules
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Change Log
2 | ==========
3 |
4 | Version 1.2.1 *(2015-03-02)*
5 | ----------------------------
6 |
7 | * Reduce minSdk to API Level 14
8 |
9 | Version 1.2.0 *(2015-02-16)*
10 | ----------------------------
11 |
12 | * Added jcenter deployment script
13 |
14 | Version 1.1.1 *(2015-02-16)*
15 | ----------------------------
16 |
17 | * Made deploy script tweaks
18 |
19 | Version 1.1.0 *(2015-02-16)*
20 | ----------------------------
21 |
22 | * Add support for jazzy RecyclerView
23 |
24 | Version 1.0.1 *(2014-03-14)*
25 | ----------------------------
26 |
27 | * Build library as .AAR
28 |
29 | Version 1.0.0 *(2013-08-28)*
30 | ----------------------------
31 |
32 | Initial release.
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2013 Two Toasters
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | JazzyListView
2 | -------------
3 |
4 | JazzyListView is an extension of ListView designed to animate list item views as
5 | they become visible. There are a number of pre-built, bundled effects that can be used
6 | by setting the effect in code or an XML layout attribute. Also, it is possible to use a
7 | custom effect by implementing a JazzyEffect.
8 |
9 | This project was inspired by [stroll.js](http://lab.hakim.se/scroll-effects).
10 |
11 | Usage
12 | -----
13 |
14 | ##### ListView
15 |
16 | 1) Include a JazzyListView in your layout
17 |
18 | ```xml
19 |
23 | ```
24 |
25 | 2) Get a reference to your JazzyListView
26 |
27 | ```java
28 | JazzyListView list = (JazzyListView) findViewById(R.id.list);
29 | ```
30 |
31 | 3) Set your effect
32 |
33 | ```java
34 | list.setTransitionEffect(new SlideInEffect());
35 | ```
36 |
37 | ##### RecyclerView
38 |
39 | 1) Include a JazzyListView in your layout
40 |
41 | ```xml
42 |
46 | ```
47 |
48 | 2) Get a reference to your RecyclerView
49 |
50 | ```java
51 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
52 | ```
53 |
54 | 3) Set the JazzyScrollListener (you can set an additional scroll listener on the JazzyScrollListener)
55 |
56 | ```java
57 | recyclerView.setOnScrollListener(new JazzyRecyclerViewScrollListener());
58 | ```
59 |
60 | 4) Set your effect
61 |
62 | ```java
63 | recyclerView.setTransitionEffect(new SlideInEffect());
64 | ```
65 |
66 | Sample App
67 | ----------
68 |
69 | The sample app demonstrates all of the pre-built effects on a list, grid, and recyclerview. You can build it from source or install it from the [Play Store](https://play.google.com/store/apps/details?id=com.twotoasters.jazzylistview.sample).
70 |
71 | Download
72 | --------
73 |
74 | ```groovy
75 | compile 'com.twotoasters.jazzylistview:library:1.2.1'
76 | compile 'com.twotoasters.jazzylistview:library-recyclerview:1.2.1'
77 | ```
78 |
79 | License
80 | -------
81 |
82 | Copyright 2015 Two Toasters
83 |
84 | Licensed under the Apache License, Version 2.0 (the "License");
85 | you may not use this file except in compliance with the License.
86 | You may obtain a copy of the License at
87 |
88 | http://www.apache.org/licenses/LICENSE-2.0
89 |
90 | Unless required by applicable law or agreed to in writing, software
91 | distributed under the License is distributed on an "AS IS" BASIS,
92 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
93 | See the License for the specific language governing permissions and
94 | limitations under the License.
95 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | }
5 | dependencies {
6 | classpath 'com.android.tools.build:gradle:1.0.1'
7 | classpath 'com.github.dcendents:android-maven-plugin:1.2'
8 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
9 | }
10 | }
11 |
12 | allprojects {
13 | group = GROUP
14 | version = VERSION_NAME
15 |
16 | repositories {
17 | jcenter()
18 | }
19 | }
--------------------------------------------------------------------------------
/checkstyle.xml:
--------------------------------------------------------------------------------
1 |
2 |
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 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/feature-graphic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/feature-graphic.png
--------------------------------------------------------------------------------
/gradle-bintray-push.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 James Barr
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 |
17 | // NOTE: be sure to have the following items added to your buildscript's dependencies in your root build.gradle:
18 | //
19 | // classpath 'com.github.dcendents:android-maven-plugin:1.2'
20 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1'
21 |
22 | apply plugin: 'com.github.dcendents.android-maven'
23 | apply plugin: 'com.jfrog.bintray'
24 |
25 | install {
26 | repositories.mavenInstaller {
27 | pom.project {
28 | name POM_NAME
29 | packaging POM_PACKAGING
30 | description POM_DESCRIPTION
31 | url POM_URL
32 |
33 | scm {
34 | url POM_SCM_URL
35 | connection POM_SCM_CONNECTION
36 | developerConnection POM_SCM_DEV_CONNECTION
37 | }
38 |
39 | licenses {
40 | license {
41 | name POM_LICENCE_NAME
42 | url POM_LICENCE_URL
43 | distribution POM_LICENCE_DIST
44 | }
45 | }
46 |
47 | developers {
48 | developer {
49 | id POM_DEVELOPER_ID
50 | name POM_DEVELOPER_NAME
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | task androidJavadocs(type: Javadoc) {
58 | source = android.sourceSets.main.java.srcDirs
59 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
60 | }
61 |
62 | task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
63 | classifier = 'javadoc'
64 | from androidJavadocs.destinationDir
65 | }
66 |
67 | task androidSourcesJar(type: Jar) {
68 | classifier = 'sources'
69 | from android.sourceSets.main.java.sourceFiles
70 | }
71 |
72 | artifacts {
73 | archives androidSourcesJar
74 | archives androidJavadocsJar
75 | }
76 |
77 | bintray {
78 | user = BINTRAY_USER
79 | key = BINTRAY_API_KEY
80 |
81 | configurations = ['archives']
82 | dryRun = false
83 | publish = true
84 | pkg {
85 | repo = BINTRAY_REPO
86 | userOrg = BINTRAY_ORGANIZATION
87 | name = BINTRAY_PROJECT_NAME
88 | websiteUrl = BINTRAY_SITE_URL
89 | vcsUrl = BINTRAY_GIT_URL
90 | licenses = [BINTRAY_PROJECT_LICENSE]
91 | version {
92 | gpg {
93 | sign = true // Determines whether to GPG sign the files. The default is false
94 | passphrase = BINTRAY_GPG_PASSWORD // Optional. The passphrase for GPG signing'
95 | }
96 | mavenCentralSync {
97 | sync = true // Optional (true by default). Determines whether to sync the version to Maven Central.
98 | user = BINTRAY_OSS_USER // OSS user token
99 | password = BINTRAY_OSS_PASSWORD // OSS user password
100 | close = '1' // Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
101 | }
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | VERSION_NAME=1.2.1
2 | VERSION_CODE=5
3 | GROUP=com.twotoasters.jazzylistview
4 |
5 | POM_DESCRIPTION=Android library for adding animations to list items when they become visible
6 | POM_URL=https://github.com/twotoasters/JazzyListView
7 | POM_SCM_URL=https://github.com/twotoasters/JazzyListView
8 | POM_SCM_CONNECTION=scm:git@github.com:twotoasters/JazzyListView.git
9 | POM_SCM_DEV_CONNECTION=scm:git@github.com:twotoasters/JazzyListView.git
10 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
11 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
12 | POM_LICENCE_DIST=repo
13 | POM_DEVELOPER_ID=jbarr21
14 | POM_DEVELOPER_NAME=James Barr
15 |
16 | ANDROID_BUILD_SDK_VERSION=21
17 | ANDROID_BUILD_TOOLS_VERSION=21
18 | ANDROID_BUILD_TARGET_SDK_VERSION=21
19 | ANDROID_BUILD_MIN_SDK_VERSION=14
20 |
21 | BINTRAY_RELEASE_ENABLED=false
22 | BINTRAY_PROJECT_NAME=com.twotoasters.jazzylistview
23 | BINTRAY_PROJECT_LICENSE=Apache-2.0
24 | BINTRAY_SITE_URL=https://github.com/twotoasters/JazzyListView
25 | BINTRAY_GIT_URL=https://github.com/twotoasters/JazzyListView.git
--------------------------------------------------------------------------------
/library-recyclerview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
6 |
7 | defaultConfig {
8 | minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
9 | targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
10 |
11 | versionCode Integer.parseInt(project.VERSION_CODE)
12 | versionName project.VERSION_NAME
13 | }
14 | }
15 |
16 | dependencies {
17 | compile 'com.android.support:support-v4:21.0.0'
18 | compile 'com.android.support:recyclerview-v7:21.0.0'
19 | compile project(':library')
20 | }
21 |
22 | if (Boolean.parseBoolean(BINTRAY_RELEASE_ENABLED)) {
23 | apply from: '../gradle-bintray-push.gradle'
24 | }
--------------------------------------------------------------------------------
/library-recyclerview/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=JazzyListView
2 | POM_ARTIFACT_ID=library-recyclerview
3 | POM_PACKAGING=aar
4 |
--------------------------------------------------------------------------------
/library-recyclerview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/library-recyclerview/src/main/java/com/twotoasters/jazzylistview/recyclerview/JazzyRecyclerViewScrollListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.recyclerview;
17 |
18 | import android.support.v7.widget.RecyclerView;
19 | import android.support.v7.widget.RecyclerView.OnScrollListener;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 | import com.twotoasters.jazzylistview.JazzyHelper;
23 |
24 | public class JazzyRecyclerViewScrollListener extends OnScrollListener {
25 |
26 | private final JazzyHelper mHelper;
27 | private OnScrollListener mAdditionalOnScrollListener;
28 |
29 | public JazzyRecyclerViewScrollListener() {
30 | mHelper = new JazzyHelper();
31 | }
32 |
33 | @Override
34 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
35 | int firstVisibleItem = recyclerView.getChildPosition(recyclerView.getChildAt(0));
36 | int visibleItemCount = recyclerView.getChildCount();
37 | int totalItemCount = recyclerView.getAdapter().getItemCount();
38 |
39 | mHelper.onScrolled(recyclerView, firstVisibleItem, visibleItemCount, totalItemCount);
40 |
41 | notifyAdditionalOnScrolledListener(recyclerView, dx, dy);
42 | }
43 |
44 | @Override
45 | public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
46 | switch (newState) {
47 | case RecyclerView.SCROLL_STATE_SETTLING: // fall through
48 | case RecyclerView.SCROLL_STATE_DRAGGING:
49 | mHelper.setScrolling(true);
50 | break;
51 | case RecyclerView.SCROLL_STATE_IDLE:
52 | mHelper.setScrolling(false);
53 | break;
54 | default:
55 | break;
56 | }
57 | notifyAdditionalOnScrollStateChangedListener(recyclerView, newState);
58 | }
59 |
60 | /**
61 | * Sets the desired transition effect.
62 | *
63 | * @param transitionEffect Numeric constant representing a bundled transition effect.
64 | */
65 | public void setTransitionEffect(int transitionEffect) {
66 | mHelper.setTransitionEffect(transitionEffect);
67 | }
68 |
69 | /**
70 | * Sets the desired transition effect.
71 | *
72 | * @param transitionEffect The non-bundled transition provided by the client.
73 | */
74 | public void setTransitionEffect(JazzyEffect transitionEffect) {
75 | mHelper.setTransitionEffect(transitionEffect);
76 | }
77 |
78 | /**
79 | * Sets whether new items or all items should be animated when they become visible.
80 | *
81 | * @param onlyAnimateNew True if only new items should be animated; false otherwise.
82 | */
83 | public void setShouldOnlyAnimateNewItems(boolean onlyAnimateNew) {
84 | mHelper.setShouldOnlyAnimateNewItems(onlyAnimateNew);
85 | }
86 |
87 | /**
88 | * Stop animations after the list has reached a certain velocity. When the list slows down
89 | * it will start animating again. This gives a performance boost as well as preventing
90 | * the list from animating under the users finger if they suddenly stop it.
91 | *
92 | * @param itemsPerSecond, set to JazzyHelper.MAX_VELOCITY_OFF to turn off max velocity.
93 | * While 13 is a good default, it is dependent on the size of your items.
94 | */
95 | public void setMaxAnimationVelocity(int itemsPerSecond) {
96 | mHelper.setMaxAnimationVelocity(itemsPerSecond);
97 | }
98 |
99 | public void setOnScrollListener(OnScrollListener l) {
100 | // hijack the scroll listener setter and have this list also notify the additional listener
101 | mAdditionalOnScrollListener = l;
102 | }
103 |
104 | /**
105 | * Notifies the OnScrollListener of an onScroll event, since JazzyListView is the primary listener for onScroll events.
106 | */
107 | private void notifyAdditionalOnScrolledListener(RecyclerView recyclerView, int dx, int dy) {
108 | if (mAdditionalOnScrollListener != null) {
109 | mAdditionalOnScrollListener.onScrolled(recyclerView, dx, dy);
110 | }
111 | }
112 |
113 | /**
114 | * Notifies the OnScrollListener of an onScrollStateChanged event, since JazzyListView is the primary listener for onScrollStateChanged events.
115 | */
116 | private void notifyAdditionalOnScrollStateChangedListener(RecyclerView recyclerView, int newState) {
117 | if (mAdditionalOnScrollListener != null) {
118 | mAdditionalOnScrollListener.onScrollStateChanged(recyclerView, newState);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
6 |
7 | defaultConfig {
8 | minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
9 | targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
10 |
11 | versionCode Integer.parseInt(project.VERSION_CODE)
12 | versionName project.VERSION_NAME
13 | }
14 | }
15 |
16 | dependencies {
17 | compile 'com.android.support:support-v4:21.0.0'
18 | }
19 |
20 | if (Boolean.parseBoolean(BINTRAY_RELEASE_ENABLED)) {
21 | apply from: '../gradle-bintray-push.gradle'
22 | }
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=JazzyListView
2 | POM_ARTIFACT_ID=library
3 | POM_PACKAGING=aar
4 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/JazzyEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | /**
22 | * This interface serves as the contract for a transition effect.
23 | */
24 | public interface JazzyEffect {
25 | /**
26 | * Initializes the view's attributes so that the view is in position to begin the animation.
27 | *
28 | * @param item The view to be animated.
29 | * @param position The index of the view in the list.
30 | * @param scrollDirection Positive number indicating scrolling down, or negative number indicating scrolling up.
31 | */
32 | void initView(View item, int position, int scrollDirection);
33 |
34 | /**
35 | * Configures the animator object with the relative changes or destination point for any attributes that will be animated.
36 | *
37 | * @param item The view to be animated.
38 | * @param position The index of the view in the list.
39 | * @param scrollDirection Positive number indicating scrolling down, or negative number indicating scrolling up.
40 | * @param animator The ViewPropertyAnimator object responsible for animating the view.
41 | */
42 | void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator);
43 | }
44 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/JazzyGridView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import android.widget.GridView;
21 |
22 | public class JazzyGridView extends GridView {
23 |
24 | private final JazzyHelper mHelper;
25 |
26 | public JazzyGridView(Context context) {
27 | super(context);
28 | mHelper = init(context, null);
29 | }
30 |
31 | public JazzyGridView(Context context, AttributeSet attrs) {
32 | super(context, attrs);
33 | mHelper = init(context, attrs);
34 | }
35 |
36 | public JazzyGridView(Context context, AttributeSet attrs, int defStyle) {
37 | super(context, attrs, defStyle);
38 | mHelper = init(context, attrs);
39 | }
40 |
41 | private JazzyHelper init(Context context, AttributeSet attrs) {
42 | JazzyHelper helper = new JazzyHelper(context, attrs);
43 | super.setOnScrollListener(helper);
44 | return helper;
45 | }
46 |
47 | /**
48 | * @see android.widget.AbsListView#setOnScrollListener
49 | */
50 | @Override
51 | public final void setOnScrollListener(OnScrollListener l) {
52 | mHelper.setOnScrollListener(l);
53 | }
54 |
55 | /**
56 | * Sets the desired transition effect.
57 | *
58 | * @param transitionEffect Numeric constant representing a bundled transition effect.
59 | */
60 | public void setTransitionEffect(int transitionEffect) {
61 | mHelper.setTransitionEffect(transitionEffect);
62 | }
63 |
64 | /**
65 | * Sets the desired transition effect.
66 | *
67 | * @param transitionEffect The non-bundled transition provided by the client.
68 | */
69 | public void setTransitionEffect(JazzyEffect transitionEffect) {
70 | mHelper.setTransitionEffect(transitionEffect);
71 | }
72 |
73 | /**
74 | * Sets whether new items or all items should be animated when they become visible.
75 | *
76 | * @param onlyAnimateNew True if only new items should be animated; false otherwise.
77 | */
78 | public void setShouldOnlyAnimateNewItems(boolean onlyAnimateNew) {
79 | mHelper.setShouldOnlyAnimateNewItems(onlyAnimateNew);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/JazzyHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview;
17 |
18 | import android.content.Context;
19 | import android.content.res.TypedArray;
20 | import android.util.AttributeSet;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.view.ViewPropertyAnimator;
24 | import android.view.animation.AccelerateDecelerateInterpolator;
25 | import android.widget.AbsListView;
26 |
27 | import com.twotoasters.jazzylistview.effects.CardsEffect;
28 | import com.twotoasters.jazzylistview.effects.CurlEffect;
29 | import com.twotoasters.jazzylistview.effects.FadeEffect;
30 | import com.twotoasters.jazzylistview.effects.FanEffect;
31 | import com.twotoasters.jazzylistview.effects.FlipEffect;
32 | import com.twotoasters.jazzylistview.effects.FlyEffect;
33 | import com.twotoasters.jazzylistview.effects.GrowEffect;
34 | import com.twotoasters.jazzylistview.effects.HelixEffect;
35 | import com.twotoasters.jazzylistview.effects.ReverseFlyEffect;
36 | import com.twotoasters.jazzylistview.effects.SlideInEffect;
37 | import com.twotoasters.jazzylistview.effects.StandardEffect;
38 | import com.twotoasters.jazzylistview.effects.TiltEffect;
39 | import com.twotoasters.jazzylistview.effects.TwirlEffect;
40 | import com.twotoasters.jazzylistview.effects.WaveEffect;
41 | import com.twotoasters.jazzylistview.effects.ZipperEffect;
42 |
43 | import java.util.HashSet;
44 |
45 | public class JazzyHelper implements AbsListView.OnScrollListener {
46 |
47 | public static final int STANDARD = 0;
48 | public static final int GROW = 1;
49 | public static final int CARDS = 2;
50 | public static final int CURL = 3;
51 | public static final int WAVE = 4;
52 | public static final int FLIP = 5;
53 | public static final int FLY = 6;
54 | public static final int REVERSE_FLY = 7;
55 | public static final int HELIX = 8;
56 | public static final int FAN = 9;
57 | public static final int TILT = 10;
58 | public static final int ZIPPER = 11;
59 | public static final int FADE = 12;
60 | public static final int TWIRL = 13;
61 | public static final int SLIDE_IN = 14;
62 |
63 | public static final int DURATION = 300;
64 | public static final int OPAQUE = 255, TRANSPARENT = 0;
65 |
66 | private JazzyEffect mTransitionEffect = null;
67 | private boolean mIsScrolling = false;
68 | private int mFirstVisibleItem = -1;
69 | private int mLastVisibleItem = -1;
70 | private int mPreviousFirstVisibleItem = 0;
71 | private long mPreviousEventTime = 0;
72 | private double mSpeed = 0;
73 | private int mMaxVelocity = 0;
74 | public static final int MAX_VELOCITY_OFF = 0;
75 |
76 | private AbsListView.OnScrollListener mAdditionalOnScrollListener;
77 |
78 | private boolean mOnlyAnimateNewItems;
79 | private boolean mOnlyAnimateOnFling;
80 | private boolean mIsFlingEvent;
81 | private boolean mSimulateGridWithList;
82 | private final HashSet mAlreadyAnimatedItems;
83 |
84 | public JazzyHelper() {
85 | this(null, null);
86 | }
87 |
88 | public JazzyHelper(Context context, AttributeSet attrs) {
89 | mAlreadyAnimatedItems = new HashSet<>();
90 | int transitionEffect = HELIX;
91 | int maxVelocity = 0;
92 |
93 | if (context != null && attrs != null) {
94 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.JazzyListView);
95 | transitionEffect = a.getInteger(R.styleable.JazzyListView_effect, STANDARD);
96 | maxVelocity = a.getInteger(R.styleable.JazzyListView_max_velocity, MAX_VELOCITY_OFF);
97 | mOnlyAnimateNewItems = a.getBoolean(R.styleable.JazzyListView_only_animate_new_items, false);
98 | mOnlyAnimateOnFling = a.getBoolean(R.styleable.JazzyListView_max_velocity, false);
99 | mSimulateGridWithList = a.getBoolean(R.styleable.JazzyListView_simulate_grid_with_list, false);
100 | a.recycle();
101 | }
102 |
103 | setTransitionEffect(transitionEffect);
104 | setMaxAnimationVelocity(maxVelocity);
105 | }
106 |
107 | public void setOnScrollListener(AbsListView.OnScrollListener l) {
108 | // hijack the scroll listener setter and have this list also notify the additional listener
109 | mAdditionalOnScrollListener = l;
110 | }
111 |
112 | /**
113 | * @see AbsListView.OnScrollListener#onScroll
114 | */
115 | @Override
116 | public final void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
117 | onScrolled(view, firstVisibleItem, visibleItemCount, totalItemCount);
118 | notifyAdditionalOnScrollListener(view, firstVisibleItem, visibleItemCount, totalItemCount);
119 | }
120 |
121 | public final void onScrolled(ViewGroup viewGroup, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
122 | boolean shouldAnimateItems = (mFirstVisibleItem != -1 && mLastVisibleItem != -1);
123 |
124 | int lastVisibleItem = firstVisibleItem + visibleItemCount - 1;
125 | if (mIsScrolling && shouldAnimateItems) {
126 | setVelocity(firstVisibleItem, totalItemCount);
127 | int indexAfterFirst = 0;
128 | while (firstVisibleItem + indexAfterFirst < mFirstVisibleItem) {
129 | View item = viewGroup.getChildAt(indexAfterFirst);
130 | doJazziness(item, firstVisibleItem + indexAfterFirst, -1);
131 | indexAfterFirst++;
132 | }
133 |
134 | int indexBeforeLast = 0;
135 | while (lastVisibleItem - indexBeforeLast > mLastVisibleItem) {
136 | View item = viewGroup.getChildAt(lastVisibleItem - firstVisibleItem - indexBeforeLast);
137 | doJazziness(item, lastVisibleItem - indexBeforeLast, 1);
138 | indexBeforeLast++;
139 | }
140 | } else if (!shouldAnimateItems) {
141 | for (int i = firstVisibleItem; i < visibleItemCount; i++) {
142 | mAlreadyAnimatedItems.add(i);
143 | }
144 | }
145 |
146 | mFirstVisibleItem = firstVisibleItem;
147 | mLastVisibleItem = lastVisibleItem;
148 | }
149 |
150 | /**
151 | * Should be called in onScroll to keep take of current Velocity.
152 | *
153 | * @param firstVisibleItem
154 | * The index of the first visible item in the ListView.
155 | */
156 | private void setVelocity(int firstVisibleItem, int totalItemCount) {
157 | if (mMaxVelocity > MAX_VELOCITY_OFF && mPreviousFirstVisibleItem != firstVisibleItem) {
158 | long currTime = System.currentTimeMillis();
159 | long timeToScrollOneItem = currTime - mPreviousEventTime;
160 | if (timeToScrollOneItem < 1) {
161 | double newSpeed = ((1.0d / timeToScrollOneItem) * 1000);
162 | // We need to normalize velocity so different size item don't
163 | // give largely different velocities.
164 | if (newSpeed < (0.9f * mSpeed)) {
165 | mSpeed *= 0.9f;
166 | } else if (newSpeed > (1.1f * mSpeed)) {
167 | mSpeed *= 1.1f;
168 | } else {
169 | mSpeed = newSpeed;
170 | }
171 | } else {
172 | mSpeed = ((1.0d / timeToScrollOneItem) * 1000);
173 | }
174 |
175 | mPreviousFirstVisibleItem = firstVisibleItem;
176 | mPreviousEventTime = currTime;
177 | }
178 | }
179 |
180 |
181 | /**
182 | * Initializes the item view and triggers the animation.
183 | *
184 | * @param item The view to be animated.
185 | * @param position The index of the view in the list.
186 | * @param scrollDirection Positive number indicating scrolling down, or negative number indicating scrolling up.
187 | */
188 | private void doJazziness(View item, int position, int scrollDirection) {
189 | if (mIsScrolling) {
190 | if (mOnlyAnimateNewItems && mAlreadyAnimatedItems.contains(position))
191 | return;
192 |
193 | if (mOnlyAnimateOnFling && !mIsFlingEvent)
194 | return;
195 |
196 | if (mMaxVelocity > MAX_VELOCITY_OFF && mMaxVelocity < mSpeed)
197 | return;
198 |
199 | if (mSimulateGridWithList) {
200 | ViewGroup itemRow = (ViewGroup) item;
201 | for (int i = 0; i < itemRow.getChildCount(); i++)
202 | doJazzinessImpl(itemRow.getChildAt(i), position, scrollDirection);
203 | } else {
204 | doJazzinessImpl(item, position, scrollDirection);
205 | }
206 |
207 | mAlreadyAnimatedItems.add(position);
208 | }
209 | }
210 |
211 | private void doJazzinessImpl(View item, int position, int scrollDirection) {
212 | ViewPropertyAnimator animator = item.animate()
213 | .setDuration(DURATION)
214 | .setInterpolator(new AccelerateDecelerateInterpolator());
215 |
216 | scrollDirection = scrollDirection > 0 ? 1 : -1;
217 | mTransitionEffect.initView(item, position, scrollDirection);
218 | mTransitionEffect.setupAnimation(item, position, scrollDirection, animator);
219 | animator.start();
220 | }
221 |
222 | /**
223 | * @see AbsListView.OnScrollListener#onScrollStateChanged
224 | */
225 | @Override
226 | public void onScrollStateChanged(AbsListView view, int scrollState) {
227 | switch(scrollState) {
228 | case AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
229 | mIsScrolling = false;
230 | mIsFlingEvent = false;
231 | break;
232 | case AbsListView.OnScrollListener.SCROLL_STATE_FLING:
233 | mIsFlingEvent = true;
234 | break;
235 | case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
236 | mIsScrolling = true;
237 | mIsFlingEvent = false;
238 | break;
239 | default: break;
240 | }
241 | notifyAdditionalOnScrollStateChangedListener(view, scrollState);
242 | }
243 |
244 | public void setTransitionEffect(int transitionEffect) {
245 | switch (transitionEffect) {
246 | case STANDARD: setTransitionEffect(new StandardEffect()); break;
247 | case GROW: setTransitionEffect(new GrowEffect()); break;
248 | case CARDS: setTransitionEffect(new CardsEffect()); break;
249 | case CURL: setTransitionEffect(new CurlEffect()); break;
250 | case WAVE: setTransitionEffect(new WaveEffect()); break;
251 | case FLIP: setTransitionEffect(new FlipEffect()); break;
252 | case FLY: setTransitionEffect(new FlyEffect()); break;
253 | case REVERSE_FLY: setTransitionEffect(new ReverseFlyEffect()); break;
254 | case HELIX: setTransitionEffect(new HelixEffect()); break;
255 | case FAN: setTransitionEffect(new FanEffect()); break;
256 | case TILT: setTransitionEffect(new TiltEffect()); break;
257 | case ZIPPER: setTransitionEffect(new ZipperEffect()); break;
258 | case FADE: setTransitionEffect(new FadeEffect()); break;
259 | case TWIRL: setTransitionEffect(new TwirlEffect()); break;
260 | case SLIDE_IN: setTransitionEffect(new SlideInEffect()); break;
261 | default: break;
262 | }
263 | }
264 |
265 | public void setTransitionEffect(JazzyEffect transitionEffect) {
266 | mTransitionEffect = transitionEffect;
267 | }
268 |
269 | public void setShouldOnlyAnimateNewItems(boolean onlyAnimateNew) {
270 | mOnlyAnimateNewItems = onlyAnimateNew;
271 | }
272 |
273 | public void setShouldOnlyAnimateFling(boolean onlyFling) {
274 | mOnlyAnimateOnFling = onlyFling;
275 | }
276 |
277 | public void setMaxAnimationVelocity(int itemsPerSecond) {
278 | mMaxVelocity = itemsPerSecond;
279 | }
280 |
281 | public void setSimulateGridWithList(boolean simulateGridWithList) {
282 | mSimulateGridWithList = simulateGridWithList;
283 | }
284 |
285 | public void setScrolling(boolean isScrolling) {
286 | mIsScrolling = isScrolling;
287 | }
288 |
289 | public void setFlingEvent(boolean isFlingEvent) {
290 | mIsFlingEvent = isFlingEvent;
291 | }
292 |
293 | /**
294 | * Notifies the OnScrollListener of an onScroll event, since JazzyListView is the primary listener for onScroll events.
295 | */
296 | private void notifyAdditionalOnScrollListener(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
297 | if (mAdditionalOnScrollListener != null) {
298 | mAdditionalOnScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
299 | }
300 | }
301 |
302 | /**
303 | * Notifies the OnScrollListener of an onScrollStateChanged event, since JazzyListView is the primary listener for onScrollStateChanged events.
304 | */
305 | private void notifyAdditionalOnScrollStateChangedListener(AbsListView view, int scrollState) {
306 | if (mAdditionalOnScrollListener != null) {
307 | mAdditionalOnScrollListener.onScrollStateChanged(view, scrollState);
308 | }
309 | }
310 | }
311 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/JazzyListView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import android.widget.ListView;
21 |
22 | public class JazzyListView extends ListView {
23 |
24 | private final JazzyHelper mHelper;
25 |
26 | public JazzyListView(Context context) {
27 | super(context);
28 | mHelper = init(context, null);
29 | }
30 |
31 | public JazzyListView(Context context, AttributeSet attrs) {
32 | super(context, attrs);
33 | mHelper = init(context, attrs);
34 | }
35 |
36 | public JazzyListView(Context context, AttributeSet attrs, int defStyle) {
37 | super(context, attrs, defStyle);
38 | mHelper = init(context, attrs);
39 | }
40 |
41 | private JazzyHelper init(Context context, AttributeSet attrs) {
42 | JazzyHelper helper = new JazzyHelper(context, attrs);
43 | super.setOnScrollListener(helper);
44 | return helper;
45 | }
46 |
47 | @Override
48 | public final void setOnScrollListener(OnScrollListener l) {
49 | mHelper.setOnScrollListener(l);
50 | }
51 |
52 | /**
53 | * Sets the desired transition effect.
54 | *
55 | * @param transitionEffect Numeric constant representing a bundled transition effect.
56 | */
57 | public void setTransitionEffect(int transitionEffect) {
58 | mHelper.setTransitionEffect(transitionEffect);
59 | }
60 |
61 | /**
62 | * Sets the desired transition effect.
63 | *
64 | * @param transitionEffect The non-bundled transition provided by the client.
65 | */
66 | public void setTransitionEffect(JazzyEffect transitionEffect) {
67 | mHelper.setTransitionEffect(transitionEffect);
68 | }
69 |
70 | /**
71 | * Sets whether new items or all items should be animated when they become visible.
72 | *
73 | * @param onlyAnimateNew True if only new items should be animated; false otherwise.
74 | */
75 | public void setShouldOnlyAnimateNewItems(boolean onlyAnimateNew) {
76 | mHelper.setShouldOnlyAnimateNewItems(onlyAnimateNew);
77 | }
78 |
79 | /**
80 | * If true animation will only occur when scrolling without the users finger on the screen.
81 | *
82 | * @param onlyWhenFling
83 | */
84 | public void setShouldOnlyAnimateFling(boolean onlyWhenFling) {
85 | mHelper.setShouldOnlyAnimateFling(onlyWhenFling);
86 | }
87 |
88 | /**
89 | * Stop animations after the list has reached a certain velocity. When the list slows down
90 | * it will start animating again. This gives a performance boost as well as preventing
91 | * the list from animating under the users finger if they suddenly stop it.
92 | *
93 | * @param itemsPerSecond, set to JazzyHelper.MAX_VELOCITY_OFF to turn off max velocity.
94 | * While 13 is a good default, it is dependent on the size of your items.
95 | */
96 | public void setMaxAnimationVelocity(int itemsPerSecond) {
97 | mHelper.setMaxAnimationVelocity(itemsPerSecond);
98 | }
99 |
100 | /**
101 | * Enable this if you are using a list with items that should act like grid items.
102 | *
103 | * @param simulateGridWithList
104 | */
105 | public void setSimulateGridWithList(boolean simulateGridWithList) {
106 | mHelper.setSimulateGridWithList(simulateGridWithList);
107 | setClipChildren(!simulateGridWithList);
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/CardsEffect.java:
--------------------------------------------------------------------------------
1 | package com.twotoasters.jazzylistview.effects;
2 |
3 | import android.view.View;
4 | import android.view.ViewPropertyAnimator;
5 |
6 | import com.twotoasters.jazzylistview.JazzyEffect;
7 |
8 | public class CardsEffect implements JazzyEffect {
9 |
10 | private static final int INITIAL_ROTATION_ANGLE = 90;
11 |
12 | @Override
13 | public void initView(View item, int position, int scrollDirection) {
14 | item.setPivotX(item.getWidth() / 2);
15 | item.setPivotY(item.getHeight() / 2);
16 | item.setRotationX(INITIAL_ROTATION_ANGLE * scrollDirection);
17 | item.setTranslationY(item.getHeight() * scrollDirection);
18 | }
19 |
20 | @Override
21 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
22 | animator.rotationXBy(-INITIAL_ROTATION_ANGLE * scrollDirection)
23 | .translationYBy(-item.getHeight() * scrollDirection);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/CurlEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class CurlEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 90;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(0);
30 | item.setPivotY(item.getHeight() / 2);
31 | item.setRotationY(INITIAL_ROTATION_ANGLE);
32 | }
33 |
34 | @Override
35 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
36 | animator.rotationYBy(-INITIAL_ROTATION_ANGLE);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/FadeEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 | import com.twotoasters.jazzylistview.JazzyHelper;
23 |
24 | public class FadeEffect implements JazzyEffect {
25 |
26 | private static final int DURATION_MULTIPLIER = 5;
27 |
28 | @Override
29 | public void initView(View item, int position, int scrollDirection) {
30 | item.setAlpha(JazzyHelper.TRANSPARENT);
31 | }
32 |
33 | @Override
34 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
35 | animator.setDuration(JazzyHelper.DURATION * DURATION_MULTIPLIER)
36 | .alpha(JazzyHelper.OPAQUE);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/FanEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class FanEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 70;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(0);
30 | item.setPivotY(0);
31 | item.setRotation(INITIAL_ROTATION_ANGLE * scrollDirection);
32 | }
33 |
34 | @Override
35 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
36 | animator.rotationBy(-INITIAL_ROTATION_ANGLE * scrollDirection);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/FlipEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class FlipEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 90;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(item.getWidth() / 2);
30 | item.setPivotY(item.getHeight() / 2);
31 | item.setRotationX(-INITIAL_ROTATION_ANGLE * scrollDirection);
32 | }
33 |
34 | @Override
35 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
36 | animator.rotationXBy(INITIAL_ROTATION_ANGLE * scrollDirection);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/FlyEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class FlyEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 135;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(item.getWidth() / 2);
30 | item.setPivotY(item.getHeight() / 2);
31 | item.setRotationX(-INITIAL_ROTATION_ANGLE * scrollDirection);
32 | item.setTranslationY(item.getHeight() * 2 * scrollDirection);
33 | }
34 |
35 | @Override
36 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
37 | animator.rotationXBy(INITIAL_ROTATION_ANGLE * scrollDirection)
38 | .translationYBy(-item.getHeight() * 2 * scrollDirection);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/GrowEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class GrowEffect implements JazzyEffect {
24 |
25 | private static final float INITIAL_SCALE_FACTOR = 0.01f;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(item.getWidth() / 2);
30 | item.setPivotY(item.getHeight() / 2);
31 | item.setScaleX(INITIAL_SCALE_FACTOR);
32 | item.setScaleY(INITIAL_SCALE_FACTOR);
33 | }
34 |
35 | @Override
36 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
37 | animator.scaleX(1).scaleY(1);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/HelixEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class HelixEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 180;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setRotationY(INITIAL_ROTATION_ANGLE);
30 | }
31 |
32 | @Override
33 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
34 | animator.rotationYBy(INITIAL_ROTATION_ANGLE * scrollDirection);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/ReverseFlyEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class ReverseFlyEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_ANGLE = 135;
26 |
27 | @Override
28 | public void initView(View item, int position, int scrollDirection) {
29 | item.setPivotX(item.getWidth() / 2);
30 | item.setPivotY(item.getHeight() / 2);
31 | item.setRotationX(INITIAL_ROTATION_ANGLE * scrollDirection);
32 | item.setTranslationY(-item.getHeight() * 2 * scrollDirection);
33 | }
34 |
35 | @Override
36 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
37 | animator.rotationXBy(-INITIAL_ROTATION_ANGLE * scrollDirection)
38 | .translationYBy(item.getHeight() * 2 * scrollDirection);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/SlideInEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class SlideInEffect implements JazzyEffect {
24 |
25 | @Override
26 | public void initView(View item, int position, int scrollDirection) {
27 | item.setTranslationY(item.getHeight() / 2 * scrollDirection);
28 | }
29 |
30 | @Override
31 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
32 | animator.translationYBy(-item.getHeight() / 2 * scrollDirection);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/StandardEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class StandardEffect implements JazzyEffect {
24 |
25 | @Override
26 | public void initView(View item, int position, int scrollDirection) {
27 | // no op
28 | }
29 |
30 | @Override
31 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
32 | // no op
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/TiltEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 | import com.twotoasters.jazzylistview.JazzyHelper;
23 |
24 | public class TiltEffect implements JazzyEffect {
25 |
26 | private static final float INITIAL_SCALE_FACTOR = 0.7f;
27 |
28 | @Override
29 | public void initView(View item, int position, int scrollDirection) {
30 | item.setPivotX(item.getWidth() / 2);
31 | item.setPivotY(item.getHeight() / 2);
32 | item.setScaleX(INITIAL_SCALE_FACTOR);
33 | item.setScaleY(INITIAL_SCALE_FACTOR);
34 | item.setTranslationY(item.getHeight() / 2 * scrollDirection);
35 | item.setAlpha(JazzyHelper.OPAQUE / 2);
36 | }
37 |
38 | @Override
39 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
40 | animator
41 | .translationYBy(-item.getHeight() / 2 * scrollDirection)
42 | .scaleX(1)
43 | .scaleY(1)
44 | .alpha(JazzyHelper.OPAQUE);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/TwirlEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class TwirlEffect implements JazzyEffect {
24 |
25 | private static final int INITIAL_ROTATION_X = 80;
26 | private static final int INITIAL_ROTATION_Y = 70;
27 | private static final int INITIAL_ROTATION_Z = 10;
28 |
29 | @Override
30 | public void initView(View item, int position, int scrollDirection) {
31 | item.setPivotX(item.getWidth() / 2);
32 | item.setPivotY(item.getWidth() / 2);
33 | item.setRotationX(INITIAL_ROTATION_X);
34 | item.setRotationY(INITIAL_ROTATION_Y * scrollDirection);
35 | item.setRotation(INITIAL_ROTATION_Z);
36 | }
37 |
38 | @Override
39 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
40 | animator.rotationXBy(-INITIAL_ROTATION_X)
41 | .rotationYBy(-INITIAL_ROTATION_Y * scrollDirection)
42 | .rotationBy(-INITIAL_ROTATION_Z);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/WaveEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class WaveEffect implements JazzyEffect {
24 |
25 | @Override
26 | public void initView(View item, int position, int scrollDirection) {
27 | item.setTranslationX(-item.getWidth());
28 | }
29 |
30 | @Override
31 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
32 | animator.translationX(0);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/com/twotoasters/jazzylistview/effects/ZipperEffect.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.effects;
17 |
18 | import android.view.View;
19 | import android.view.ViewPropertyAnimator;
20 |
21 | import com.twotoasters.jazzylistview.JazzyEffect;
22 |
23 | public class ZipperEffect implements JazzyEffect {
24 |
25 | @Override
26 | public void initView(View item, int position, int scrollDirection) {
27 | boolean isEven = position % 2 == 0;
28 | item.setTranslationX((isEven ? -1 : 1) * item.getWidth());
29 | }
30 |
31 | @Override
32 | public void setupAnimation(View item, int position, int scrollDirection, ViewPropertyAnimator animator) {
33 | animator.translationX(0);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/library/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 |
--------------------------------------------------------------------------------
/sample/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
5 | buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion Integer.parseInt(ANDROID_BUILD_MIN_SDK_VERSION)
10 | targetSdkVersion Integer.parseInt(ANDROID_BUILD_TARGET_SDK_VERSION)
11 |
12 | versionCode Integer.parseInt(project.VERSION_CODE)
13 | versionName project.VERSION_NAME
14 | }
15 | }
16 |
17 | dependencies {
18 | compile 'com.android.support:support-v4:21.0.0'
19 | compile project(':library')
20 | compile project(':library-recyclerview')
21 | }
22 |
--------------------------------------------------------------------------------
/sample/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
25 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/ActivityInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.app.Activity;
19 |
20 | class ActivityInfo {
21 | public final Class extends Activity> activityClass;
22 | public final int titleRes;
23 | public final int itemLayoutRes;
24 | public final boolean isStaggered;
25 |
26 | public ActivityInfo(Class extends Activity> activityClass, int titleRes, int itemLayoutRes, boolean isStaggered) {
27 | this.activityClass = activityClass;
28 | this.titleRes = titleRes;
29 | this.itemLayoutRes = itemLayoutRes;
30 | this.isStaggered = isStaggered;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/GridViewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.app.Activity;
19 | import android.os.Bundle;
20 | import android.view.Menu;
21 | import android.view.MenuItem;
22 | import android.widget.Toast;
23 |
24 | import com.twotoasters.jazzylistview.JazzyGridView;
25 | import com.twotoasters.jazzylistview.JazzyHelper;
26 |
27 | import java.util.ArrayList;
28 | import java.util.Map;
29 |
30 | public class GridViewActivity extends Activity {
31 |
32 | private static final String KEY_TRANSITION_EFFECT = "transition_effect";
33 |
34 | private JazzyGridView mGrid;
35 | private Map mEffectMap;
36 | private int mCurrentTransitionEffect = JazzyHelper.HELIX;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_grid);
42 | mGrid = (JazzyGridView) findViewById(android.R.id.list);
43 | mGrid.setAdapter(new ListAdapter(this, R.layout.grid_item));
44 |
45 | if (savedInstanceState != null) {
46 | mCurrentTransitionEffect = savedInstanceState.getInt(KEY_TRANSITION_EFFECT, JazzyHelper.HELIX);
47 | setupJazziness(mCurrentTransitionEffect);
48 | }
49 | }
50 |
51 | @Override
52 | public boolean onCreateOptionsMenu(Menu menu) {
53 | mEffectMap = Utils.buildEffectMap(this);
54 | Utils.populateEffectMenu(menu, new ArrayList<>(mEffectMap.keySet()), this);
55 | return true;
56 | }
57 |
58 | @Override
59 | public boolean onOptionsItemSelected(MenuItem item) {
60 | String strEffect = item.getTitle().toString();
61 | Toast.makeText(this, strEffect, Toast.LENGTH_SHORT).show();
62 | setupJazziness(mEffectMap.get(strEffect));
63 | return true;
64 | }
65 |
66 | @Override
67 | public void onSaveInstanceState(Bundle outState) {
68 | super.onSaveInstanceState(outState);
69 | outState.putInt(KEY_TRANSITION_EFFECT, mCurrentTransitionEffect);
70 | }
71 |
72 | private void setupJazziness(int effect) {
73 | mCurrentTransitionEffect = effect;
74 | mGrid.setTransitionEffect(mCurrentTransitionEffect);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/ListAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.content.Context;
19 | import android.content.res.Resources;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.widget.ArrayAdapter;
24 | import android.widget.TextView;
25 |
26 | class ListAdapter extends ArrayAdapter {
27 |
28 | private final LayoutInflater inflater;
29 | private final Resources res;
30 | private final int itemLayoutRes;
31 |
32 | public ListAdapter(Context context, int itemLayoutRes) {
33 | super(context, itemLayoutRes, R.id.text, ListModel.getModel());
34 | inflater = LayoutInflater.from(context);
35 | res = context.getResources();
36 | this.itemLayoutRes = itemLayoutRes;
37 | }
38 |
39 | @Override
40 | public View getView(int position, View convertView, ViewGroup parent) {
41 | ViewHolder holder;
42 |
43 | if (convertView == null) {
44 | convertView = inflater.inflate(itemLayoutRes, null);
45 | holder = new ViewHolder(convertView);
46 | convertView.setTag(holder);
47 | } else {
48 | holder = (ViewHolder) convertView.getTag();
49 | }
50 |
51 | holder.text.setBackgroundColor(res.getColor(Utils.getBackgroundColorRes(position, itemLayoutRes)));
52 | holder.text.setText(ListModel.getModelItem(position));
53 |
54 | return convertView;
55 | }
56 |
57 | static class ViewHolder {
58 | final TextView text;
59 |
60 | ViewHolder(View view) {
61 | text = (TextView) view.findViewById(R.id.text);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/ListModel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | final class ListModel {
19 |
20 | private static final String[] MODEL = {
21 | "Zero",
22 | "One",
23 | "Two",
24 | "Three",
25 | "Four",
26 | "Five",
27 | "Six",
28 | "Seven",
29 | "Eight",
30 | "Nine",
31 | "Ten",
32 | "Eleven",
33 | "Twelve",
34 | "Thirteen",
35 | "Fourteen",
36 | "Fifteen",
37 | "Sixteen",
38 | "Seventeen",
39 | "Eighteen",
40 | "Nineteen",
41 | "Twenty",
42 | "Twentyone",
43 | "Twentytwo",
44 | "Twentythree",
45 | "Twentyfour",
46 | "Twentyfive",
47 | "Twentysix",
48 | "Twentyseven",
49 | "Twentyeight",
50 | "Twentynine",
51 | "Thirty",
52 | "Thirtyone",
53 | "Thirtytwo",
54 | "Thirtythree",
55 | "Thirtyfour",
56 | "Thirtyfive",
57 | "Thirtysix",
58 | "Thirtyseven",
59 | "Thirtyeight",
60 | "Thirtynine",
61 | "Forty",
62 | "Fortyone",
63 | "Fortytwo",
64 | "Fortythree",
65 | "Fortyfour",
66 | "Fortyfive",
67 | "Fortysix",
68 | "Fortyseven",
69 | "Fortyeight",
70 | "Fortynine",
71 | "Fifty",
72 | "Fiftyone",
73 | "Fiftytwo",
74 | "Fiftythree",
75 | "Fiftyfour",
76 | "Fiftyfive",
77 | "Fiftysix",
78 | "Fiftyseven",
79 | "Fiftyeight",
80 | "Fiftynine",
81 | "Sixty",
82 | "Sixtyone",
83 | "Sixtytwo",
84 | "Sixtythree",
85 | "Sixtyfour",
86 | "Sixtyfive",
87 | "Sixtysix",
88 | "Sixtyseven",
89 | "Sixtyeight",
90 | "Sixtynine",
91 | "Seventy",
92 | "Seventyone",
93 | "Seventytwo",
94 | "Seventythree",
95 | "Seventyfour",
96 | "Seventyfive",
97 | "Seventysix",
98 | "Seventyseven",
99 | "Seventyeight",
100 | "Seventynine",
101 | "Eighty",
102 | "Eightyone",
103 | "Eightytwo",
104 | "Eightythree",
105 | "Eightyfour",
106 | "Eightyfive",
107 | "Eightysix",
108 | "Eightyseven",
109 | "Eightyeight",
110 | "Eightynine",
111 | "Ninety",
112 | "Ninetyone",
113 | "Ninetytwo",
114 | "Ninetythree",
115 | "Ninetyfour",
116 | "Ninetyfive",
117 | "Ninetysix",
118 | "Ninetyseven",
119 | "Ninetyeight",
120 | "Ninetynine"
121 | };
122 |
123 | public static String[] getModel() {
124 | return MODEL;
125 | }
126 |
127 | public static String getModelItem(int position) {
128 | return MODEL[position];
129 | }
130 |
131 | private ListModel() { }
132 | }
133 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/ListViewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.app.Activity;
19 | import android.os.Bundle;
20 | import android.view.Menu;
21 | import android.view.MenuItem;
22 | import android.widget.Toast;
23 |
24 | import com.twotoasters.jazzylistview.JazzyHelper;
25 | import com.twotoasters.jazzylistview.JazzyListView;
26 |
27 | import java.util.ArrayList;
28 | import java.util.Map;
29 |
30 | public class ListViewActivity extends Activity {
31 |
32 | private static final String KEY_TRANSITION_EFFECT = "transition_effect";
33 |
34 | private JazzyListView mList;
35 | private Map mEffectMap;
36 | private int mCurrentTransitionEffect = JazzyHelper.HELIX;
37 |
38 | @Override
39 | protected void onCreate(Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.activity_list);
42 | mList = (JazzyListView) findViewById(android.R.id.list);
43 | mList.setAdapter(new ListAdapter(this, R.layout.item));
44 |
45 | if (savedInstanceState != null) {
46 | mCurrentTransitionEffect = savedInstanceState.getInt(KEY_TRANSITION_EFFECT, JazzyHelper.HELIX);
47 | setupJazziness(mCurrentTransitionEffect);
48 | }
49 | }
50 |
51 | @Override
52 | public boolean onCreateOptionsMenu(Menu menu) {
53 | mEffectMap = Utils.buildEffectMap(this);
54 | Utils.populateEffectMenu(menu, new ArrayList<>(mEffectMap.keySet()), this);
55 | return true;
56 | }
57 |
58 | @Override
59 | public boolean onOptionsItemSelected(MenuItem item) {
60 | String strEffect = item.getTitle().toString();
61 | Toast.makeText(this, strEffect, Toast.LENGTH_SHORT).show();
62 | setupJazziness(mEffectMap.get(strEffect));
63 | return true;
64 | }
65 |
66 | @Override
67 | public void onSaveInstanceState(Bundle outState) {
68 | super.onSaveInstanceState(outState);
69 | outState.putInt(KEY_TRANSITION_EFFECT, mCurrentTransitionEffect);
70 | }
71 |
72 | private void setupJazziness(int effect) {
73 | mCurrentTransitionEffect = effect;
74 | mList.setTransitionEffect(mCurrentTransitionEffect);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.app.Activity;
19 | import android.app.ListActivity;
20 | import android.content.Intent;
21 | import android.os.Bundle;
22 | import android.view.View;
23 | import android.widget.ArrayAdapter;
24 | import android.widget.ListView;
25 |
26 | import java.util.Arrays;
27 | import java.util.List;
28 |
29 | public class MainActivity extends ListActivity {
30 |
31 | public static final String EXTRA_TITLE_RES = "title_res";
32 | public static final String EXTRA_ITEM_LAYOUT_RES = "item_layout_res";
33 | public static final String EXTRA_IS_STAGGERED = "is_staggered";
34 |
35 | private final List activityInfos = Arrays.asList(
36 | new ActivityInfo(ListViewActivity.class, R.string.listview_example, R.layout.item, false),
37 | new ActivityInfo(GridViewActivity.class, R.string.gridview_example, R.layout.grid_item, false),
38 | new ActivityInfo(RecyclerViewActivity.class, R.string.recyclerview_list_example, R.layout.item, false),
39 | new ActivityInfo(RecyclerViewActivity.class, R.string.recyclerview_grid_example, R.layout.grid_item, false),
40 | new ActivityInfo(RecyclerViewActivity.class, R.string.recyclerview_staggered_grid_example, R.layout.grid_item, true)
41 | );
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | String[] titles = getActivityTitles();
47 | setListAdapter(new ArrayAdapter<>(
48 | this, android.R.layout.simple_list_item_1, android.R.id.text1, titles));
49 | }
50 |
51 | @Override
52 | protected void onListItemClick(ListView l, View v, int position, long id) {
53 | ActivityInfo activityInfo = activityInfos.get(position);
54 | Class extends Activity> clazz = activityInfo.activityClass;
55 | startActivity(new Intent(this, clazz)
56 | .putExtra(EXTRA_TITLE_RES, activityInfo.titleRes)
57 | .putExtra(EXTRA_ITEM_LAYOUT_RES, activityInfo.itemLayoutRes)
58 | .putExtra(EXTRA_IS_STAGGERED, activityInfo.isStaggered));
59 | }
60 |
61 | private String[] getActivityTitles() {
62 | String[] result = new String[activityInfos.size()];
63 | int i = 0;
64 | for (ActivityInfo info : activityInfos) {
65 | result[i++] = getString(info.titleRes);
66 | }
67 | return result;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/RecyclerViewActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.app.Activity;
19 | import android.os.Bundle;
20 | import android.support.v7.widget.GridLayoutManager;
21 | import android.support.v7.widget.LinearLayoutManager;
22 | import android.support.v7.widget.RecyclerView;
23 | import android.support.v7.widget.RecyclerView.LayoutManager;
24 | import android.support.v7.widget.StaggeredGridLayoutManager;
25 | import android.view.Menu;
26 | import android.view.MenuItem;
27 | import android.widget.Toast;
28 |
29 | import com.twotoasters.jazzylistview.JazzyHelper;
30 | import com.twotoasters.jazzylistview.recyclerview.JazzyRecyclerViewScrollListener;
31 |
32 | import java.util.ArrayList;
33 | import java.util.Map;
34 |
35 | public class RecyclerViewActivity extends Activity {
36 |
37 | private static final String KEY_TRANSITION_EFFECT = "transition_effect";
38 |
39 | private Map mEffectMap;
40 | private int mCurrentTransitionEffect = JazzyHelper.HELIX;
41 | private JazzyRecyclerViewScrollListener jazzyScrollListener;
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_recyclerview);
47 | setTitle(getString(getIntent().getIntExtra(MainActivity.EXTRA_TITLE_RES, 0)));
48 |
49 | int itemLayoutRes = getIntent().getIntExtra(MainActivity.EXTRA_ITEM_LAYOUT_RES, R.layout.item);
50 | boolean isStaggered = getIntent().getBooleanExtra(MainActivity.EXTRA_IS_STAGGERED, false);
51 |
52 | RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
53 | recyclerView.setLayoutManager(createLayoutManager(itemLayoutRes, isStaggered));
54 | recyclerView.setHasFixedSize(true);
55 | recyclerView.setAdapter(new SampleRecyclerViewAdapter(ListModel.getModel(), itemLayoutRes, isStaggered));
56 |
57 | jazzyScrollListener = new JazzyRecyclerViewScrollListener();
58 | recyclerView.setOnScrollListener(jazzyScrollListener);
59 |
60 | if (savedInstanceState != null) {
61 | mCurrentTransitionEffect = savedInstanceState.getInt(KEY_TRANSITION_EFFECT, JazzyHelper.HELIX);
62 | setupJazziness(mCurrentTransitionEffect);
63 | }
64 | }
65 |
66 | private LayoutManager createLayoutManager(int itemLayoutRes, boolean isStaggered) {
67 | if (itemLayoutRes == R.layout.item) {
68 | return new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
69 | } else {
70 | if (isStaggered) {
71 | return new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
72 | } else {
73 | return new GridLayoutManager(this, 2);
74 | }
75 | }
76 | }
77 |
78 | @Override
79 | public boolean onCreateOptionsMenu(Menu menu) {
80 | mEffectMap = Utils.buildEffectMap(this);
81 | Utils.populateEffectMenu(menu, new ArrayList<>(mEffectMap.keySet()), this);
82 | return true;
83 | }
84 |
85 | @Override
86 | public boolean onOptionsItemSelected(MenuItem item) {
87 | String strEffect = item.getTitle().toString();
88 | Toast.makeText(this, strEffect, Toast.LENGTH_SHORT).show();
89 | setupJazziness(mEffectMap.get(strEffect));
90 | return true;
91 | }
92 |
93 | @Override
94 | public void onSaveInstanceState(Bundle outState) {
95 | super.onSaveInstanceState(outState);
96 | outState.putInt(KEY_TRANSITION_EFFECT, mCurrentTransitionEffect);
97 | }
98 |
99 | private void setupJazziness(int effect) {
100 | mCurrentTransitionEffect = effect;
101 | jazzyScrollListener.setTransitionEffect(mCurrentTransitionEffect);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/SampleRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.graphics.Color;
19 | import android.support.v7.widget.RecyclerView;
20 | import android.support.v7.widget.RecyclerView.Adapter;
21 | import android.view.LayoutInflater;
22 | import android.view.View;
23 | import android.view.ViewGroup;
24 | import android.widget.TextView;
25 |
26 | import com.twotoasters.jazzylistview.sample.SampleRecyclerViewAdapter.SampleViewHolder;
27 |
28 | import java.util.Arrays;
29 | import java.util.List;
30 |
31 | class SampleRecyclerViewAdapter extends Adapter {
32 |
33 | private List items;
34 | private int itemLayoutRes;
35 | private boolean isStaggered;
36 |
37 | SampleRecyclerViewAdapter(String[] items, int itemLayoutRes, boolean isStaggered) {
38 | this.items = Arrays.asList(items);
39 | this.itemLayoutRes = itemLayoutRes;
40 | this.isStaggered = isStaggered;
41 | }
42 |
43 | @Override
44 | public SampleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
45 | LayoutInflater inflater = LayoutInflater.from(parent.getContext());
46 | View view;
47 | if (isStaggered && viewType == 0) {
48 | view = inflater.inflate(R.layout.grid_item_taller, parent, false);
49 | } else {
50 | view = inflater.inflate(itemLayoutRes, parent, false);
51 | }
52 | return new SampleViewHolder(view);
53 | }
54 |
55 | @Override
56 | public void onBindViewHolder(SampleViewHolder holder, int position) {
57 | holder.text.setBackgroundColor(backgroundColor(position, holder));
58 | holder.text.setText(items.get(position));
59 | }
60 |
61 | @Override
62 | public int getItemCount() {
63 | return items != null ? items.size() : 0;
64 | }
65 |
66 | @Override
67 | public int getItemViewType(int position) {
68 | return isStaggered ? position % 2 : 0;
69 | }
70 |
71 | private int backgroundColor(int position, SampleViewHolder holder) {
72 | if (isStaggered) {
73 | int val = (int) (Math.random() * 55 + 200);
74 | return Color.rgb(val, val, val);
75 | } else {
76 | return holder.itemView.getResources().getColor(Utils.getBackgroundColorRes(position, itemLayoutRes));
77 | }
78 | }
79 |
80 | public static class SampleViewHolder extends RecyclerView.ViewHolder {
81 | final TextView text;
82 |
83 | SampleViewHolder(View view) {
84 | super(view);
85 | text = (TextView) view.findViewById(R.id.text);
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/sample/src/main/java/com/twotoasters/jazzylistview/sample/Utils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 Two Toasters
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.twotoasters.jazzylistview.sample;
17 |
18 | import android.content.Context;
19 | import android.view.Menu;
20 |
21 | import java.util.Collections;
22 | import java.util.LinkedHashMap;
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | public class Utils {
27 | private Utils() { }
28 |
29 | public static Map buildEffectMap(Context context) {
30 | Map effectMap = new LinkedHashMap<>();
31 | int i = 0;
32 | String[] effects = context.getResources().getStringArray(R.array.jazzy_effects);
33 | for (String effect : effects) {
34 | effectMap.put(effect, i++);
35 | }
36 | return effectMap;
37 | }
38 |
39 | public static void populateEffectMenu(Menu menu, List effectNames, Context context) {
40 | Collections.sort(effectNames);
41 | effectNames.remove(context.getString(R.string.standard));
42 | effectNames.add(0, context.getString(R.string.standard));
43 | for (String effectName : effectNames) {
44 | menu.add(effectName);
45 | }
46 | }
47 |
48 | public static int getBackgroundColorRes(int position, int itemLayoutRes) {
49 | if (itemLayoutRes == R.layout.item) {
50 | return position % 2 == 0 ? R.color.even : R.color.odd;
51 | } else {
52 | return (position % 4 == 0 || position % 4 == 3) ? R.color.even : R.color.odd;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_grid.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_list.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/activity_recyclerview.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/grid_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/grid_item_taller.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/sample/src/main/res/layout/item.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #323232
4 | #FFFFFF
5 | #eeeeee
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 48dp
3 | 150dp
4 | 243dp
5 | 16dp
6 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | JazzyListView
5 |
6 | Standard
7 | ListView Example
8 | GridView Example
9 | RecyclerView List Example
10 | RecyclerView Grid Example
11 | RecyclerView Staggered Grid Example
12 |
13 |
14 | - @string/standard
15 | - Grow
16 | - Cards
17 | - Curl
18 | - Wave
19 | - Flip
20 | - Fly
21 | - ReverseFly
22 | - Helix
23 | - Fan
24 | - Tilt
25 | - Zipper
26 | - Fade
27 | - Twirl
28 | - SlideIn
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sample/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
--------------------------------------------------------------------------------
/sample/web_hi_res_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/twotoasters/JazzyListView/4a69239f90374a71e7d4073448ca049bd074f7fe/sample/web_hi_res_512.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library'
2 | include ':library-recyclerview'
3 | include ':sample'
4 |
--------------------------------------------------------------------------------