├── .gitignore ├── LICENSE ├── README.md ├── badge.png ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── yalantis │ │ └── phoenix │ │ ├── PullToRefreshView.java │ │ ├── refresh_view │ │ ├── BaseRefreshView.java │ │ └── SunRefreshView.java │ │ └── util │ │ ├── Logger.java │ │ └── Utils.java │ └── res │ ├── drawable-hdpi │ ├── buildings.png │ ├── sky.png │ └── sun.png │ ├── drawable-mdpi │ ├── buildings.png │ ├── sky.png │ └── sun.png │ ├── drawable-xhdpi │ ├── buildings.png │ ├── sky.png │ └── sun.png │ ├── drawable-xxhdpi │ ├── buildings.png │ ├── sky.png │ └── sun.png │ ├── drawable-xxxhdpi │ ├── buildings.png │ ├── sky.png │ └── sun.png │ └── values │ └── attrs.xml ├── mavenpush.gradle ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── yalantis │ │ └── phoenix │ │ └── sample │ │ ├── BaseRefreshFragment.java │ │ ├── ListViewFragment.java │ │ ├── PullToRefreshActivity.java │ │ └── RecyclerViewFragment.java │ └── res │ ├── drawable-hdpi │ ├── icon_1.png │ ├── icon_2.png │ ├── icon_3.png │ └── lib_icon.png │ ├── drawable-mdpi │ ├── icon_1.png │ ├── icon_2.png │ ├── icon_3.png │ └── lib_icon.png │ ├── drawable-xhdpi │ ├── icon_1.png │ ├── icon_2.png │ ├── icon_3.png │ └── lib_icon.png │ ├── drawable-xxhdpi │ ├── icon_1.png │ ├── icon_2.png │ ├── icon_3.png │ └── lib_icon.png │ ├── drawable-xxxhdpi │ ├── icon_1.png │ ├── icon_2.png │ ├── icon_3.png │ └── lib_icon.png │ ├── layout │ ├── activity_pull_to_refresh.xml │ ├── fragment_list_view.xml │ ├── fragment_recycler_view.xml │ └── list_item.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # files for the dex VM 2 | *.dex 3 | 4 | # Java class files 5 | *.class 6 | 7 | # generated files 8 | bin/ 9 | gen/ 10 | out/ 11 | build/ 12 | 13 | # Local configuration file (sdk path, etc) 14 | local.properties 15 | 16 | # Eclipse project files 17 | .classpath 18 | .project 19 | 20 | # Windows thumbnail db 21 | .DS_Store 22 | 23 | # IDEA/Android Studio project files, because 24 | # the project can be imported from settings.gradle 25 | .idea 26 | *.iml 27 | 28 | # Old-style IDEA project files 29 | *.ipr 30 | *.iws 31 | 32 | # Local IDEA workspace 33 | .idea/workspace.xml 34 | 35 | # Gradle cache 36 | .gradle 37 | 38 | # Sandbox stuff 39 | _sandbox -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Phoenix-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/1386) [![Yalantis](https://github.com/Yalantis/Phoenix/blob/master/badge.png)](https://yalantis.com/?utm_source=github) 2 | 3 | # Phoenix Pull-to-Refresh 4 | 5 | #### This project aims to provide a simple and customizable pull to refresh implementation. Made in [Yalantis] (https://yalantis.com/?utm_source=github) 6 | 7 | Check this [project on Dribbble] (https://dribbble.com/shots/1650317-Pull-to-Refresh-Rentals) 8 | Check this [project on Behance] (https://www.behance.net/gallery/20411445/Mobile-Animations-Interactions) 9 | 10 | alt text 11 | 12 | #Usage 13 | 14 | *For a working implementation, Have a look at the Sample Project - sample* 15 | 16 | 1. Include the library as local library project. 17 | 18 | ``` compile 'com.yalantis:phoenix:1.2.3' ``` 19 | 20 | 2. Include the PullToRefreshView widget in your layout. 21 | 22 | ```xml 23 | 27 | 28 | 34 | 35 | 36 | ``` 37 | 38 | 3. In your `onCreate` method refer to the View and setup OnRefreshListener. 39 | ```java 40 | mPullToRefreshView = (PullToRefreshView) findViewById(R.id.pull_to_refresh); 41 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 42 | @Override 43 | public void onRefresh() { 44 | mPullToRefreshView.postDelayed(new Runnable() { 45 | @Override 46 | public void run() { 47 | mPullToRefreshView.setRefreshing(false); 48 | } 49 | }, REFRESH_DELAY); 50 | } 51 | }); 52 | ``` 53 | 54 | #Customization 55 | 56 | To customize drawables you can change: 57 | * sun.png - Sun image 58 | * sky.png - background image 59 | * buildings.png - foreground image 60 | 61 | # Misc 62 | If you need to change progress state: 63 | ```java 64 | mPullToRefreshView.setRefreshing(boolean isRefreshing) 65 | ``` 66 | #Compatibility 67 | 68 | * Android GINGERBREAD 2.3+ 69 | 70 | # Changelog 71 | 72 | ### Version: 1.2 73 | 74 | * Sample updated with RecyclerView example 75 | * Showing the refresh view just in it's bounds. (Issue with transparent / empty ListView) 76 | * Possibility to set refresh view padding 77 | 78 | ### Version: 1.0 79 | 80 | * Initial Build 81 | 82 | #### Let us know! 83 | 84 | We’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation. 85 | 86 | P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for Android (iOS) better than better. Stay tuned! 87 | 88 | ## License 89 | 90 | Copyright 2017, Yalantis 91 | 92 | Licensed under the Apache License, Version 2.0 (the "License"); 93 | you may not use this file except in compliance with the License. 94 | You may obtain a copy of the License at 95 | 96 | http://www.apache.org/licenses/LICENSE-2.0 97 | 98 | Unless required by applicable law or agreed to in writing, software 99 | distributed under the License is distributed on an "AS IS" BASIS, 100 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 101 | See the License for the specific language governing permissions and 102 | limitations under the License. 103 | -------------------------------------------------------------------------------- /badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/badge.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | dependencies { 6 | classpath 'com.android.tools.build:gradle:2.0.0-alpha1' 7 | } 8 | } 9 | 10 | def isReleaseBuild() { 11 | return version.contains("SNAPSHOT") == false 12 | } 13 | 14 | allprojects { 15 | version = VERSION_NAME 16 | group = GROUP 17 | 18 | repositories { 19 | mavenCentral() 20 | } 21 | } 22 | 23 | apply plugin: 'android-reporting' -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | VERSION_NAME=1.2.3 21 | VERSION_CODE=8 22 | GROUP=com.yalantis 23 | 24 | POM_DESCRIPTION=Android Library to add beautiful Pull-to-Refresh widget 25 | POM_URL=https://github.com/Yalantis/Phoenix 26 | POM_SCM_URL=https://github.com/Yalantis/Phoenix 27 | POM_SCM_CONNECTION=scm:git@github.com/Yalantis/Phoenix.git 28 | POM_SCM_DEV_CONNECTION=scm:git@github.com/Yalantis/Phoenix.git 29 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 30 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0 31 | POM_LICENCE_DIST=repo 32 | POM_DEVELOPER_ID=yalantis 33 | POM_DEVELOPER_NAME=Yalantis -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Nov 30 13:15:11 EET 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '23.0.2' 6 | 7 | defaultConfig { 8 | minSdkVersion 9 9 | targetSdkVersion 23 10 | versionCode 8 11 | versionName "1.2.3" 12 | } 13 | compileOptions { 14 | sourceCompatibility JavaVersion.VERSION_1_7 15 | targetCompatibility JavaVersion.VERSION_1_7 16 | } 17 | } 18 | 19 | dependencies { 20 | compile fileTree(dir: 'libs', include: ['*.jar']) 21 | compile 'com.android.support:support-v4:23.1.1' 22 | } 23 | 24 | apply from: '../mavenpush.gradle' -------------------------------------------------------------------------------- /library/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Phoenix 2 | POM_ARTIFACT_ID=phoenix 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/baoyz/Developer/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library/src/main/java/com/yalantis/phoenix/PullToRefreshView.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.support.annotation.NonNull; 6 | import android.support.v4.view.MotionEventCompat; 7 | import android.support.v4.view.ViewCompat; 8 | import android.util.AttributeSet; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.view.ViewConfiguration; 12 | import android.view.ViewGroup; 13 | import android.view.animation.Animation; 14 | import android.view.animation.DecelerateInterpolator; 15 | import android.view.animation.Interpolator; 16 | import android.view.animation.Transformation; 17 | import android.widget.AbsListView; 18 | import android.widget.ImageView; 19 | 20 | import com.yalantis.phoenix.refresh_view.BaseRefreshView; 21 | import com.yalantis.phoenix.refresh_view.SunRefreshView; 22 | import com.yalantis.phoenix.util.Utils; 23 | 24 | import java.security.InvalidParameterException; 25 | 26 | public class PullToRefreshView extends ViewGroup { 27 | 28 | private static final int DRAG_MAX_DISTANCE = 120; 29 | private static final float DRAG_RATE = .5f; 30 | private static final float DECELERATE_INTERPOLATION_FACTOR = 2f; 31 | 32 | public static final int STYLE_SUN = 0; 33 | public static final int MAX_OFFSET_ANIMATION_DURATION = 700; 34 | 35 | private static final int INVALID_POINTER = -1; 36 | 37 | private View mTarget; 38 | private ImageView mRefreshView; 39 | private Interpolator mDecelerateInterpolator; 40 | private int mTouchSlop; 41 | private int mTotalDragDistance; 42 | private BaseRefreshView mBaseRefreshView; 43 | private float mCurrentDragPercent; 44 | private int mCurrentOffsetTop; 45 | private boolean mRefreshing; 46 | private int mActivePointerId; 47 | private boolean mIsBeingDragged; 48 | private float mInitialMotionY; 49 | private int mFrom; 50 | private float mFromDragPercent; 51 | private boolean mNotify; 52 | private OnRefreshListener mListener; 53 | 54 | private int mTargetPaddingTop; 55 | private int mTargetPaddingBottom; 56 | private int mTargetPaddingRight; 57 | private int mTargetPaddingLeft; 58 | 59 | public PullToRefreshView(Context context) { 60 | this(context, null); 61 | } 62 | 63 | public PullToRefreshView(Context context, AttributeSet attrs) { 64 | super(context, attrs); 65 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RefreshView); 66 | final int type = a.getInteger(R.styleable.RefreshView_type, STYLE_SUN); 67 | a.recycle(); 68 | 69 | mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); 70 | mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); 71 | mTotalDragDistance = Utils.convertDpToPixel(context, DRAG_MAX_DISTANCE); 72 | 73 | mRefreshView = new ImageView(context); 74 | 75 | setRefreshStyle(type); 76 | 77 | addView(mRefreshView); 78 | 79 | setWillNotDraw(false); 80 | ViewCompat.setChildrenDrawingOrderEnabled(this, true); 81 | } 82 | 83 | public void setRefreshStyle(int type) { 84 | setRefreshing(false); 85 | switch (type) { 86 | case STYLE_SUN: 87 | mBaseRefreshView = new SunRefreshView(getContext(), this); 88 | break; 89 | default: 90 | throw new InvalidParameterException("Type does not exist"); 91 | } 92 | mRefreshView.setImageDrawable(mBaseRefreshView); 93 | } 94 | 95 | /** 96 | * This method sets padding for the refresh (progress) view. 97 | */ 98 | public void setRefreshViewPadding(int left, int top, int right, int bottom) { 99 | mRefreshView.setPadding(left, top, right, bottom); 100 | } 101 | 102 | public int getTotalDragDistance() { 103 | return mTotalDragDistance; 104 | } 105 | 106 | @Override 107 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 108 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 109 | 110 | ensureTarget(); 111 | if (mTarget == null) 112 | return; 113 | 114 | widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingRight() - getPaddingLeft(), MeasureSpec.EXACTLY); 115 | heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY); 116 | mTarget.measure(widthMeasureSpec, heightMeasureSpec); 117 | mRefreshView.measure(widthMeasureSpec, heightMeasureSpec); 118 | } 119 | 120 | private void ensureTarget() { 121 | if (mTarget != null) 122 | return; 123 | if (getChildCount() > 0) { 124 | for (int i = 0; i < getChildCount(); i++) { 125 | View child = getChildAt(i); 126 | if (child != mRefreshView) { 127 | mTarget = child; 128 | mTargetPaddingBottom = mTarget.getPaddingBottom(); 129 | mTargetPaddingLeft = mTarget.getPaddingLeft(); 130 | mTargetPaddingRight = mTarget.getPaddingRight(); 131 | mTargetPaddingTop = mTarget.getPaddingTop(); 132 | } 133 | } 134 | } 135 | } 136 | 137 | @Override 138 | public boolean onInterceptTouchEvent(MotionEvent ev) { 139 | 140 | if (!isEnabled() || canChildScrollUp() || mRefreshing) { 141 | return false; 142 | } 143 | 144 | final int action = MotionEventCompat.getActionMasked(ev); 145 | 146 | switch (action) { 147 | case MotionEvent.ACTION_DOWN: 148 | setTargetOffsetTop(0, true); 149 | mActivePointerId = MotionEventCompat.getPointerId(ev, 0); 150 | mIsBeingDragged = false; 151 | final float initialMotionY = getMotionEventY(ev, mActivePointerId); 152 | if (initialMotionY == -1) { 153 | return false; 154 | } 155 | mInitialMotionY = initialMotionY; 156 | break; 157 | case MotionEvent.ACTION_MOVE: 158 | if (mActivePointerId == INVALID_POINTER) { 159 | return false; 160 | } 161 | final float y = getMotionEventY(ev, mActivePointerId); 162 | if (y == -1) { 163 | return false; 164 | } 165 | final float yDiff = y - mInitialMotionY; 166 | if (yDiff > mTouchSlop && !mIsBeingDragged) { 167 | mIsBeingDragged = true; 168 | } 169 | break; 170 | case MotionEvent.ACTION_UP: 171 | case MotionEvent.ACTION_CANCEL: 172 | mIsBeingDragged = false; 173 | mActivePointerId = INVALID_POINTER; 174 | break; 175 | case MotionEventCompat.ACTION_POINTER_UP: 176 | onSecondaryPointerUp(ev); 177 | break; 178 | } 179 | 180 | return mIsBeingDragged; 181 | } 182 | 183 | @Override 184 | public boolean onTouchEvent(@NonNull MotionEvent ev) { 185 | 186 | if (!mIsBeingDragged) { 187 | return super.onTouchEvent(ev); 188 | } 189 | 190 | final int action = MotionEventCompat.getActionMasked(ev); 191 | 192 | switch (action) { 193 | case MotionEvent.ACTION_MOVE: { 194 | final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); 195 | if (pointerIndex < 0) { 196 | return false; 197 | } 198 | 199 | final float y = MotionEventCompat.getY(ev, pointerIndex); 200 | final float yDiff = y - mInitialMotionY; 201 | final float scrollTop = yDiff * DRAG_RATE; 202 | mCurrentDragPercent = scrollTop / mTotalDragDistance; 203 | if (mCurrentDragPercent < 0) { 204 | return false; 205 | } 206 | float boundedDragPercent = Math.min(1f, Math.abs(mCurrentDragPercent)); 207 | float extraOS = Math.abs(scrollTop) - mTotalDragDistance; 208 | float slingshotDist = mTotalDragDistance; 209 | float tensionSlingshotPercent = Math.max(0, 210 | Math.min(extraOS, slingshotDist * 2) / slingshotDist); 211 | float tensionPercent = (float) ((tensionSlingshotPercent / 4) - Math.pow( 212 | (tensionSlingshotPercent / 4), 2)) * 2f; 213 | float extraMove = (slingshotDist) * tensionPercent / 2; 214 | int targetY = (int) ((slingshotDist * boundedDragPercent) + extraMove); 215 | 216 | mBaseRefreshView.setPercent(mCurrentDragPercent, true); 217 | setTargetOffsetTop(targetY - mCurrentOffsetTop, true); 218 | break; 219 | } 220 | case MotionEventCompat.ACTION_POINTER_DOWN: 221 | final int index = MotionEventCompat.getActionIndex(ev); 222 | mActivePointerId = MotionEventCompat.getPointerId(ev, index); 223 | break; 224 | case MotionEventCompat.ACTION_POINTER_UP: 225 | onSecondaryPointerUp(ev); 226 | break; 227 | case MotionEvent.ACTION_UP: 228 | case MotionEvent.ACTION_CANCEL: { 229 | if (mActivePointerId == INVALID_POINTER) { 230 | return false; 231 | } 232 | final int pointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); 233 | final float y = MotionEventCompat.getY(ev, pointerIndex); 234 | final float overScrollTop = (y - mInitialMotionY) * DRAG_RATE; 235 | mIsBeingDragged = false; 236 | if (overScrollTop > mTotalDragDistance) { 237 | setRefreshing(true, true); 238 | } else { 239 | mRefreshing = false; 240 | animateOffsetToStartPosition(); 241 | } 242 | mActivePointerId = INVALID_POINTER; 243 | return false; 244 | } 245 | } 246 | 247 | return true; 248 | } 249 | 250 | private void animateOffsetToStartPosition() { 251 | mFrom = mCurrentOffsetTop; 252 | mFromDragPercent = mCurrentDragPercent; 253 | long animationDuration = Math.abs((long) (MAX_OFFSET_ANIMATION_DURATION * mFromDragPercent)); 254 | 255 | mAnimateToStartPosition.reset(); 256 | mAnimateToStartPosition.setDuration(animationDuration); 257 | mAnimateToStartPosition.setInterpolator(mDecelerateInterpolator); 258 | mAnimateToStartPosition.setAnimationListener(mToStartListener); 259 | mRefreshView.clearAnimation(); 260 | mRefreshView.startAnimation(mAnimateToStartPosition); 261 | } 262 | 263 | private void animateOffsetToCorrectPosition() { 264 | mFrom = mCurrentOffsetTop; 265 | mFromDragPercent = mCurrentDragPercent; 266 | 267 | mAnimateToCorrectPosition.reset(); 268 | mAnimateToCorrectPosition.setDuration(MAX_OFFSET_ANIMATION_DURATION); 269 | mAnimateToCorrectPosition.setInterpolator(mDecelerateInterpolator); 270 | mRefreshView.clearAnimation(); 271 | mRefreshView.startAnimation(mAnimateToCorrectPosition); 272 | 273 | if (mRefreshing) { 274 | mBaseRefreshView.start(); 275 | if (mNotify) { 276 | if (mListener != null) { 277 | mListener.onRefresh(); 278 | } 279 | } 280 | } else { 281 | mBaseRefreshView.stop(); 282 | animateOffsetToStartPosition(); 283 | } 284 | mCurrentOffsetTop = mTarget.getTop(); 285 | mTarget.setPadding(mTargetPaddingLeft, mTargetPaddingTop, mTargetPaddingRight, mTotalDragDistance); 286 | } 287 | 288 | private final Animation mAnimateToStartPosition = new Animation() { 289 | @Override 290 | public void applyTransformation(float interpolatedTime, Transformation t) { 291 | moveToStart(interpolatedTime); 292 | } 293 | }; 294 | 295 | private final Animation mAnimateToCorrectPosition = new Animation() { 296 | @Override 297 | public void applyTransformation(float interpolatedTime, Transformation t) { 298 | int targetTop; 299 | int endTarget = mTotalDragDistance; 300 | targetTop = (mFrom + (int) ((endTarget - mFrom) * interpolatedTime)); 301 | int offset = targetTop - mTarget.getTop(); 302 | 303 | mCurrentDragPercent = mFromDragPercent - (mFromDragPercent - 1.0f) * interpolatedTime; 304 | mBaseRefreshView.setPercent(mCurrentDragPercent, false); 305 | 306 | setTargetOffsetTop(offset, false /* requires update */); 307 | } 308 | }; 309 | 310 | private void moveToStart(float interpolatedTime) { 311 | int targetTop = mFrom - (int) (mFrom * interpolatedTime); 312 | float targetPercent = mFromDragPercent * (1.0f - interpolatedTime); 313 | int offset = targetTop - mTarget.getTop(); 314 | 315 | mCurrentDragPercent = targetPercent; 316 | mBaseRefreshView.setPercent(mCurrentDragPercent, true); 317 | mTarget.setPadding(mTargetPaddingLeft, mTargetPaddingTop, mTargetPaddingRight, mTargetPaddingBottom + targetTop); 318 | setTargetOffsetTop(offset, false); 319 | } 320 | 321 | public void setRefreshing(boolean refreshing) { 322 | if (mRefreshing != refreshing) { 323 | setRefreshing(refreshing, false /* notify */); 324 | } 325 | } 326 | 327 | private void setRefreshing(boolean refreshing, final boolean notify) { 328 | if (mRefreshing != refreshing) { 329 | mNotify = notify; 330 | ensureTarget(); 331 | mRefreshing = refreshing; 332 | if (mRefreshing) { 333 | mBaseRefreshView.setPercent(1f, true); 334 | animateOffsetToCorrectPosition(); 335 | } else { 336 | animateOffsetToStartPosition(); 337 | } 338 | } 339 | } 340 | 341 | private Animation.AnimationListener mToStartListener = new Animation.AnimationListener() { 342 | @Override 343 | public void onAnimationStart(Animation animation) { 344 | } 345 | 346 | @Override 347 | public void onAnimationRepeat(Animation animation) { 348 | } 349 | 350 | @Override 351 | public void onAnimationEnd(Animation animation) { 352 | mBaseRefreshView.stop(); 353 | mCurrentOffsetTop = mTarget.getTop(); 354 | } 355 | }; 356 | 357 | private void onSecondaryPointerUp(MotionEvent ev) { 358 | final int pointerIndex = MotionEventCompat.getActionIndex(ev); 359 | final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); 360 | if (pointerId == mActivePointerId) { 361 | final int newPointerIndex = pointerIndex == 0 ? 1 : 0; 362 | mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); 363 | } 364 | } 365 | 366 | private float getMotionEventY(MotionEvent ev, int activePointerId) { 367 | final int index = MotionEventCompat.findPointerIndex(ev, activePointerId); 368 | if (index < 0) { 369 | return -1; 370 | } 371 | return MotionEventCompat.getY(ev, index); 372 | } 373 | 374 | private void setTargetOffsetTop(int offset, boolean requiresUpdate) { 375 | mTarget.offsetTopAndBottom(offset); 376 | mBaseRefreshView.offsetTopAndBottom(offset); 377 | mCurrentOffsetTop = mTarget.getTop(); 378 | if (requiresUpdate && android.os.Build.VERSION.SDK_INT < 11) { 379 | invalidate(); 380 | } 381 | } 382 | 383 | private boolean canChildScrollUp() { 384 | if (android.os.Build.VERSION.SDK_INT < 14) { 385 | if (mTarget instanceof AbsListView) { 386 | final AbsListView absListView = (AbsListView) mTarget; 387 | return absListView.getChildCount() > 0 388 | && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) 389 | .getTop() < absListView.getPaddingTop()); 390 | } else { 391 | return mTarget.getScrollY() > 0; 392 | } 393 | } else { 394 | return ViewCompat.canScrollVertically(mTarget, -1); 395 | } 396 | } 397 | 398 | @Override 399 | protected void onLayout(boolean changed, int l, int t, int r, int b) { 400 | 401 | ensureTarget(); 402 | if (mTarget == null) 403 | return; 404 | 405 | int height = getMeasuredHeight(); 406 | int width = getMeasuredWidth(); 407 | int left = getPaddingLeft(); 408 | int top = getPaddingTop(); 409 | int right = getPaddingRight(); 410 | int bottom = getPaddingBottom(); 411 | 412 | mTarget.layout(left, top + mCurrentOffsetTop, left + width - right, top + height - bottom + mCurrentOffsetTop); 413 | mRefreshView.layout(left, top, left + width - right, top + height - bottom); 414 | } 415 | 416 | public void setOnRefreshListener(OnRefreshListener listener) { 417 | mListener = listener; 418 | } 419 | 420 | public interface OnRefreshListener { 421 | void onRefresh(); 422 | } 423 | 424 | } 425 | 426 | -------------------------------------------------------------------------------- /library/src/main/java/com/yalantis/phoenix/refresh_view/BaseRefreshView.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.refresh_view; 2 | 3 | import android.content.Context; 4 | import android.graphics.ColorFilter; 5 | import android.graphics.PixelFormat; 6 | import android.graphics.drawable.Animatable; 7 | import android.graphics.drawable.Drawable; 8 | import android.support.annotation.NonNull; 9 | 10 | import com.yalantis.phoenix.PullToRefreshView; 11 | 12 | public abstract class BaseRefreshView extends Drawable implements Drawable.Callback, Animatable { 13 | 14 | private PullToRefreshView mRefreshLayout; 15 | private boolean mEndOfRefreshing; 16 | 17 | public BaseRefreshView(Context context, PullToRefreshView layout) { 18 | mRefreshLayout = layout; 19 | } 20 | 21 | public Context getContext() { 22 | return mRefreshLayout != null ? mRefreshLayout.getContext() : null; 23 | } 24 | 25 | public PullToRefreshView getRefreshLayout() { 26 | return mRefreshLayout; 27 | } 28 | 29 | public abstract void setPercent(float percent, boolean invalidate); 30 | 31 | public abstract void offsetTopAndBottom(int offset); 32 | 33 | @Override 34 | public void invalidateDrawable(@NonNull Drawable who) { 35 | final Callback callback = getCallback(); 36 | if (callback != null) { 37 | callback.invalidateDrawable(this); 38 | } 39 | } 40 | 41 | @Override 42 | public void scheduleDrawable(Drawable who, Runnable what, long when) { 43 | final Callback callback = getCallback(); 44 | if (callback != null) { 45 | callback.scheduleDrawable(this, what, when); 46 | } 47 | } 48 | 49 | @Override 50 | public void unscheduleDrawable(Drawable who, Runnable what) { 51 | final Callback callback = getCallback(); 52 | if (callback != null) { 53 | callback.unscheduleDrawable(this, what); 54 | } 55 | } 56 | 57 | @Override 58 | public int getOpacity() { 59 | return PixelFormat.TRANSLUCENT; 60 | } 61 | 62 | @Override 63 | public void setAlpha(int alpha) { 64 | 65 | } 66 | 67 | @Override 68 | public void setColorFilter(ColorFilter cf) { 69 | 70 | } 71 | 72 | /** 73 | * Our animation depend on type of current work of refreshing. 74 | * We should to do different things when it's end of refreshing 75 | * 76 | * @param endOfRefreshing - we will check current state of refresh with this 77 | */ 78 | public void setEndOfRefreshing(boolean endOfRefreshing) { 79 | mEndOfRefreshing = endOfRefreshing; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /library/src/main/java/com/yalantis/phoenix/refresh_view/SunRefreshView.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.refresh_view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.graphics.Canvas; 7 | import android.graphics.Matrix; 8 | import android.graphics.Rect; 9 | import android.graphics.drawable.Animatable; 10 | import android.view.animation.Animation; 11 | import android.view.animation.Interpolator; 12 | import android.view.animation.LinearInterpolator; 13 | import android.view.animation.Transformation; 14 | 15 | import com.yalantis.phoenix.PullToRefreshView; 16 | import com.yalantis.phoenix.R; 17 | import com.yalantis.phoenix.util.Utils; 18 | 19 | /** 20 | * Created by Oleksii Shliama on 22/12/2014. 21 | * https://dribbble.com/shots/1650317-Pull-to-Refresh-Rentals 22 | */ 23 | public class SunRefreshView extends BaseRefreshView implements Animatable { 24 | 25 | private static final float SCALE_START_PERCENT = 0.5f; 26 | private static final int ANIMATION_DURATION = 1000; 27 | 28 | private final static float SKY_RATIO = 0.65f; 29 | private static final float SKY_INITIAL_SCALE = 1.05f; 30 | 31 | private final static float TOWN_RATIO = 0.22f; 32 | private static final float TOWN_INITIAL_SCALE = 1.20f; 33 | private static final float TOWN_FINAL_SCALE = 1.30f; 34 | 35 | private static final float SUN_FINAL_SCALE = 0.75f; 36 | private static final float SUN_INITIAL_ROTATE_GROWTH = 1.2f; 37 | private static final float SUN_FINAL_ROTATE_GROWTH = 1.5f; 38 | 39 | private static final Interpolator LINEAR_INTERPOLATOR = new LinearInterpolator(); 40 | 41 | private PullToRefreshView mParent; 42 | private Matrix mMatrix; 43 | private Animation mAnimation; 44 | 45 | private int mTop; 46 | private int mScreenWidth; 47 | 48 | private int mSkyHeight; 49 | private float mSkyTopOffset; 50 | private float mSkyMoveOffset; 51 | 52 | private int mTownHeight; 53 | private float mTownInitialTopOffset; 54 | private float mTownFinalTopOffset; 55 | private float mTownMoveOffset; 56 | 57 | private int mSunSize = 100; 58 | private float mSunLeftOffset; 59 | private float mSunTopOffset; 60 | 61 | private float mPercent = 0.0f; 62 | private float mRotate = 0.0f; 63 | 64 | private Bitmap mSky; 65 | private Bitmap mSun; 66 | private Bitmap mTown; 67 | 68 | private boolean isRefreshing = false; 69 | 70 | public SunRefreshView(Context context, final PullToRefreshView parent) { 71 | super(context, parent); 72 | mParent = parent; 73 | mMatrix = new Matrix(); 74 | 75 | setupAnimations(); 76 | parent.post(new Runnable() { 77 | @Override 78 | public void run() { 79 | initiateDimens(parent.getWidth()); 80 | } 81 | }); 82 | } 83 | 84 | public void initiateDimens(int viewWidth) { 85 | if (viewWidth <= 0 || viewWidth == mScreenWidth) return; 86 | 87 | mScreenWidth = viewWidth; 88 | mSkyHeight = (int) (SKY_RATIO * mScreenWidth); 89 | mSkyTopOffset = (mSkyHeight * 0.38f); 90 | mSkyMoveOffset = Utils.convertDpToPixel(getContext(), 15); 91 | 92 | mTownHeight = (int) (TOWN_RATIO * mScreenWidth); 93 | mTownInitialTopOffset = (mParent.getTotalDragDistance() - mTownHeight * TOWN_INITIAL_SCALE); 94 | mTownFinalTopOffset = (mParent.getTotalDragDistance() - mTownHeight * TOWN_FINAL_SCALE); 95 | mTownMoveOffset = Utils.convertDpToPixel(getContext(), 10); 96 | 97 | mSunLeftOffset = 0.3f * (float) mScreenWidth; 98 | mSunTopOffset = (mParent.getTotalDragDistance() * 0.1f); 99 | 100 | mTop = -mParent.getTotalDragDistance(); 101 | 102 | createBitmaps(); 103 | } 104 | 105 | private void createBitmaps() { 106 | final BitmapFactory.Options options = new BitmapFactory.Options(); 107 | options.inPreferredConfig = Bitmap.Config.RGB_565; 108 | 109 | mSky = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.sky, options); 110 | mSky = Bitmap.createScaledBitmap(mSky, mScreenWidth, mSkyHeight, true); 111 | mTown = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.buildings, options); 112 | mTown = Bitmap.createScaledBitmap(mTown, mScreenWidth, (int) (mScreenWidth * TOWN_RATIO), true); 113 | mSun = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.sun, options); 114 | mSun = Bitmap.createScaledBitmap(mSun, mSunSize, mSunSize, true); 115 | } 116 | 117 | @Override 118 | public void setPercent(float percent, boolean invalidate) { 119 | setPercent(percent); 120 | if (invalidate) setRotate(percent); 121 | } 122 | 123 | @Override 124 | public void offsetTopAndBottom(int offset) { 125 | mTop += offset; 126 | invalidateSelf(); 127 | } 128 | 129 | @Override 130 | public void draw(Canvas canvas) { 131 | if (mScreenWidth <= 0) return; 132 | 133 | final int saveCount = canvas.save(); 134 | 135 | canvas.translate(0, mTop); 136 | canvas.clipRect(0, -mTop, mScreenWidth, mParent.getTotalDragDistance()); 137 | 138 | drawSky(canvas); 139 | drawSun(canvas); 140 | drawTown(canvas); 141 | 142 | canvas.restoreToCount(saveCount); 143 | } 144 | 145 | private void drawSky(Canvas canvas) { 146 | Matrix matrix = mMatrix; 147 | matrix.reset(); 148 | 149 | float dragPercent = Math.min(1f, Math.abs(mPercent)); 150 | 151 | float skyScale; 152 | float scalePercentDelta = dragPercent - SCALE_START_PERCENT; 153 | if (scalePercentDelta > 0) { 154 | /** Change skyScale between {@link #SKY_INITIAL_SCALE} and 1.0f depending on {@link #mPercent} */ 155 | float scalePercent = scalePercentDelta / (1.0f - SCALE_START_PERCENT); 156 | skyScale = SKY_INITIAL_SCALE - (SKY_INITIAL_SCALE - 1.0f) * scalePercent; 157 | } else { 158 | skyScale = SKY_INITIAL_SCALE; 159 | } 160 | 161 | float offsetX = -(mScreenWidth * skyScale - mScreenWidth) / 2.0f; 162 | float offsetY = (1.0f - dragPercent) * mParent.getTotalDragDistance() - mSkyTopOffset // Offset canvas moving 163 | - mSkyHeight * (skyScale - 1.0f) / 2 // Offset sky scaling 164 | + mSkyMoveOffset * dragPercent; // Give it a little move top -> bottom 165 | 166 | matrix.postScale(skyScale, skyScale); 167 | matrix.postTranslate(offsetX, offsetY); 168 | canvas.drawBitmap(mSky, matrix, null); 169 | } 170 | 171 | private void drawTown(Canvas canvas) { 172 | Matrix matrix = mMatrix; 173 | matrix.reset(); 174 | 175 | float dragPercent = Math.min(1f, Math.abs(mPercent)); 176 | 177 | float townScale; 178 | float townTopOffset; 179 | float townMoveOffset; 180 | float scalePercentDelta = dragPercent - SCALE_START_PERCENT; 181 | if (scalePercentDelta > 0) { 182 | /** 183 | * Change townScale between {@link #TOWN_INITIAL_SCALE} and {@link #TOWN_FINAL_SCALE} depending on {@link #mPercent} 184 | * Change townTopOffset between {@link #mTownInitialTopOffset} and {@link #mTownFinalTopOffset} depending on {@link #mPercent} 185 | */ 186 | float scalePercent = scalePercentDelta / (1.0f - SCALE_START_PERCENT); 187 | townScale = TOWN_INITIAL_SCALE + (TOWN_FINAL_SCALE - TOWN_INITIAL_SCALE) * scalePercent; 188 | townTopOffset = mTownInitialTopOffset - (mTownFinalTopOffset - mTownInitialTopOffset) * scalePercent; 189 | townMoveOffset = mTownMoveOffset * (1.0f - scalePercent); 190 | } else { 191 | float scalePercent = dragPercent / SCALE_START_PERCENT; 192 | townScale = TOWN_INITIAL_SCALE; 193 | townTopOffset = mTownInitialTopOffset; 194 | townMoveOffset = mTownMoveOffset * scalePercent; 195 | } 196 | 197 | float offsetX = -(mScreenWidth * townScale - mScreenWidth) / 2.0f; 198 | float offsetY = (1.0f - dragPercent) * mParent.getTotalDragDistance() // Offset canvas moving 199 | + townTopOffset 200 | - mTownHeight * (townScale - 1.0f) / 2 // Offset town scaling 201 | + townMoveOffset; // Give it a little move 202 | 203 | matrix.postScale(townScale, townScale); 204 | matrix.postTranslate(offsetX, offsetY); 205 | 206 | canvas.drawBitmap(mTown, matrix, null); 207 | } 208 | 209 | private void drawSun(Canvas canvas) { 210 | Matrix matrix = mMatrix; 211 | matrix.reset(); 212 | 213 | float dragPercent = mPercent; 214 | if (dragPercent > 1.0f) { // Slow down if pulling over set height 215 | dragPercent = (dragPercent + 9.0f) / 10; 216 | } 217 | 218 | float sunRadius = (float) mSunSize / 2.0f; 219 | float sunRotateGrowth = SUN_INITIAL_ROTATE_GROWTH; 220 | 221 | float offsetX = mSunLeftOffset; 222 | float offsetY = mSunTopOffset 223 | + (mParent.getTotalDragDistance() / 2) * (1.0f - dragPercent) // Move the sun up 224 | - mTop; // Depending on Canvas position 225 | 226 | float scalePercentDelta = dragPercent - SCALE_START_PERCENT; 227 | if (scalePercentDelta > 0) { 228 | float scalePercent = scalePercentDelta / (1.0f - SCALE_START_PERCENT); 229 | float sunScale = 1.0f - (1.0f - SUN_FINAL_SCALE) * scalePercent; 230 | sunRotateGrowth += (SUN_FINAL_ROTATE_GROWTH - SUN_INITIAL_ROTATE_GROWTH) * scalePercent; 231 | 232 | matrix.preTranslate(offsetX + (sunRadius - sunRadius * sunScale), offsetY * (2.0f - sunScale)); 233 | matrix.preScale(sunScale, sunScale); 234 | 235 | offsetX += sunRadius; 236 | offsetY = offsetY * (2.0f - sunScale) + sunRadius * sunScale; 237 | } else { 238 | matrix.postTranslate(offsetX, offsetY); 239 | 240 | offsetX += sunRadius; 241 | offsetY += sunRadius; 242 | } 243 | 244 | matrix.postRotate( 245 | (isRefreshing ? -360 : 360) * mRotate * (isRefreshing ? 1 : sunRotateGrowth), 246 | offsetX, 247 | offsetY); 248 | 249 | canvas.drawBitmap(mSun, matrix, null); 250 | } 251 | 252 | public void setPercent(float percent) { 253 | mPercent = percent; 254 | } 255 | 256 | public void setRotate(float rotate) { 257 | mRotate = rotate; 258 | invalidateSelf(); 259 | } 260 | 261 | public void resetOriginals() { 262 | setPercent(0); 263 | setRotate(0); 264 | } 265 | 266 | @Override 267 | protected void onBoundsChange(Rect bounds) { 268 | super.onBoundsChange(bounds); 269 | } 270 | 271 | @Override 272 | public void setBounds(int left, int top, int right, int bottom) { 273 | super.setBounds(left, top, right, mSkyHeight + top); 274 | } 275 | 276 | @Override 277 | public boolean isRunning() { 278 | return false; 279 | } 280 | 281 | @Override 282 | public void start() { 283 | mAnimation.reset(); 284 | isRefreshing = true; 285 | mParent.startAnimation(mAnimation); 286 | } 287 | 288 | @Override 289 | public void stop() { 290 | mParent.clearAnimation(); 291 | isRefreshing = false; 292 | resetOriginals(); 293 | } 294 | 295 | private void setupAnimations() { 296 | mAnimation = new Animation() { 297 | @Override 298 | public void applyTransformation(float interpolatedTime, Transformation t) { 299 | setRotate(interpolatedTime); 300 | } 301 | }; 302 | mAnimation.setRepeatCount(Animation.INFINITE); 303 | mAnimation.setRepeatMode(Animation.RESTART); 304 | mAnimation.setInterpolator(LINEAR_INTERPOLATOR); 305 | mAnimation.setDuration(ANIMATION_DURATION); 306 | } 307 | 308 | } 309 | -------------------------------------------------------------------------------- /library/src/main/java/com/yalantis/phoenix/util/Logger.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.util; 2 | 3 | import android.text.TextUtils; 4 | 5 | public final class Logger { 6 | 7 | private static final String TAG = "Phoenix"; 8 | 9 | /** 10 | * Set true or false if you want read logs or not 11 | */ 12 | private static boolean logEnabled_d = false; 13 | private static boolean logEnabled_i = false; 14 | private static boolean logEnabled_e = false; 15 | 16 | public static void d() { 17 | if (logEnabled_d) { 18 | android.util.Log.v(TAG, getLocation()); 19 | } 20 | } 21 | 22 | public static void d(String msg) { 23 | if (logEnabled_d) { 24 | android.util.Log.v(TAG, getLocation() + msg); 25 | } 26 | } 27 | 28 | public static void i(String msg) { 29 | if (logEnabled_i) { 30 | android.util.Log.i(TAG, getLocation() + msg); 31 | } 32 | } 33 | 34 | public static void i() { 35 | if (logEnabled_i) { 36 | android.util.Log.i(TAG, getLocation()); 37 | } 38 | } 39 | 40 | public static void e(String msg) { 41 | if (logEnabled_e) { 42 | android.util.Log.e(TAG, getLocation() + msg); 43 | } 44 | } 45 | 46 | public static void e(String msg, Throwable e) { 47 | if (logEnabled_e) { 48 | android.util.Log.e(TAG, getLocation() + msg, e); 49 | } 50 | } 51 | 52 | public static void e(Throwable e) { 53 | if (logEnabled_e) { 54 | android.util.Log.e(TAG, getLocation(), e); 55 | } 56 | } 57 | 58 | public static void e() { 59 | if (logEnabled_e) { 60 | android.util.Log.e(TAG, getLocation()); 61 | } 62 | } 63 | 64 | private static String getLocation() { 65 | final String className = Logger.class.getName(); 66 | final StackTraceElement[] traces = Thread.currentThread() 67 | .getStackTrace(); 68 | boolean found = false; 69 | 70 | for (StackTraceElement trace : traces) { 71 | try { 72 | if (found) { 73 | if (!trace.getClassName().startsWith(className)) { 74 | Class clazz = Class.forName(trace.getClassName()); 75 | return "[" + getClassName(clazz) + ":" 76 | + trace.getMethodName() + ":" 77 | + trace.getLineNumber() + "]: "; 78 | } 79 | } else if (trace.getClassName().startsWith(className)) { 80 | found = true; 81 | } 82 | } catch (ClassNotFoundException ignored) { 83 | } 84 | } 85 | 86 | return "[]: "; 87 | } 88 | 89 | private static String getClassName(Class clazz) { 90 | if (clazz != null) { 91 | if (!TextUtils.isEmpty(clazz.getSimpleName())) { 92 | return clazz.getSimpleName(); 93 | } 94 | 95 | return getClassName(clazz.getEnclosingClass()); 96 | } 97 | 98 | return ""; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /library/src/main/java/com/yalantis/phoenix/util/Utils.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.util; 2 | 3 | import android.content.Context; 4 | 5 | public class Utils { 6 | 7 | public static int convertDpToPixel(Context context, int dp) { 8 | float density = context.getResources().getDisplayMetrics().density; 9 | return Math.round((float) dp * density); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-hdpi/buildings.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-hdpi/sky.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-hdpi/sun.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-mdpi/buildings.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-mdpi/sky.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-mdpi/sun.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xhdpi/buildings.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xhdpi/sky.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xhdpi/sun.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxhdpi/buildings.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxhdpi/sky.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxhdpi/sun.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxxhdpi/buildings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxxhdpi/buildings.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxxhdpi/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxxhdpi/sky.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxxhdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/library/src/main/res/drawable-xxxhdpi/sun.png -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mavenpush.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven' 2 | apply plugin: 'signing' 3 | 4 | def sonatypeRepositoryUrl 5 | if (isReleaseBuild()) { 6 | println 'RELEASE BUILD' 7 | sonatypeRepositoryUrl = hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL 8 | : "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 9 | } else { 10 | println 'DEBUG BUILD' 11 | sonatypeRepositoryUrl = hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL 12 | : "https://oss.sonatype.org/content/repositories/snapshots/" 13 | } 14 | 15 | def getRepositoryUsername() { 16 | return hasProperty('nexusUsername') ? nexusUsername : "" 17 | } 18 | 19 | def getRepositoryPassword() { 20 | return hasProperty('nexusPassword') ? nexusPassword : "" 21 | } 22 | 23 | afterEvaluate { project -> 24 | uploadArchives { 25 | repositories { 26 | mavenDeployer { 27 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 28 | 29 | pom.artifactId = POM_ARTIFACT_ID 30 | 31 | repository(url: sonatypeRepositoryUrl) { 32 | authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) 33 | } 34 | 35 | pom.project { 36 | name POM_NAME 37 | packaging POM_PACKAGING 38 | description POM_DESCRIPTION 39 | url POM_URL 40 | 41 | scm { 42 | url POM_SCM_URL 43 | connection POM_SCM_CONNECTION 44 | developerConnection POM_SCM_DEV_CONNECTION 45 | } 46 | 47 | licenses { 48 | license { 49 | name POM_LICENCE_NAME 50 | url POM_LICENCE_URL 51 | distribution POM_LICENCE_DIST 52 | } 53 | } 54 | 55 | developers { 56 | developer { 57 | id POM_DEVELOPER_ID 58 | name POM_DEVELOPER_NAME 59 | } 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | signing { 67 | required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } 68 | sign configurations.archives 69 | } 70 | 71 | task androidJavadocs(type: Javadoc) { 72 | source = android.sourceSets.main.java.sourceFiles 73 | } 74 | 75 | task androidJavadocsJar(type: Jar) { 76 | classifier = 'javadoc' 77 | //basename = artifact_id 78 | from androidJavadocs.destinationDir 79 | } 80 | 81 | task androidSourcesJar(type: Jar) { 82 | classifier = 'sources' 83 | //basename = artifact_id 84 | from android.sourceSets.main.java.sourceFiles 85 | } 86 | 87 | artifacts { 88 | //archives packageReleaseJar 89 | archives androidSourcesJar 90 | archives androidJavadocsJar 91 | } 92 | } -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '23.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.yalantis.phoenix.sample" 9 | minSdkVersion 9 10 | targetSdkVersion 23 11 | versionCode 2 12 | versionName "2.0" 13 | } 14 | compileOptions { 15 | sourceCompatibility JavaVersion.VERSION_1_7 16 | targetCompatibility JavaVersion.VERSION_1_7 17 | } 18 | } 19 | 20 | dependencies { 21 | compile 'com.android.support:design:23.1.1' 22 | compile 'com.android.support:recyclerview-v7:23.1.1' 23 | compile project(':library') 24 | } 25 | -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/oleksii/dev/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/java/com/yalantis/phoenix/sample/BaseRefreshFragment.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.sample; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | * Created by Oleksii Shliama. 13 | */ 14 | public class BaseRefreshFragment extends Fragment { 15 | 16 | public static final int REFRESH_DELAY = 2000; 17 | 18 | public static final String KEY_ICON = "icon"; 19 | public static final String KEY_COLOR = "color"; 20 | 21 | protected List> mSampleList; 22 | 23 | @Override 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | 27 | Map map; 28 | mSampleList = new ArrayList<>(); 29 | 30 | int[] icons = { 31 | R.drawable.icon_1, 32 | R.drawable.icon_2, 33 | R.drawable.icon_3}; 34 | 35 | int[] colors = { 36 | R.color.saffron, 37 | R.color.eggplant, 38 | R.color.sienna}; 39 | 40 | for (int i = 0; i < icons.length; i++) { 41 | map = new HashMap<>(); 42 | map.put(KEY_ICON, icons[i]); 43 | map.put(KEY_COLOR, colors[i]); 44 | mSampleList.add(map); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample/src/main/java/com/yalantis/phoenix/sample/ListViewFragment.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.sample; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.NonNull; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.ImageView; 11 | import android.widget.ListView; 12 | 13 | import com.yalantis.phoenix.PullToRefreshView; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | /** 19 | * Created by Oleksii Shliama. 20 | */ 21 | public class ListViewFragment extends BaseRefreshFragment { 22 | 23 | private PullToRefreshView mPullToRefreshView; 24 | 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 27 | ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_list_view, container, false); 28 | 29 | ListView listView = (ListView) rootView.findViewById(R.id.list_view); 30 | listView.setAdapter(new SampleAdapter(getActivity(), R.layout.list_item, mSampleList)); 31 | 32 | mPullToRefreshView = (PullToRefreshView) rootView.findViewById(R.id.pull_to_refresh); 33 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 34 | @Override 35 | public void onRefresh() { 36 | mPullToRefreshView.postDelayed(new Runnable() { 37 | @Override 38 | public void run() { 39 | mPullToRefreshView.setRefreshing(false); 40 | } 41 | }, REFRESH_DELAY); 42 | } 43 | }); 44 | 45 | return rootView; 46 | } 47 | 48 | class SampleAdapter extends ArrayAdapter> { 49 | 50 | public static final String KEY_ICON = "icon"; 51 | public static final String KEY_COLOR = "color"; 52 | 53 | private final LayoutInflater mInflater; 54 | private final List> mData; 55 | 56 | public SampleAdapter(Context context, int layoutResourceId, List> data) { 57 | super(context, layoutResourceId, data); 58 | mData = data; 59 | mInflater = LayoutInflater.from(context); 60 | } 61 | 62 | @Override 63 | public View getView(final int position, View convertView, @NonNull ViewGroup parent) { 64 | final ViewHolder viewHolder; 65 | if (convertView == null) { 66 | viewHolder = new ViewHolder(); 67 | convertView = mInflater.inflate(R.layout.list_item, parent, false); 68 | viewHolder.imageViewIcon = (ImageView) convertView.findViewById(R.id.image_view_icon); 69 | convertView.setTag(viewHolder); 70 | } else { 71 | viewHolder = (ViewHolder) convertView.getTag(); 72 | } 73 | 74 | viewHolder.imageViewIcon.setImageResource(mData.get(position).get(KEY_ICON)); 75 | convertView.setBackgroundResource(mData.get(position).get(KEY_COLOR)); 76 | 77 | return convertView; 78 | } 79 | 80 | class ViewHolder { 81 | ImageView imageViewIcon; 82 | } 83 | 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /sample/src/main/java/com/yalantis/phoenix/sample/PullToRefreshActivity.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.sample; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.TabLayout; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.app.FragmentPagerAdapter; 8 | import android.support.v4.view.ViewPager; 9 | import android.support.v7.app.AppCompatActivity; 10 | import android.support.v7.widget.Toolbar; 11 | 12 | /** 13 | * Created by Oleksii Shliama. 14 | */ 15 | public class PullToRefreshActivity extends AppCompatActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_pull_to_refresh); 21 | 22 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 23 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); 24 | ViewPager viewPager = (ViewPager) findViewById(R.id.pager); 25 | 26 | if (toolbar != null) { 27 | setSupportActionBar(toolbar); 28 | } 29 | 30 | viewPager.setAdapter(new SectionPagerAdapter(getSupportFragmentManager())); 31 | tabLayout.setupWithViewPager(viewPager); 32 | } 33 | 34 | public class SectionPagerAdapter extends FragmentPagerAdapter { 35 | 36 | public SectionPagerAdapter(FragmentManager fm) { 37 | super(fm); 38 | } 39 | 40 | @Override 41 | public Fragment getItem(int position) { 42 | switch (position) { 43 | case 0: 44 | return new ListViewFragment(); 45 | case 1: 46 | default: 47 | return new RecyclerViewFragment(); 48 | } 49 | } 50 | 51 | @Override 52 | public int getCount() { 53 | return 2; 54 | } 55 | 56 | @Override 57 | public CharSequence getPageTitle(int position) { 58 | switch (position) { 59 | case 0: 60 | return "ListView"; 61 | case 1: 62 | default: 63 | return "RecyclerView"; 64 | } 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /sample/src/main/java/com/yalantis/phoenix/sample/RecyclerViewFragment.java: -------------------------------------------------------------------------------- 1 | package com.yalantis.phoenix.sample; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | 11 | import com.yalantis.phoenix.PullToRefreshView; 12 | 13 | import java.util.Map; 14 | 15 | /** 16 | * Created by Oleksii Shliama. 17 | */ 18 | public class RecyclerViewFragment extends BaseRefreshFragment { 19 | 20 | private PullToRefreshView mPullToRefreshView; 21 | 22 | @Override 23 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 24 | ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_recycler_view, container, false); 25 | 26 | RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); 27 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); 28 | 29 | recyclerView.setAdapter(new SampleAdapter()); 30 | 31 | mPullToRefreshView = (PullToRefreshView) rootView.findViewById(R.id.pull_to_refresh); 32 | mPullToRefreshView.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { 33 | @Override 34 | public void onRefresh() { 35 | mPullToRefreshView.postDelayed(new Runnable() { 36 | @Override 37 | public void run() { 38 | mPullToRefreshView.setRefreshing(false); 39 | } 40 | }, REFRESH_DELAY); 41 | } 42 | }); 43 | 44 | return rootView; 45 | } 46 | 47 | private class SampleAdapter extends RecyclerView.Adapter { 48 | 49 | @Override 50 | public SampleHolder onCreateViewHolder(ViewGroup parent, int pos) { 51 | View view = LayoutInflater.from(parent.getContext()) 52 | .inflate(R.layout.list_item, parent, false); 53 | return new SampleHolder(view); 54 | } 55 | 56 | @Override 57 | public void onBindViewHolder(SampleHolder holder, int pos) { 58 | Map data = mSampleList.get(pos); 59 | holder.bindData(data); 60 | } 61 | 62 | @Override 63 | public int getItemCount() { 64 | return mSampleList.size(); 65 | } 66 | } 67 | 68 | private class SampleHolder extends RecyclerView.ViewHolder { 69 | 70 | private View mRootView; 71 | private ImageView mImageViewIcon; 72 | 73 | private Map mData; 74 | 75 | public SampleHolder(View itemView) { 76 | super(itemView); 77 | 78 | mRootView = itemView; 79 | mImageViewIcon = (ImageView) itemView.findViewById(R.id.image_view_icon); 80 | } 81 | 82 | public void bindData(Map data) { 83 | mData = data; 84 | 85 | mRootView.setBackgroundResource(mData.get(KEY_COLOR)); 86 | mImageViewIcon.setImageResource(mData.get(KEY_ICON)); 87 | } 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-hdpi/icon_1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-hdpi/icon_2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-hdpi/icon_3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/lib_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-hdpi/lib_icon.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-mdpi/icon_1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-mdpi/icon_2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-mdpi/icon_3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/lib_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-mdpi/lib_icon.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xhdpi/icon_1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xhdpi/icon_2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xhdpi/icon_3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/lib_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xhdpi/lib_icon.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxhdpi/icon_1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxhdpi/icon_2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxhdpi/icon_3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/lib_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxhdpi/lib_icon.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/icon_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxxhdpi/icon_1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/icon_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxxhdpi/icon_2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/icon_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxxhdpi/icon_3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/lib_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yalantis/Phoenix/50728bc07b84c44863438128cf72b434c00bb1c9/sample/src/main/res/drawable-xxxhdpi/lib_icon.png -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_pull_to_refresh.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 17 | 18 | 22 | 23 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_list_view.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/fragment_recycler_view.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F4B63E 4 | #663D4E 5 | #EB6460 6 | 7 | #303030 8 | #303030 9 | #8661C1 10 | -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 222dp 4 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Phoenix 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':library' 2 | --------------------------------------------------------------------------------