├── .buildscript └── deploy_snapshot.sh ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE.txt ├── README.md ├── RELEASING.md ├── assets ├── arrow_refresh_indicator.gif ├── circle_refresh_indicator.gif └── pull_from_bottom.gif ├── build.gradle ├── circlerefreshlayout-rxbinding ├── build.gradle ├── gradle.properties └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── androidhuman │ └── circlerefreshlayout │ └── rxbinding │ ├── RxSwipeRefreshLayout.java │ └── SwipeRefreshLayoutRefreshOnSubscribe.java ├── circlerefreshlayout-sample ├── build.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── androidhuman │ │ └── circlerefreshlayout │ │ └── sample │ │ ├── MainActivity.java │ │ ├── RefreshLayoutActivity.java │ │ └── WebViewActivity.java │ └── res │ ├── layout │ ├── activity_main.xml │ ├── activity_refreshlayout.xml │ ├── activity_webview.xml │ └── item_simple.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── circlerefreshlayout ├── .gitignore ├── build.gradle ├── gradle.properties ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── androidhuman │ │ └── circlerefreshlayout │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── androidhuman │ │ └── circlerefreshlayout │ │ ├── CircleImageView.java │ │ ├── MaterialProgressDrawable.java │ │ └── SwipeRefreshLayout.java │ └── test │ └── java │ └── com │ └── androidhuman │ └── circlerefreshlayout │ └── ExampleUnitTest.java ├── config └── checkstyle │ ├── checkstyle.xml │ ├── checkstyle.xsl │ └── checkstyle_suppressions.xml ├── dependencies.gradle ├── gradle.properties ├── gradle ├── gradle-mvn-push.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.buildscript/deploy_snapshot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo. 4 | # 5 | # Adapted from https://coderwall.com/p/9b_lfq and 6 | # http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/ 7 | 8 | SLUG="kunny/android-CircleRefreshLayout" 9 | JDK="oraclejdk8" 10 | BRANCH="master" 11 | 12 | set -e 13 | 14 | if [ "$TRAVIS_REPO_SLUG" != "$SLUG" ]; then 15 | echo "Skipping snapshot deployment: wrong repository. Expected '$SLUG' but was '$TRAVIS_REPO_SLUG'." 16 | elif [ "$TRAVIS_JDK_VERSION" != "$JDK" ]; then 17 | echo "Skipping snapshot deployment: wrong JDK. Expected '$JDK' but was '$TRAVIS_JDK_VERSION'." 18 | elif [ "$TRAVIS_PULL_REQUEST" != "false" ]; then 19 | echo "Skipping snapshot deployment: was pull request." 20 | elif [ "$TRAVIS_BRANCH" != "$BRANCH" ]; then 21 | echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '$TRAVIS_BRANCH'." 22 | elif [ "$MODULE" == "circlerefreshlayout-sample" ]; then 23 | echo "Skipping snapshot deployment: sample app" 24 | else 25 | echo "Deploying snapshot..." 26 | ./gradlew clean "$MODULE:uploadArchives" 27 | echo "Snapshot deployed!" 28 | fi -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | *.iml 4 | 5 | # Built application files 6 | *.apk 7 | *.ap_ 8 | 9 | # Files for the Dalvik VM 10 | *.dex 11 | 12 | # Java class files 13 | *.class 14 | 15 | # Generated files 16 | bin/ 17 | gen/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | sudo: false 3 | 4 | android: 5 | components: 6 | - platform-tools 7 | - tools 8 | - build-tools-23.0.3 9 | - android-23 10 | - extra-android-m2repository 11 | 12 | jdk: 13 | - oraclejdk8 14 | 15 | script: 16 | - ./gradlew checkstyle "$MODULE:build" 17 | 18 | after_success: 19 | - .buildscript/deploy_snapshot.sh 20 | 21 | env: 22 | matrix: 23 | - MODULE=circlerefreshlayout 24 | - MODULE=circlerefreshlayout-rxbinding 25 | - MODULE=circlerefreshlayout-sample 26 | global: 27 | - secure: "9Dt1DOrW79rFLO8XqcZbcaxI/OcVVhppLVY+PPYSTyqiXWtNtATHp9CcSihjKMVMwH6bgP8fgdCU3pnmQPxwW9C8SYlu27i76vPVBAmpk9rPqLtY/i5Vphr5G/S71lluU9aFO6tmmCHjDVAJK/DwIJSgPqTeGXzGm/971cXkS4OuXqxUuuULufUoLWKVRnD2yGK3e/VkfJXMIC9dzYycJ5fBZGCf+G1qY3LyGgUulzfPZUTETBy1NGijTlp3D0cnN1iL++JZaEztuAyDim5uQk17X66ZzeoKxfImd36iwa/sGAqaOUsug84JoyT713dnMDSSlqfEjJ/LLkI88z8+tPb+q+XvTBaq9mr9C1CvWpZM/8wrIcEZ36Jkkpl2pK+jH8Mh0+1jfWCuYlXZp8ZYDoXUHoGVeiLad2mDMMFuEx6mmsmNHxnrReR7h1np9ZG8bIEl6qM/o8cmQdpVsDV7i6HoPGIQbomch4Am4b5KtXck61XRmxeWa4nDLIwSiLHun1HUe9BxgKjJQnrNsmTsiiBsbY0kPxfdrNK3zDPOiDnDs3nrKHTb1elZjdsRkmbpghqbjJ9cay3V1C8mT1Ii4iK7uTryobKBoe2d1uhuxNEjoNbfhz3fD55rkMYJeMR4m28siEli2130Oajb25xk+w9451o+iX8WI0e6RwEiRIw=" 28 | - secure: "OhmaonEXYwp0MUc89oPdMLDOQ60Eg3xRjLFe4PdtsGVi+ovgRtlg5o55syZ9TYIb/9CIwd1AoeaIcYQ++zlH4crDU2Q7OvO+7Gq+hpnPUO4qq55zrmerOMKlxgjiR/lU3nN+n/mU/epxrINgHVvB2Qex5njqVDHGgY/0PhUSeVzVnSK3Mhr8UD9uukpFp3GsQXvjOCS7qF4X9lK2P06FMmm1EY+aPjwTgVuztO+p6i4AOmbdsa5xkiv0T4ko46eINbk2zMrXi55B4wQ7q5PwUXi7y+SpWxPRQIWlDSU3n/teHgN6rRrvpSMv68VgT/sa8ImjsYA88Q61tiqaxxVGWmelH7BDBViJ8mGNR8GKcGg756GhSbFn0BT7hMwXu6lmKU+N5c42aSSsIFkzLMZGYpoVJKZ/jMKpLQUO/x6DLuOTyP6/N9QKhA+HWvwNmgu4RtuHfTEuO6b5k+JQ4/VjO90pIQJn8uPZLyjqPTdKo23YHabgN4HC+6OI2Ij53+1H+qW5q+jMPZMbS/mKb8XHwKJbJJ2loZucK6EA+oFm2a5psqW7axwbE1lbw6TA7tXir0LDYUYqp2NMEWgxClxGPur1iz4oxvfms/wymJtd4DfZlZiTuXrlQ27j6TPHKhNhx4YrtSO41dB6F3vUKYamMLEsX5H+olo35yO2ptCh7zI=" 29 | 30 | cache: 31 | directories: 32 | - $HOME/.gradle -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## Version 0.1.0 *(2016-05-12)* 4 | 5 | Initial release. 6 | -------------------------------------------------------------------------------- /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 [yyyy] [name of copyright owner] 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 | # android-CircleRefreshLayout [![Build status](https://travis-ci.org/kunny/android-CircleRefreshLayout.svg?branch=master)](https://travis-ci.org/kunny/android-CircleRefreshLayout) 2 | 3 | A customized SwipeRefreshLayout that supports circular refresh indicator and pull to refresh from the bottom. 4 | 5 | ## Screenshots 6 | 7 | ### Circle Refresh indicator (No arrow) 8 | ![Circle refresh indicator](assets/circle_refresh_indicator.gif) 9 | 10 | ### Arrow Refresh indicator (Same as original SwipeRefreshLayout) 11 | ![Arrow refresh indicator](assets/arrow_refresh_indicator.gif) 12 | 13 | ### Pull from bottom 14 | ![Arrow refresh indicator](assets/pull_from_bottom.gif) 15 | 16 | ## Usage 17 | 18 | ### Change Refresh drawable style 19 | 20 | ```java 21 | SwipeRefreshLayout layout = (SwipeRefreshLayout) findViewById(/* Resource id */); 22 | 23 | // Circle (which is default) 24 | layout.setRefreshDrawableStyle(SwipeRefreshLayout.CIRCLE); 25 | 26 | // Or with arrow (which is default in original SwipeRefreshLayout in Support Library) 27 | layout.setRefreshDrawableStyle(SwipeRefreshLayout.ARROW); 28 | ``` 29 | 30 | ### Change Pull position 31 | 32 | ```java 33 | SwipeRefreshLayout layout = (SwipeRefreshLayout) findViewById(/* Resource id */); 34 | 35 | // Pull from bottom 36 | layout.setPullPosition(Gravity.BOTTOM); 37 | 38 | // Or from top, which is default 39 | layout.setPullPosition(Gravity.TOP); 40 | ``` 41 | 42 | ## Download 43 | 44 | ### Stable 45 | 46 | Core: 47 | ```groovy 48 | compile 'com.androidhuman.circlerefreshlayout:circlerefreshlayout:0.1.0' 49 | ``` 50 | 51 | RxBinding support: 52 | ```groovy 53 | compile 'com.androidhuman.circlerefreshlayout:circlerefreshlayout-rxbinding:0.1.0' 54 | ``` 55 | 56 | ### Development Snapshot 57 | Snapshots of the development version are available in [Sonatype's `snapshots` repository](https://oss.sonatype.org/content/repositories/snapshots/). 58 | 59 | Core: 60 | ```groovy 61 | compile 'com.androidhuman.circlerefreshlayout:circlerefreshlayout:0.1.0-SNAPSHOT' 62 | ``` 63 | 64 | RxBinding support: 65 | ```groovy 66 | compile 'com.androidhuman.circlerefreshlayout:circlerefreshlayout-rxbinding:0.1.0-SNAPSHOT' 67 | ``` 68 | 69 | ## License 70 | 71 | ``` 72 | Copyright 2016 Taeho Kim 73 | 74 | Licensed under the Apache License, Version 2.0 (the "License"); 75 | you may not use this file except in compliance with the License. 76 | You may obtain a copy of the License at 77 | 78 | http://www.apache.org/licenses/LICENSE-2.0 79 | 80 | Unless required by applicable law or agreed to in writing, software 81 | distributed under the License is distributed on an "AS IS" BASIS, 82 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 83 | See the License for the specific language governing permissions and 84 | limitations under the License. 85 | ``` 86 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | #Releasing 2 | 3 | 1. Change the version in `gradle.properties` to a non-SNAPSHOT version. 4 | 2. Update the `CHANGELOG.md` for the impending release. 5 | 3. Update the `README.md` with the new version. 6 | 4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) 7 | 5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) 8 | 6. `./gradlew clean uploadArchives` 9 | 7. Update the `gradle.properties` to the next SNAPSHOT version. 10 | 8. `git commit -am "Prepare next development version."` 11 | 9. `git push && git push --tags` 12 | 10. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact. -------------------------------------------------------------------------------- /assets/arrow_refresh_indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunny/android-CircleRefreshLayout/698c2a75a3a129ca9c27dc5416147206f9478cef/assets/arrow_refresh_indicator.gif -------------------------------------------------------------------------------- /assets/circle_refresh_indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunny/android-CircleRefreshLayout/698c2a75a3a129ca9c27dc5416147206f9478cef/assets/circle_refresh_indicator.gif -------------------------------------------------------------------------------- /assets/pull_from_bottom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kunny/android-CircleRefreshLayout/698c2a75a3a129ca9c27dc5416147206f9478cef/assets/pull_from_bottom.gif -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | 20 | apply plugin: 'checkstyle' 21 | 22 | checkstyle { 23 | toolVersion = "6.6" 24 | configFile = new File(rootProject.rootDir, 'config/checkstyle/checkstyle.xml') 25 | configProperties.checkStyleConfigDir = rootProject.file('config/checkstyle') 26 | } 27 | 28 | task('checkstyle', type: Checkstyle) { 29 | group = "Verification" 30 | description = "Runs checkstyle task." 31 | 32 | source 'src' 33 | ignoreFailures false 34 | showViolations true 35 | include '**/*.java' 36 | exclude '**/gen/**' 37 | exclude '**/**Test.java' 38 | exclude '**/test/**' 39 | 40 | classpath = files() 41 | } 42 | 43 | afterEvaluate { 44 | if (tasks.findByName('check')) { 45 | check.dependsOn('checkstyle') 46 | } 47 | } 48 | } 49 | 50 | task clean(type: Delete) { 51 | delete rootProject.buildDir 52 | } 53 | 54 | apply from: file('dependencies.gradle') 55 | -------------------------------------------------------------------------------- /circlerefreshlayout-rxbinding/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | buildToolsVersion rootProject.ext.buildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.minSdkVersion 9 | targetSdkVersion rootProject.ext.targetSdkVersion 10 | } 11 | 12 | compileOptions { 13 | sourceCompatibility JavaVersion.VERSION_1_7 14 | targetCompatibility JavaVersion.VERSION_1_7 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | compile project(':circlerefreshlayout') 27 | 28 | compile rootProject.ext.rxAndroid 29 | compile rootProject.ext.rxJava 30 | 31 | testCompile rootProject.ext.junit4 32 | } 33 | 34 | apply from: rootProject.file('gradle/gradle-mvn-push.gradle') 35 | -------------------------------------------------------------------------------- /circlerefreshlayout-rxbinding/gradle.properties: -------------------------------------------------------------------------------- 1 | VERSION_NAME=0.1.0-SNAPSHOT 2 | VERSION_CODE=1 3 | GROUP=com.androidhuman.circlerefreshlayout 4 | 5 | POM_NAME=android-CircleRefreshLayout-rxbinding 6 | POM_DESCRIPTION=RxJava binding APIs for CircleRefreshLayout. 7 | POM_ARTIFACT_ID=circlerefreshlayout-rxbinding 8 | POM_PACKAGING=aar 9 | POM_URL=https://github.com/kunny/android-CircleRefreshLayout 10 | POM_SCM_URL=https://github.com/kunny/android-CircleRefreshLayout 11 | POM_SCM_CONNECTION=scm:git@github.com:kunny/android-CircleRefreshLayout.git 12 | POM_SCM_DEV_CONNECTION=scm:git@github.com:kunny/android-CircleRefreshLayout.git 13 | POM_LICENCE_NAME=The Apache Software License, Version 2.0 14 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt 15 | POM_LICENCE_DIST=repo 16 | POM_DEVELOPER_ID=kunny 17 | POM_DEVELOPER_NAME=Taeho Kim 18 | POM_DEVELOPER_EMAIL=jyte82@gmail.com -------------------------------------------------------------------------------- /circlerefreshlayout-rxbinding/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /circlerefreshlayout-rxbinding/src/main/java/com/androidhuman/circlerefreshlayout/rxbinding/RxSwipeRefreshLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Taeho Kim 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 | package com.androidhuman.circlerefreshlayout.rxbinding; 18 | 19 | import com.androidhuman.circlerefreshlayout.SwipeRefreshLayout; 20 | 21 | import android.support.annotation.CheckResult; 22 | import android.support.annotation.NonNull; 23 | 24 | import rx.Observable; 25 | import rx.functions.Action1; 26 | 27 | public final class RxSwipeRefreshLayout { 28 | 29 | /** 30 | * Create an observable of refresh events on {@code view}. 31 | *

32 | * Warning: The created observable keeps a strong reference to {@code view}. 33 | * Unsubscribe to free this reference. 34 | */ 35 | @CheckResult 36 | @NonNull 37 | public static Observable refreshes(@NonNull SwipeRefreshLayout view) { 38 | checkNotNull(view, "view == null"); 39 | return Observable.create(new SwipeRefreshLayoutRefreshOnSubscribe(view)); 40 | } 41 | 42 | /** 43 | * An action which sets whether the layout is showing the refreshing indicator. 44 | *

45 | * Warning: The created observable keeps a strong reference to {@code view}. 46 | * Unsubscribe to free this reference. 47 | */ 48 | @CheckResult @NonNull 49 | public static Action1 refreshing(@NonNull final SwipeRefreshLayout view) { 50 | checkNotNull(view, "view == null"); 51 | return new Action1() { 52 | @Override public void call(Boolean value) { 53 | view.setRefreshing(value); 54 | } 55 | }; 56 | } 57 | 58 | private static T checkNotNull(T value, String message) { 59 | if (value == null) { 60 | throw new NullPointerException(message); 61 | } 62 | return value; 63 | } 64 | 65 | private RxSwipeRefreshLayout() { 66 | throw new AssertionError("No instances."); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /circlerefreshlayout-rxbinding/src/main/java/com/androidhuman/circlerefreshlayout/rxbinding/SwipeRefreshLayoutRefreshOnSubscribe.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Taeho Kim 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 | package com.androidhuman.circlerefreshlayout.rxbinding; 18 | 19 | import com.androidhuman.circlerefreshlayout.SwipeRefreshLayout; 20 | 21 | import rx.Observable; 22 | import rx.Subscriber; 23 | import rx.android.MainThreadSubscription; 24 | 25 | import static rx.android.MainThreadSubscription.verifyMainThread; 26 | 27 | final class SwipeRefreshLayoutRefreshOnSubscribe implements Observable.OnSubscribe { 28 | 29 | final SwipeRefreshLayout view; 30 | 31 | SwipeRefreshLayoutRefreshOnSubscribe(SwipeRefreshLayout view) { 32 | this.view = view; 33 | } 34 | 35 | @Override 36 | public void call(final Subscriber subscriber) { 37 | verifyMainThread(); 38 | 39 | SwipeRefreshLayout.OnRefreshListener listener = new SwipeRefreshLayout.OnRefreshListener() { 40 | @Override 41 | public void onRefresh() { 42 | subscriber.onNext(null); 43 | } 44 | }; 45 | view.setOnRefreshListener(listener); 46 | 47 | subscriber.add(new MainThreadSubscription() { 48 | @Override 49 | protected void onUnsubscribe() { 50 | view.setOnRefreshListener(null); 51 | } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion rootProject.ext.compileSdkVersion 5 | buildToolsVersion rootProject.ext.buildToolsVersion 6 | 7 | defaultConfig { 8 | applicationId "com.androidhuman.circlerefreshlayout.sample" 9 | minSdkVersion rootProject.ext.minSdkVersion 10 | targetSdkVersion rootProject.ext.targetSdkVersion 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | lintOptions { 21 | abortOnError false 22 | } 23 | } 24 | 25 | dependencies { 26 | compile project(':circlerefreshlayout') 27 | 28 | compile rootProject.ext.appcompat 29 | compile rootProject.ext.recyclerview 30 | } 31 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/src/main/java/com/androidhuman/circlerefreshlayout/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidhuman.circlerefreshlayout.sample; 2 | 3 | import com.androidhuman.circlerefreshlayout.SwipeRefreshLayout; 4 | 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.Gravity; 10 | import android.view.View; 11 | import android.widget.Button; 12 | 13 | public class MainActivity extends AppCompatActivity { 14 | 15 | Button btnCircleRefreshIndicator; 16 | 17 | Button btnArrowRefreshIndicator; 18 | 19 | Button btnPullFromBottom; 20 | 21 | Button btnWithWebViewTop; 22 | 23 | Button btnWithWebViewBottom; 24 | 25 | @Override 26 | protected void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_main); 29 | 30 | btnCircleRefreshIndicator = (Button) findViewById( 31 | R.id.btn_activity_main_circle_refresh_indicator); 32 | 33 | btnArrowRefreshIndicator = (Button) findViewById( 34 | R.id.btn_activity_main_arrow_refresh_indicator); 35 | 36 | btnPullFromBottom = (Button) findViewById( 37 | R.id.btn_activity_main_pull_from_bottom); 38 | 39 | btnWithWebViewTop = (Button) findViewById( 40 | R.id.btn_activity_main_webview_top); 41 | 42 | btnWithWebViewBottom = (Button) findViewById( 43 | R.id.btn_activity_main_webview_bottom); 44 | 45 | btnCircleRefreshIndicator.setOnClickListener(new View.OnClickListener() { 46 | @Override 47 | public void onClick(View v) { 48 | startActivity(new Intent(MainActivity.this, RefreshLayoutActivity.class) 49 | .putExtra(RefreshLayoutActivity.KEY_REFRESH_DRAWABLE_STYLE, 50 | SwipeRefreshLayout.CIRCLE) 51 | .putExtra(RefreshLayoutActivity.KEY_TITLE, "Circle Refresh indicator")); 52 | } 53 | }); 54 | 55 | btnArrowRefreshIndicator.setOnClickListener(new View.OnClickListener() { 56 | @Override 57 | public void onClick(View v) { 58 | startActivity(new Intent(MainActivity.this, RefreshLayoutActivity.class) 59 | .putExtra(RefreshLayoutActivity.KEY_REFRESH_DRAWABLE_STYLE, 60 | SwipeRefreshLayout.ARROW) 61 | .putExtra(RefreshLayoutActivity.KEY_TITLE, "Arrow Refresh indicator")); 62 | } 63 | }); 64 | 65 | btnPullFromBottom.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | startActivity(new Intent(MainActivity.this, RefreshLayoutActivity.class) 69 | .putExtra(RefreshLayoutActivity.KEY_PULL_POSITION, Gravity.BOTTOM) 70 | .putExtra(RefreshLayoutActivity.KEY_TITLE, "Pull from bottom")); 71 | } 72 | }); 73 | 74 | btnWithWebViewTop.setOnClickListener(new View.OnClickListener() { 75 | @Override 76 | public void onClick(View v) { 77 | startActivity(new Intent(MainActivity.this, WebViewActivity.class) 78 | .putExtra(WebViewActivity.KEY_PULL_POSITION, Gravity.TOP)); 79 | } 80 | }); 81 | 82 | btnWithWebViewBottom.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | startActivity(new Intent(MainActivity.this, WebViewActivity.class) 86 | .putExtra(WebViewActivity.KEY_PULL_POSITION, Gravity.BOTTOM)); 87 | } 88 | }); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/src/main/java/com/androidhuman/circlerefreshlayout/sample/RefreshLayoutActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidhuman.circlerefreshlayout.sample; 2 | 3 | import com.androidhuman.circlerefreshlayout.SwipeRefreshLayout; 4 | 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.view.Gravity; 11 | import android.view.LayoutInflater; 12 | import android.view.ViewGroup; 13 | import android.widget.TextView; 14 | import android.widget.Toast; 15 | 16 | public class RefreshLayoutActivity extends AppCompatActivity 17 | implements SwipeRefreshLayout.OnRefreshListener { 18 | 19 | public static final String KEY_TITLE = "title"; 20 | 21 | public static final String KEY_REFRESH_DRAWABLE_STYLE = "refresh_drawable_style"; 22 | 23 | public static final String KEY_PULL_POSITION = "pull_position"; 24 | 25 | SwipeRefreshLayout swlRefresh; 26 | 27 | RecyclerView rlList; 28 | 29 | @Override 30 | protected void onCreate(@Nullable Bundle savedInstanceState) { 31 | super.onCreate(savedInstanceState); 32 | setContentView(R.layout.activity_refreshlayout); 33 | 34 | String title = getIntent().getStringExtra(KEY_TITLE); 35 | if (null != title) { 36 | setTitle(title); 37 | } 38 | 39 | swlRefresh = (SwipeRefreshLayout) findViewById(R.id.srl_activity_refreshlayout_refresh); 40 | rlList = (RecyclerView) findViewById(R.id.rv_list); 41 | 42 | setupSwipeRefreshLayout(swlRefresh, getIntent().getExtras()); 43 | 44 | rlList.setLayoutManager(new LinearLayoutManager(this)); 45 | rlList.setAdapter(new ItemAdapter()); 46 | } 47 | 48 | private void setupSwipeRefreshLayout(SwipeRefreshLayout view, @Nullable Bundle extras) { 49 | view.setColorSchemeResources(R.color.colorAccent); 50 | view.setOnRefreshListener(this); 51 | 52 | if (null == extras) { 53 | return; 54 | } 55 | 56 | @SwipeRefreshLayout.RefreshDrawableStyle 57 | int style = extras.getInt(KEY_REFRESH_DRAWABLE_STYLE, SwipeRefreshLayout.CIRCLE); 58 | view.setRefreshDrawableStyle(style); 59 | 60 | @SwipeRefreshLayout.PullPosition 61 | int position = extras.getInt(KEY_PULL_POSITION, Gravity.TOP); 62 | view.setPullPosition(position); 63 | } 64 | 65 | @Override 66 | public void onRefresh() { 67 | Toast.makeText(getApplicationContext(), "Refreshing...", Toast.LENGTH_SHORT).show(); 68 | } 69 | 70 | class ItemAdapter extends RecyclerView.Adapter { 71 | 72 | @Override 73 | public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) { 74 | return new ItemHolder(parent); 75 | } 76 | 77 | @Override 78 | public void onBindViewHolder(ItemHolder holder, int position) { 79 | holder.text.setText("Item " + position); 80 | } 81 | 82 | @Override 83 | public int getItemCount() { 84 | return 30; 85 | } 86 | } 87 | 88 | class ItemHolder extends RecyclerView.ViewHolder { 89 | 90 | public TextView text; 91 | 92 | public ItemHolder(ViewGroup parent) { 93 | super(LayoutInflater.from(parent.getContext()) 94 | .inflate(R.layout.item_simple, parent, false)); 95 | text = (TextView) itemView.findViewById(R.id.tv_item_simple); 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/src/main/java/com/androidhuman/circlerefreshlayout/sample/WebViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.androidhuman.circlerefreshlayout.sample; 2 | 3 | import com.androidhuman.circlerefreshlayout.SwipeRefreshLayout; 4 | 5 | import android.graphics.Bitmap; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.text.TextUtils; 10 | import android.view.Gravity; 11 | import android.webkit.WebView; 12 | import android.webkit.WebViewClient; 13 | 14 | public class WebViewActivity extends AppCompatActivity 15 | implements SwipeRefreshLayout.OnRefreshListener { 16 | 17 | public static final String KEY_PULL_POSITION = "pull_position"; 18 | 19 | SwipeRefreshLayout srlRefresh; 20 | 21 | WebView wvWebView; 22 | 23 | @Override 24 | protected void onCreate(@Nullable Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_webview); 27 | 28 | srlRefresh = (SwipeRefreshLayout) findViewById(R.id.srl_activity_webview_refresh); 29 | srlRefresh.setOnRefreshListener(this); 30 | 31 | @SwipeRefreshLayout.PullPosition 32 | int pullPosition = getIntent().getIntExtra(KEY_PULL_POSITION, Gravity.TOP); 33 | srlRefresh.setPullPosition(pullPosition); 34 | 35 | wvWebView = (WebView) findViewById(R.id.wv_activity_webview); 36 | wvWebView.getSettings().setJavaScriptEnabled(true); 37 | wvWebView.setWebViewClient(new WebViewClient() { 38 | @Override 39 | public void onPageStarted(WebView view, String url, Bitmap favicon) { 40 | setTitle("Loading..."); 41 | } 42 | 43 | @Override 44 | public void onPageFinished(WebView view, String url) { 45 | String pageTitle = view.getTitle(); 46 | if (!TextUtils.isEmpty(pageTitle)) { 47 | setTitle(pageTitle); 48 | } 49 | if (srlRefresh.isRefreshing()) { 50 | srlRefresh.setRefreshing(false); 51 | } 52 | } 53 | }); 54 | wvWebView.loadUrl("http://d.android.com"); 55 | } 56 | 57 | @Override 58 | public void onBackPressed() { 59 | if (wvWebView.canGoBack()) { 60 | wvWebView.goBack(); 61 | } else { 62 | super.onBackPressed(); 63 | } 64 | } 65 | 66 | @Override 67 | public void onRefresh() { 68 | wvWebView.reload(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /circlerefreshlayout-sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 |