├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── BeautifulRefreshLayout.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cjj
│ │ └── beautifulrefreshlayout
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cjj
│ │ └── beautifulrefreshlayout
│ │ ├── MainActivity.java
│ │ ├── MainApplication.java
│ │ └── SampleListFragment.java
│ └── res
│ ├── drawable-hdpi
│ ├── bb.jpg
│ ├── cc.jpg
│ ├── ic_dashboard.png
│ ├── ic_discuss.png
│ ├── ic_done.png
│ ├── ic_event.png
│ ├── ic_forum.png
│ ├── ic_headset.png
│ └── ic_menu.png
│ ├── layout
│ ├── activity_main.xml
│ ├── fragment_list.xml
│ ├── fragment_test.xml
│ ├── include_list_viewpager.xml
│ ├── list_item.xml
│ └── nav_header.xml
│ ├── menu
│ ├── drawer_view.xml
│ └── menu_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v19
│ └── theme.xml
│ ├── values-v21
│ └── theme.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ ├── styles.xml
│ └── theme.xml
├── beautifulrefreshlibrary
├── .gitignore
├── beautifulrefreshlibrary.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── cjj
│ │ └── refresh
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cjj
│ │ └── refresh
│ │ ├── BeautifulRefreshLayout.java
│ │ ├── DensityUtil.java
│ │ ├── PullToRefreshListener.java
│ │ ├── PullWaveListener.java
│ │ ├── Rain.java
│ │ ├── RainView.java
│ │ ├── RefreshLayout.java
│ │ ├── RippleView.java
│ │ ├── RoundDotView.java
│ │ ├── RoundProgressView.java
│ │ └── WaveView.java
│ └── res
│ ├── drawable
│ └── gg.jpg
│ ├── layout
│ └── view_head.xml
│ └── values
│ ├── colors.xml
│ └── strings.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | BeautifulRefreshLayout
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/BeautifulRefreshLayout.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | BeautifulRefreshLayout
2 | =========================================
3 |
4 | [](http://www.android-arsenal.com/details/1/2488)
5 | GitHub小伙伴交流群'' 477826523,很难进的哦!
6 |
7 | 众多优秀的下拉刷新(除了我写的之外T_T)
8 | -----------------------------------------------------------------------------------------------------------------------------
9 | 说起下拉刷新,好像经历一段历史的洗礼。。。
10 |
11 | (1)在我刚学android的时候,用的是XListView,在github上搜索有[MarkMjw/PullToRefresh](https://github.com/MarkMjw/PullToRefresh),根据Maxwin的XListView改造而来,完善下拉刷新上拉加载更多的功能并实现自动刷新以及自动加载等功能, 并增加对ScrollView的支持。 原XListView参考链接:https://github.com/Maxwin-z/XListView-Android(听说原作者停止维护了)
12 | 
13 |
14 | (2)然后又学了[chrisbanes/Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh)的那个库,这个库牛逼到要死,支持ListView、ExpandableListView、GridView、WebView、ScrollView、HorizontalScrollView、ViewPager、ListFragment、、、
15 |
16 | 
17 |
18 | 自己也侮辱了这个库,改的乱七八糟[https://github.com/android-cjj/ComicReader/tree/master/YinHunPulltoRefreshLibrary](https://github.com/android-cjj/ComicReader/tree/master/YinHunPulltoRefreshLibrary),增加了支持瀑布流刷新的功能和下拉动画效果的。。。。
19 |
20 | 
21 |
22 | (3)那时候看了知乎的客户端,下拉刷新很炫,查了下是用什么实现的,最终知道是用[chrisbanes/ActionBar-PullToRefresh](https://github.com/chrisbanes/ActionBar-PullToRefresh)的库可以实现那种效果,又去学了,啊哈哈,然而过些日子也没见人用了,啊哈哈哈
23 |
24 | 
25 |
26 | (4)这时候google也有自己的下拉控件SwipeRefreshLayout,刚出来的效果,一条加载直线,个人觉得,一般到要死。[stormzhang/SwipeRefreshLayoutDemo](https://github.com/stormzhang/SwipeRefreshLayoutDemo)写了demo。
27 |
28 | 
29 |
30 | android 5.0之后效果是个加载圆圈,还可以接受了,现在很多应用都用这个
31 |
32 | 
33 |
34 | (5)这时又看到了[baoyongzhang/android-PullRefreshLayout](https://github.com/baoyongzhang/android-PullRefreshLayout),This component like SwipeRefreshLayout, it is more beautiful than SwipeRefreshLayout.就是比google的跟漂亮。呵呵!
35 |
36 | 
37 |
38 | (6)同时,这里也要提下[liaohuqiu/android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh),已经强大到什么控件都能适用刷新了,相信你也听过了
39 |
40 | 
41 |
42 | (7)看过最有创意的下拉刷新[FlyRefresh](https://github.com/race604/FlyRefresh),一只飞机飞啊飞,然而并没有什么卵用.....
43 |
44 | 
45 |
46 | (8)material设计已经深入到开发者的心里,然后 我看到了A pull-down-to-refresh layout inspired by Lollipop overscrolled effects
47 | [allan1st/JellyRefreshLayout](https://github.com/allan1st/JellyRefreshLayout),我这个也是看人家的代码实现的,十分感谢,啊哈哈
48 |
49 | 
50 |
51 | (9)最近看的下拉刷新也是挺奇怪的,就比如[recruit-lifestyle/BeerSwipeRefresh](https://github.com/recruit-lifestyle/BeerSwipeRefresh)啤酒下拉刷新和[recruit-lifestyle/WaveSwipeRefreshLayout](https://github.com/recruit-lifestyle/WaveSwipeRefreshLayout)水滴下拉刷新...
52 |
53 | 
54 | 
55 |
56 | (10)这个是网友推荐的[SuperSwipeRefreshLayout](https://github.com/nuptboyzhb/SuperSwipeRefreshLayout),顾名思义,是扩展自SwipeRefreshLayout。
57 | 
58 |
59 | (11)这个是Yalantis公司开发的下拉刷新,其中它的很多东西动画这块,做的非常漂亮[Yalantis/Phoenix](https://github.com/Yalantis/Phoenix)
60 | 
61 |
62 | [Taurus](https://github.com/Yalantis/Taurus)又是飞机飞啊飞...
63 | 
64 |
65 | (12)[tuesda/CircleRefreshLayout](https://github.com/tuesda/CircleRefreshLayout)的下拉刷新,动画做的很不错,设计图来源[https://dribbble.com/shots/1797373-Pull-Down-To-Refresh](https://dribbble.com/shots/1797373-Pull-Down-To-Refresh)
66 |
67 | 
68 |
69 | (13)[BeautifulRefreshLayoutForFood](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForFood)
70 |
71 | 看到一个很漂亮的美食下拉刷新[(来源地址)](https://dribbble.com/shots/2096383-Pull-To-Refresh-V2?list=users&offset=1) ,可惜技术水平菜菜的,只能模仿一下下,啊哈哈。。。[源码下载地址download](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForFood)
72 |
73 | 
74 |
75 | (14)[BeautifulRefreshLayoutForNaruto](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForNaruto)
76 |
77 | 闲着蛋疼,写了个血轮眼下拉刷新的,虽然火影漫画完结了,但是动画还在继续,真的是挂漫天飞。。。。[(源码下载地址download)](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForNaruto)
78 |
79 | 
80 |
81 | (15)[bingoogolapple/BGARefreshLayout-Android](https://github.com/bingoogolapple/BGARefreshLayout-Android)多种下拉刷新效果、上拉加载更多、可配置自定义头部广告位...
82 |
83 | 
84 |
85 |
86 | (16)[BeautifulRefreshLayoutForGirl](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForGirl)
87 |
88 | 这是一个小清新的下拉刷新,纯代码绘制,无需任何图片,Recyclerview中item展示的妹子图来自[http://gank.io/](http://gank.io/)
89 |
90 | 设计图来源,当然我实现的效果做了一些修改,希望你喜欢,呵呵。。。[源码下载地址download](https://github.com/android-cjj/BeautifulRefreshLayout/tree/BeautifulRefreshForGirl)
91 | [pull to refresh by Michael Lanning](https://dribbble.com/shots/1936194-Pull-To-Refresh)
92 | 截图
93 | -------------------------------------------------------------------------------------------------------
94 | 
95 |
96 | (17)[BeautifulRefreshLayoutForRain](https://github.com/android-cjj/BeautifulRefreshLayout)
97 |
98 | 这是一个下雨刷新,你没听错,确实一刷新就下雨,为什么会出现,只是我的好奇心而做的东西,见怪不怪了,呵呵。。。
99 |
100 | 
101 |
102 | (18)[Android-MaterialRefreshLayout](https://github.com/android-cjj/Android-MaterialRefreshLayout)是我最近写的, it is more beautiful and powerful than SwipeRefreshLayout , 下拉刷新拥有侵入式,非侵入式,覆盖式,非覆盖式,自动刷新,上拉加载更多,自动加载等功能......
103 |
104 | 
105 |
106 | (19)[WaveRefreshForAndroid](https://github.com/alienjun/WaveRefreshForAndroid)这个是基于[Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh)修改的而成的水波纹下拉刷新...可能作者主攻ios,所以ios的效果看起来好看点[WaveRefresh](https://github.com/alienjun/WaveRefresh)...
107 |
108 | 
109 |
110 | (20)[WaterDropListView](https://github.com/THEONE10211024/WaterDropListView)如果你用过ios的qq,那应该很熟悉这种刷新了,效果还是蛮不错的,就是不知道为什么android版本的qq不用,呵呵。。。
111 |
112 | 
113 |
114 | (21)[SwipeRefreshRecyclerView](https://github.com/liangzhitao/SwipeRefreshRecyclerView)
115 | 一个展示 RecyclerView 下拉刷新和上拉加载更多的 Demo
116 | 完全使用原生控件实现非侵入式的下拉刷新和加载更多。
117 | 同时也是 Ailurus 练习 RxJava 的小例子。
118 | 使用HeaderViewRecyclerAdapter完成了加载更多的进度展示
119 |
120 | 
121 |
122 | (22)阿拉灯神灯写的两个下拉库[AutoHomeRefreshListView](https://github.com/nugongshou110/AutoHomeRefreshListView)仿汽车之家下拉刷新和[MeiTuanRefreshListView](https://github.com/nugongshou110/MeiTuanRefreshListView)仿美团下拉刷新。。。
123 |
124 | 
125 | 
126 |
127 | (23)[XRecyclerView](https://github.com/jianghejie/XRecyclerView)a RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView
128 |
129 | 
130 |
131 | (24)[ChromeLikeSwipeLayout](https://github.com/ashqal/ChromeLikeSwipeLayout)这个效果蛮赞的,细节做的很好。。。。Pull down, and execute more action!
132 |
133 | 
134 |
135 | (25)下拉玩消格子游戏[HitBlockRefresh](https://github.com/Hitomis/HitBlockRefresh), 一边下拉刷新,一边打砖块.
136 |
137 | 
138 |
139 | * 温馨提示:如需RecyclerView加载更多,请参考:[https://github.com/android-cjj/Android-RecyclerViewWithFooter](https://github.com/android-cjj/Android-RecyclerViewWithFooter)
140 |
141 |
142 |
143 |
144 |
145 | 写在最后
146 | =================================================================================
147 | 这个仓库我会一直维护,有时间也会写一些比较有意思的下拉刷新,只是技术有限,不要吐槽给建议就好,呵呵。。。同时,也希望你们能介绍一些比较好的下拉刷新的库给我,让更多人知道有这个东西,大家一起交流学习,一起进步。欢迎随时关注,记得star哦,呵呵!
148 | If you want to support me,you can follow me on Github:
149 | [https://github.com/android-cjj](https://github.com/android-cjj).
150 |
151 | 随意说说
152 | -----------------------------
153 | 刚建了个[github小伙伴交流群](http://t.cn/RyiVjnv)(477826523),有兴趣的朋友可以加进来的...小小要求:github有至少7个关注者或者开源库有7颗星星的...
154 |
155 | ****************************转载请注明出处,不然我咬你哦!************************
156 |
157 | [about me](http://android-cjj.github.io/)
158 | ------------------------------------
159 |
160 | License
161 | =======
162 |
163 | The MIT License (MIT)
164 |
165 | Copyright (c) 2015 android-cjj
166 |
167 | Permission is hereby granted, free of charge, to any person obtaining a copy
168 | of this software and associated documentation files (the "Software"), to deal
169 | in the Software without restriction, including without limitation the rights
170 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
171 | copies of the Software, and to permit persons to whom the Software is
172 | furnished to do so, subject to the following conditions:
173 |
174 | The above copyright notice and this permission notice shall be included in all
175 | copies or substantial portions of the Software.
176 |
177 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
178 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
179 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
180 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
181 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
182 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
183 | SOFTWARE.
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.cjj.beautifulrefreshlayout"
9 | minSdkVersion 14
10 | targetSdkVersion 22
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 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.2.0'
25 | compile 'com.android.support:design:22.2.0'
26 | compile project(':beautifulrefreshlibrary')
27 | compile 'com.android.support:recyclerview-v7:22.2.0'
28 | compile 'com.android.support:cardview-v7:22.2.0'
29 | }
30 |
--------------------------------------------------------------------------------
/app/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 D:\as\sdk-install/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 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/cjj/beautifulrefreshlayout/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cjj.beautifulrefreshlayout;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cjj/beautifulrefreshlayout/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.cjj.beautifulrefreshlayout;
2 |
3 | import android.net.Uri;
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.design.widget.NavigationView;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.design.widget.TabLayout;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v4.app.FragmentManager;
11 | import android.support.v4.app.FragmentPagerAdapter;
12 | import android.support.v4.view.ViewPager;
13 | import android.support.v4.widget.DrawerLayout;
14 | import android.support.v7.app.ActionBar;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.support.v7.widget.Toolbar;
17 | import android.view.Menu;
18 | import android.view.MenuItem;
19 | import android.view.View;
20 |
21 | import com.facebook.drawee.backends.pipeline.Fresco;
22 | import com.facebook.drawee.interfaces.DraweeController;
23 | import com.facebook.drawee.view.SimpleDraweeView;
24 | import com.facebook.imagepipeline.request.ImageRequest;
25 | import com.facebook.imagepipeline.request.ImageRequestBuilder;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | public class MainActivity extends AppCompatActivity {
31 | private DrawerLayout mDrawerLayout;
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 |
36 | setContentView(R.layout.activity_main);
37 |
38 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
39 | setSupportActionBar(toolbar);
40 |
41 | final ActionBar ab = getSupportActionBar();
42 | ab.setHomeAsUpIndicator(R.drawable.ic_menu);
43 | ab.setDisplayHomeAsUpEnabled(true);
44 | ab.setTitle(null);
45 |
46 | mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
47 |
48 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
49 | if (navigationView != null) {
50 | setupDrawerContent(navigationView);
51 | }
52 |
53 | ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
54 | if (viewPager != null) {
55 | setupViewPager(viewPager);
56 | }
57 |
58 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
59 | fab.setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View view) {
62 | Snackbar.make(view, "I'm CJJ", Snackbar.LENGTH_LONG)
63 | .setAction("Action", null).show();
64 | }
65 | });
66 |
67 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
68 | tabLayout.setupWithViewPager(viewPager);
69 |
70 | }
71 |
72 | @Override
73 | public boolean onCreateOptionsMenu(Menu menu) {
74 | // Inflate the menu; this adds items to the action bar if it is present.
75 | getMenuInflater().inflate(R.menu.menu_main, menu);
76 | return true;
77 | }
78 |
79 | @Override
80 | public boolean onOptionsItemSelected(MenuItem item) {
81 | // Handle action bar item clicks here. The action bar will
82 | // automatically handle clicks on the Home/Up button, so long
83 | // as you specify a parent activity in AndroidManifest.xml.
84 | int id = item.getItemId();
85 |
86 | //noinspection SimplifiableIfStatement
87 | if (id == R.id.action_settings) {
88 | return true;
89 | }
90 |
91 | return super.onOptionsItemSelected(item);
92 | }
93 |
94 | private void setupViewPager(ViewPager viewPager) {
95 | Adapter adapter = new Adapter(getSupportFragmentManager());
96 | adapter.addFragment(new SampleListFragment(), "鸣人");
97 | adapter.addFragment(new SampleListFragment(), "佐助");
98 | adapter.addFragment(new SampleListFragment(), "小樱");
99 | viewPager.setAdapter(adapter);
100 | }
101 |
102 | private void setupDrawerContent(NavigationView navigationView) {
103 | navigationView.setNavigationItemSelectedListener(
104 | new NavigationView.OnNavigationItemSelectedListener() {
105 | @Override
106 | public boolean onNavigationItemSelected(MenuItem menuItem) {
107 | menuItem.setChecked(true);
108 | mDrawerLayout.closeDrawers();
109 | return true;
110 | }
111 | });
112 | }
113 |
114 | static class Adapter extends FragmentPagerAdapter {
115 | private final List mFragments = new ArrayList<>();
116 | private final List mFragmentTitles = new ArrayList<>();
117 |
118 | public Adapter(FragmentManager fm) {
119 | super(fm);
120 | }
121 |
122 | public void addFragment(Fragment fragment, String title) {
123 | mFragments.add(fragment);
124 | mFragmentTitles.add(title);
125 | }
126 |
127 | @Override
128 | public Fragment getItem(int position) {
129 | return mFragments.get(position);
130 | }
131 |
132 | @Override
133 | public int getCount() {
134 | return mFragments.size();
135 | }
136 |
137 | @Override
138 | public CharSequence getPageTitle(int position) {
139 | return mFragmentTitles.get(position);
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cjj/beautifulrefreshlayout/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.cjj.beautifulrefreshlayout;
2 |
3 | import android.app.Application;
4 |
5 | import com.facebook.drawee.backends.pipeline.Fresco;
6 |
7 | /**
8 | * Created by Administrator on 2015/8/6.
9 | */
10 | public class MainApplication extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 |
16 | Fresco.initialize(this);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/cjj/beautifulrefreshlayout/SampleListFragment.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2015 The Android Open Source Project
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.cjj.beautifulrefreshlayout;
18 |
19 | import android.content.Context;
20 | import android.os.Bundle;
21 | import android.support.annotation.Nullable;
22 | import android.support.v4.app.Fragment;
23 | import android.support.v7.widget.DefaultItemAnimator;
24 | import android.support.v7.widget.LinearLayoutManager;
25 | import android.support.v7.widget.RecyclerView;
26 | import android.view.LayoutInflater;
27 | import android.view.View;
28 | import android.view.ViewGroup;
29 | import android.widget.ImageView;
30 |
31 |
32 | import com.cjj.refresh.BeautifulRefreshLayout;
33 |
34 | import java.util.ArrayList;
35 | import java.util.List;
36 | import java.util.Random;
37 |
38 | public class SampleListFragment extends Fragment {
39 |
40 | @Nullable
41 | @Override
42 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
43 | View v = inflater.inflate(
44 | R.layout.fragment_list, container, false);
45 | BeautifulRefreshLayout beautifulRefreshLayout = (BeautifulRefreshLayout) v.findViewById(R.id.refresh);
46 | beautifulRefreshLayout.setBuautifulRefreshListener(new BeautifulRefreshLayout.BuautifulRefreshListener() {
47 | @Override
48 | public void onRefresh(final BeautifulRefreshLayout refreshLayout) {
49 | // refreshLayout.postDelayed(new Runnable() {
50 | // @Override
51 | // public void run() {
52 | // refreshLayout.finishRefreshing();
53 | // }
54 | // }, 3000);
55 | //
56 | refreshLayout.post(new Runnable() {
57 | @Override
58 | public void run() {
59 | refreshLayout.finishRefreshing();
60 | }
61 | });
62 |
63 | }
64 | });
65 |
66 |
67 | RecyclerView rv = (RecyclerView) v.findViewById(R.id.recyclerview);
68 | setupRecyclerView(rv);
69 | return v;
70 | }
71 |
72 | private void setupRecyclerView(RecyclerView recyclerView) {
73 | recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
74 | recyclerView.setAdapter(new SimpleStringRecyclerViewAdapter(getActivity()));
75 | recyclerView.setItemAnimator(new DefaultItemAnimator());
76 | }
77 |
78 | private List getRandomSublist(String[] array, int amount) {
79 | ArrayList list = new ArrayList<>(amount);
80 | Random random = new Random();
81 | while (list.size() < amount) {
82 | list.add(array[random.nextInt(array.length)]);
83 | }
84 | return list;
85 | }
86 |
87 | public static class SimpleStringRecyclerViewAdapter
88 | extends RecyclerView.Adapter {
89 |
90 |
91 | public static class ViewHolder extends RecyclerView.ViewHolder {
92 |
93 | public final ImageView mImageView;
94 |
95 | public ViewHolder(View view) {
96 | super(view);
97 | mImageView = (ImageView) view.findViewById(R.id.avatar);
98 | }
99 |
100 |
101 | }
102 |
103 | public SimpleStringRecyclerViewAdapter(Context context) {
104 | super();
105 | }
106 |
107 | @Override
108 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
109 | View view = LayoutInflater.from(parent.getContext())
110 | .inflate(R.layout.list_item, parent, false);
111 | return new ViewHolder(view);
112 | }
113 |
114 | @Override
115 | public void onBindViewHolder(final ViewHolder holder, int position) {
116 | if(position==0)
117 | {
118 | holder.mImageView.setImageResource(R.drawable.bb);
119 | }else if(position == 1)
120 | {
121 | holder.mImageView.setImageResource(R.drawable.cc);
122 | }
123 |
124 | }
125 |
126 | @Override
127 | public int getItemCount() {
128 | return 4;
129 | }
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/bb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/bb.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/cc.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/cc.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_dashboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_dashboard.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_discuss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_discuss.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_done.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_event.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_event.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_forum.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_forum.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_headset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_headset.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/drawable-hdpi/ic_menu.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
23 |
24 |
25 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_list.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
23 |
24 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/include_list_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
29 |
30 |
38 |
39 |
40 |
41 |
42 |
47 |
48 |
49 |
50 |
55 |
56 |
63 |
64 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
23 |
24 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/drawer_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
50 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v19/theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #e1e1e1
4 | #673AB7
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BeautifulRefresh
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
9 |
10 |
16 |
17 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values/theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/beautifulrefreshlibrary.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 22
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 22
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | compile 'com.android.support:appcompat-v7:22.2.0'
24 | compile 'com.facebook.fresco:fresco:0.6.0'
25 | }
26 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/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 D:\as\sdk-install/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 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/androidTest/java/com/cjj/refresh/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/BeautifulRefreshLayout.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.util.AttributeSet;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.animation.AccelerateInterpolator;
10 | import android.view.animation.Animation;
11 | import android.view.animation.BounceInterpolator;
12 | import android.view.animation.OvershootInterpolator;
13 | import android.view.animation.TranslateAnimation;
14 | import android.widget.ImageView;
15 | import android.widget.TextView;
16 |
17 | import com.facebook.drawee.backends.pipeline.Fresco;
18 | import com.facebook.drawee.interfaces.DraweeController;
19 | import com.facebook.drawee.view.SimpleDraweeView;
20 | import com.facebook.imagepipeline.request.ImageRequest;
21 | import com.facebook.imagepipeline.request.ImageRequestBuilder;
22 | import com.nineoldandroids.animation.Animator;
23 | import com.nineoldandroids.animation.AnimatorListenerAdapter;
24 | import com.nineoldandroids.animation.ObjectAnimator;
25 | import com.nineoldandroids.animation.ValueAnimator;
26 |
27 |
28 | /**
29 | * Created by cjj on 2015/8/4.
30 | */
31 | public class BeautifulRefreshLayout extends RefreshLayout {
32 | private float waveHeight = 200;
33 | private float headHeight = 120;
34 |
35 | public BeautifulRefreshLayout(Context context) {
36 | this(context, null, 0);
37 | }
38 |
39 | public BeautifulRefreshLayout(Context context, AttributeSet attrs) {
40 | this(context, attrs, 0);
41 | }
42 |
43 | public BeautifulRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
44 | super(context, attrs, defStyleAttr);
45 | init(attrs);
46 | }
47 |
48 | /**
49 | * 初始化
50 | */
51 | private void init(AttributeSet attrs) {
52 | /**
53 | * attrs 需要在xml设置什么属性 自己自定义吧 啊哈哈
54 | */
55 |
56 | /**
57 | * 初始化headView
58 | */
59 | final View headView = LayoutInflater.from(getContext()).inflate(R.layout.view_head, null);
60 | final WaveView waveView = (WaveView) headView.findViewById(R.id.draweeView);
61 | final TextView tv_tip = (TextView) headView.findViewById(R.id.tv_tip);
62 | final RippleView rippleView = (RippleView) headView.findViewById(R.id.ripple);
63 | final RainView rain = (RainView) headView.findViewById(R.id.rain);
64 | rain.setVisibility(View.GONE);
65 | rippleView.setRippleListener(new RippleView.RippleListener() {
66 | @Override
67 | public void onRippleFinish() {
68 | if(listener!=null)
69 | {
70 | listener.onRefresh(BeautifulRefreshLayout.this);
71 | }
72 | }
73 | });
74 | /**
75 | * 设置波浪的高度
76 | */
77 | setWaveHeight(DensityUtil.dip2px(getContext(), waveHeight));
78 | /**
79 | * 设置headView的高度
80 | */
81 | setHeaderHeight(DensityUtil.dip2px(getContext(), headHeight));
82 | /**
83 | * 设置headView
84 | */
85 | setHeaderView(headView);
86 | /**
87 | * 监听波浪变化监听
88 | */
89 | setPullWaveListener(new PullWaveListener() {
90 | @Override
91 | public void onPulling(RefreshLayout refreshLayout, float fraction) {
92 | float headW = DensityUtil.dip2px(getContext(), waveHeight);
93 | waveView.setHeadHeight((int) (DensityUtil.dip2px(getContext(), headHeight) * limitValue(1, fraction)));
94 | waveView.setWaveHeight((int) (headW * Math.max(0, fraction - 1)));
95 |
96 | waveView.invalidate();
97 |
98 | if(DensityUtil.dip2px(getContext(), headHeight)> (int) (DensityUtil.dip2px(getContext(), headHeight) * limitValue(1, fraction)))
99 | {
100 | tv_tip.setText("下拉下雨");
101 | }else
102 | {
103 | tv_tip.setText("松开下雨");
104 | }
105 |
106 |
107 |
108 | }
109 |
110 | @Override
111 | public void onPullReleasing(RefreshLayout refreshLayout, float fraction) {
112 | if (!refreshLayout.isRefreshing) {
113 |
114 | }
115 | }
116 | });
117 |
118 | /**
119 | * 松开后的监听
120 | */
121 | setPullToRefreshListener(new PullToRefreshListener() {
122 | @Override
123 | public void onRefresh(RefreshLayout refreshLayout) {
124 | tv_tip.setText("下雨中...");
125 | rain.setVisibility(View.VISIBLE);
126 | rain.StartRain();
127 | waveView.setHeadHeight((int) (DensityUtil.dip2px(getContext(), headHeight)));
128 | ValueAnimator animator = ValueAnimator.ofInt(waveView.getWaveHeight(), 0,-300,0,-100,0);
129 | animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
130 | @Override
131 | public void onAnimationUpdate(ValueAnimator animation) {
132 | Log.i("anim", "value--->" + (int) animation.getAnimatedValue());
133 | waveView.setWaveHeight((int) animation.getAnimatedValue());
134 | waveView.invalidate();
135 |
136 | }
137 | });
138 | animator.setInterpolator(new BounceInterpolator());
139 | animator.setDuration(1000);
140 | animator.start();
141 |
142 |
143 | refreshLayout.postDelayed(
144 | new Runnable() {
145 | @Override
146 | public void run() {
147 | rippleView.startReveal();
148 | rain.stopRain();
149 | }
150 | }, 3000
151 | );
152 | }
153 | });
154 | }
155 |
156 |
157 | public void shakeAnim(View view)
158 | {
159 | ObjectAnimator animator = ObjectAnimator.ofFloat(view,"rotation",0,2,0,-2,0);
160 | animator.setDuration(100);
161 | animator.setRepeatCount(-1);
162 | animator.setRepeatMode(ValueAnimator.RESTART);
163 | animator.start();
164 | }
165 |
166 |
167 | /**
168 | * 限定值
169 | * @param a
170 | * @param b
171 | * @return
172 | */
173 | public float limitValue(float a, float b) {
174 | float valve = 0;
175 | final float min = Math.min(a, b);
176 | final float max = Math.max(a, b);
177 | valve = valve > min ? valve : min;
178 | valve = valve < max ? valve : max;
179 | return valve;
180 | }
181 |
182 | public interface BuautifulRefreshListener {
183 | void onRefresh(BeautifulRefreshLayout refreshLayout);
184 | }
185 |
186 | private BuautifulRefreshListener listener;
187 | public void setBuautifulRefreshListener(BuautifulRefreshListener listener)
188 | {
189 | this.listener = listener;
190 | }
191 | }
192 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | import android.content.Context;
4 |
5 | public class DensityUtil {
6 |
7 | /**
8 | * 根据手机的分辨率从 dp 的单位 转成为 px(像素)
9 | */
10 | public static int dip2px(Context context, float dpValue) {
11 | final float scale = context.getResources().getDisplayMetrics().density;
12 | return (int) (dpValue * scale + 0.5f);
13 | }
14 |
15 | /**
16 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
17 | */
18 | public static int px2dip(Context context, float pxValue) {
19 | final float scale = context.getResources().getDisplayMetrics().density;
20 | return (int) (pxValue / scale + 0.5f);
21 | }
22 | }
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/PullToRefreshListener.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | /**
4 | * Created by cjj on 2015/8/4.
5 | * 刷新回调接口
6 | */
7 | public interface PullToRefreshListener {
8 | /**
9 | * 刷新中。。。
10 | * @param refreshLayout
11 | */
12 | void onRefresh(RefreshLayout refreshLayout);
13 | }
14 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/PullWaveListener.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | /**
4 | * Created by cjj on 2015/8/4.
5 | * wave回调监听
6 | */
7 | public interface PullWaveListener {
8 | /**
9 | * 下拉中
10 | * @param refreshLayout
11 | * @param fraction
12 | */
13 | void onPulling(RefreshLayout refreshLayout, float fraction);
14 |
15 | /**
16 | * 下拉松开
17 | * @param refreshLayout
18 | * @param fraction
19 | */
20 | void onPullReleasing(RefreshLayout refreshLayout, float fraction);
21 | }
22 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/Rain.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | import android.graphics.Paint;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Administrator on 2015/8/31.
10 | */
11 | public class Rain implements Cloneable {
12 | private Paint paint;
13 | private float speedY;
14 | private float speedX;
15 | private float x;
16 | private float y;
17 | private float w;
18 | private float pos;
19 |
20 | public Paint getPaint() {
21 | return paint;
22 | }
23 |
24 | public void setPaint(Paint paint) {
25 | this.paint = paint;
26 | }
27 |
28 | public float getW() {
29 | return w;
30 | }
31 |
32 | public void setW(float w) {
33 | this.w = w;
34 | }
35 |
36 | public float getX() {
37 | return x;
38 | }
39 |
40 | public void setX(float x) {
41 | this.x = x;
42 | }
43 |
44 | public float getY() {
45 | return y;
46 | }
47 |
48 | public void setY(float y) {
49 | this.y = y;
50 | }
51 |
52 | public float getSpeedY() {
53 | return speedY;
54 | }
55 |
56 | public void setSpeedY(float speedY) {
57 | this.speedY = speedY;
58 | }
59 |
60 | public float getSpeedX() {
61 | return speedX;
62 | }
63 |
64 | public void setSpeedX(float speedX) {
65 | this.speedX = speedX;
66 | }
67 |
68 | public float getPos() {
69 | return pos;
70 | }
71 |
72 | public void setPos(float pos) {
73 | this.pos = pos;
74 | }
75 |
76 | @Override
77 | protected Rain clone() throws CloneNotSupportedException {
78 | Rain rain = null;
79 | try {
80 | rain = (Rain) super.clone();
81 | } catch (CloneNotSupportedException e) {
82 | e.printStackTrace();
83 | }
84 | return rain;
85 | }
86 | public List clone(int number){
87 | List clones = null;
88 | Rain clone;
89 | try {
90 | clones = new ArrayList<>();
91 | for(int i=0;i mRains;
21 | private Random mRandom = new Random();
22 |
23 | private float mStartY = -20;
24 | double mGradient = 8 * Math.PI / 180;
25 | float mSpeedY = 25;
26 | float mRainWidth = 3;
27 | float mRainLength = 15;
28 | private volatile boolean mIsStop = false;
29 |
30 | private volatile Thread mThread;
31 | private List mCopyRains;
32 |
33 | public RainView(Context context) {
34 | this(context, null);
35 | }
36 |
37 | public RainView(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 |
40 | mRains = new ArrayList<>();
41 | mCopyRains = new ArrayList<>();
42 | }
43 |
44 | public void StartRain()
45 | {
46 | mIsStop = false;
47 | mThread = new Thread(new Runnable() {
48 | @Override
49 | public void run() {
50 | while (!mIsStop) {
51 | Paint paint = new Paint();
52 | for (int i = 0; i < mRandom.nextInt() * 50 + 100; i++) {
53 | Rain rain = new Rain();
54 | rain.setW(mRainWidth);
55 | rain.setSpeedY(mSpeedY);
56 | // Paint paint = new Paint();
57 | paint.reset();
58 | paint.setColor(0Xffffff);
59 | paint.setAlpha(90);
60 | paint.setStrokeWidth((float) Math.random() * (mRainWidth - 1) + 1);
61 | rain.setPaint(paint);
62 | int x = mRandom.nextInt(getMeasuredWidth() + 1);
63 | rain.setX(x);
64 | rain.setY(mStartY);
65 | float speedX = (float) (Math.tan(mGradient) * mSpeedY);
66 | rain.setSpeedX(speedX);
67 | mRains.add(rain);
68 | }
69 | postInvalidate();
70 | try {
71 | Thread.sleep(30);
72 | } catch (InterruptedException e) {
73 | e.printStackTrace();
74 | }
75 | }
76 | }
77 | });
78 | mThread.start();
79 | }
80 |
81 |
82 | public void stopRain() {
83 | mIsStop = true;
84 | mThread = null;
85 | mRains.clear();
86 | invalidate();
87 | }
88 |
89 | @Override
90 | protected void onAttachedToWindow() {
91 | super.onAttachedToWindow();
92 | }
93 |
94 | @Override
95 | protected void onDetachedFromWindow() {
96 | super.onDetachedFromWindow();
97 | }
98 |
99 | @Override
100 | protected void onDraw(Canvas canvas) {
101 | super.onDraw(canvas);
102 | if(mRains == null || mRains.size() <= 0) {
103 | return;
104 | }
105 |
106 | mCopyRains.clear();
107 | mCopyRains.addAll(mRains);
108 | for(Rain rain : mCopyRains) {
109 | if(rain == null) return;
110 |
111 | if (rain.getX() <= 0) {
112 | mRains.remove(rain);
113 | } else if (rain.getX() >= getWidth()) {
114 | mRains.remove(rain);
115 | } else if(rain.getY() > mStartY + getHeight()) {
116 | mRains.remove(rain);
117 | }
118 |
119 | rain.setX(rain.getX() + rain.getSpeedX());
120 | rain.setY(rain.getY() + rain.getSpeedY());
121 | Rain nextRain = RainNext(rain, mRainLength);
122 | canvas.drawLine(rain.getX(), rain.getY(), nextRain.getX(), nextRain.getY(), rain.getPaint());
123 | // Log.d("cjj", "for..." + rain.getX() + " y" + rain.getY() + " nx+" + nextRain.getX() + " ny" + nextRain.getY());
124 | }
125 |
126 | }
127 |
128 | private Rain RainNext(Rain bubble, float length) {
129 | Rain next = new Rain();
130 | next.setX((float) (bubble.getX() + length * Math.sin(mGradient)));
131 | next.setY((float) (bubble.getY() + length * Math.cos(mGradient)));
132 | return next;
133 | }
134 | }
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/RefreshLayout.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 | import android.animation.ObjectAnimator;
4 | import android.animation.ValueAnimator;
5 | import android.annotation.TargetApi;
6 | import android.content.Context;
7 | import android.os.Build;
8 | import android.support.v4.view.ViewCompat;
9 | import android.util.AttributeSet;
10 | import android.util.Log;
11 | import android.view.Gravity;
12 | import android.view.MotionEvent;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.animation.DecelerateInterpolator;
16 | import android.widget.AbsListView;
17 | import android.widget.FrameLayout;
18 |
19 | /**
20 | * Created by cjj on 2015/8/4.
21 | */
22 | public class RefreshLayout extends FrameLayout {
23 | //波浪的高度
24 | protected float mWaveHeight;
25 |
26 | //头部的高度
27 | protected float mHeadHeight;
28 |
29 | //子控件
30 | private View mChildView;
31 |
32 | //头部layout
33 | protected FrameLayout mHeadLayout;
34 |
35 | //刷新的状态
36 | protected boolean isRefreshing;
37 |
38 | //触摸获得Y的位置
39 | private float mTouchY;
40 |
41 | //当前Y的位置
42 | private float mCurrentY;
43 |
44 | //动画的变化率
45 | private DecelerateInterpolator decelerateInterpolator;
46 |
47 |
48 | public RefreshLayout(Context context) {
49 | this(context, null, 0);
50 | }
51 |
52 | public RefreshLayout(Context context, AttributeSet attrs) {
53 | this(context, attrs, 0);
54 | }
55 |
56 | public RefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
57 | super(context, attrs, defStyleAttr);
58 | init();
59 | Log.i("cjj", "init");
60 | }
61 |
62 | /**
63 | * 初始化
64 | */
65 | private void init() {
66 | //使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
67 | if (isInEditMode()) {
68 | return;
69 | }
70 |
71 | if (getChildCount() > 1) {
72 | throw new RuntimeException("只能拥有一个子控件哦");
73 | }
74 |
75 | //在动画开始的地方快然后慢;
76 | decelerateInterpolator = new DecelerateInterpolator(10);
77 | }
78 |
79 |
80 | @TargetApi(Build.VERSION_CODES.KITKAT)
81 | @Override
82 | protected void onAttachedToWindow() {
83 | super.onAttachedToWindow();
84 | Log.i("cjj", "onAttachedToWindow");
85 |
86 | //添加头部
87 | FrameLayout headViewLayout = new FrameLayout(getContext());
88 | LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
89 | layoutParams.gravity = Gravity.TOP;
90 | headViewLayout.setLayoutParams(layoutParams);
91 |
92 | mHeadLayout = headViewLayout;
93 |
94 | this.addView(mHeadLayout);
95 |
96 |
97 | //获得子控件
98 | mChildView = getChildAt(0);
99 |
100 | // if (mChildView == null) {
101 | // return;
102 | // }
103 | // mChildView.animate().setInterpolator(new DecelerateInterpolator());//设置速率为递减
104 | // mChildView.animate().setUpdateListener(//通过addUpdateListener()方法来添加一个动画的监听器
105 | // new ValueAnimator.AnimatorUpdateListener() {
106 | // @Override
107 | // public void onAnimationUpdate(ValueAnimator animation) {
108 | // int height = (int) mChildView.getTranslationY();//获得mChildView当前y的位置
109 | //
110 | // Log.i("cjj", "mChildView.getTranslationY----------->" + height);
111 | // mHeadLayout.getLayoutParams().height = height;
112 | // mHeadLayout.requestLayout();//重绘
113 | //
114 | // if (pullWaveListener != null) {
115 | // pullWaveListener.onPullReleasing(RefreshLayout.this, height / mHeadHeight);
116 | // }
117 | // }
118 | // }
119 | // );
120 |
121 | }
122 |
123 | //由于animate().setUpdateListener必须在API 19以上才能使用,故使用ObjectAnimator代替
124 | private void setChildViewTransLationY(float... values){
125 | ObjectAnimator oa = ObjectAnimator.ofFloat(mChildView, View.TRANSLATION_Y, values);
126 | oa.setInterpolator(new DecelerateInterpolator());
127 | oa.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
128 | @Override
129 | public void onAnimationUpdate(ValueAnimator animation) {
130 | int height = (int) mChildView.getTranslationY();//获得mChildView当前y的位置
131 |
132 | Log.i("cjj", "mChildView.getTranslationY----------->" + height);
133 | mHeadLayout.getLayoutParams().height = height;
134 | mHeadLayout.requestLayout();//重绘
135 |
136 | if (pullWaveListener != null) {
137 | pullWaveListener.onPullReleasing(RefreshLayout.this, height / mHeadHeight);
138 | }
139 | }
140 | });
141 | oa.start();
142 | }
143 |
144 |
145 | /**
146 | * 拦截事件
147 | * @param ev
148 | * @return
149 | */
150 | @Override
151 | public boolean onInterceptTouchEvent(MotionEvent ev) {
152 | if(isRefreshing) return true;
153 |
154 | switch (ev.getAction()) {
155 | case MotionEvent.ACTION_DOWN:
156 | mTouchY = ev.getY();
157 | mCurrentY = mTouchY;
158 | break;
159 | case MotionEvent.ACTION_MOVE:
160 | float currentY = ev.getY();
161 | float dy = currentY - mTouchY;
162 | if (dy > 0 && !canChildScrollUp()) {
163 | return true;
164 | }
165 | break;
166 | }
167 | return super.onInterceptTouchEvent(ev);
168 | }
169 |
170 | /**
171 | * 响应事件
172 | * @param e
173 | * @return
174 | */
175 | @Override
176 | public boolean onTouchEvent(MotionEvent e) {
177 | if (isRefreshing) {
178 | return super.onTouchEvent(e);
179 | }
180 |
181 | switch (e.getAction()) {
182 | case MotionEvent.ACTION_MOVE:
183 | mCurrentY = e.getY();
184 |
185 | float dy = mCurrentY - mTouchY;
186 | dy = Math.min(mWaveHeight * 2, dy);
187 | dy = Math.max(0, dy);
188 |
189 | if (mChildView != null) {
190 | float offsetY = decelerateInterpolator.getInterpolation(dy / mWaveHeight / 2) * dy / 2;
191 | mChildView.setTranslationY(offsetY);
192 |
193 | mHeadLayout.getLayoutParams().height = (int) offsetY;
194 | mHeadLayout.requestLayout();
195 |
196 | if (pullWaveListener != null) {
197 | pullWaveListener.onPulling(RefreshLayout.this, offsetY / mHeadHeight);
198 | }
199 | }
200 | return true;
201 | case MotionEvent.ACTION_CANCEL:
202 | case MotionEvent.ACTION_UP:
203 | if (mChildView != null) {
204 | if (mChildView.getTranslationY() >= mHeadHeight) {
205 | // mChildView.animate().translationY(mHeadHeight).start();
206 | setChildViewTransLationY(mHeadHeight);
207 | isRefreshing = true;
208 | if (pullToRefreshPullingListener != null) {
209 | pullToRefreshPullingListener.onRefresh(RefreshLayout.this);
210 | }
211 | } else {
212 | // mChildView.animate().translationY(0).start();
213 | setChildViewTransLationY(0);
214 | }
215 |
216 | }
217 | return true;
218 | }
219 | return super.onTouchEvent(e);
220 | }
221 |
222 | /**
223 | * 用来判断是否可以上拉
224 | * @return boolean
225 | */
226 | public boolean canChildScrollUp() {
227 | if (mChildView == null) {
228 | return false;
229 | }
230 | if (Build.VERSION.SDK_INT < 14) {
231 | if (mChildView instanceof AbsListView) {
232 | final AbsListView absListView = (AbsListView) mChildView;
233 | return absListView.getChildCount() > 0
234 | && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
235 | .getTop() < absListView.getPaddingTop());
236 | } else {
237 | return ViewCompat.canScrollVertically(mChildView, -1) || mChildView.getScrollY() > 0;
238 | }
239 | } else {
240 | return ViewCompat.canScrollVertically(mChildView, -1);
241 | }
242 | }
243 |
244 | /**
245 | * 设置下拉监听
246 | */
247 | private PullToRefreshListener pullToRefreshPullingListener;
248 | public void setPullToRefreshListener(PullToRefreshListener pullToRefreshPullingListener)
249 | {
250 | this.pullToRefreshPullingListener = pullToRefreshPullingListener;
251 | }
252 |
253 | /**
254 | * 设置wave监听
255 | */
256 | private PullWaveListener pullWaveListener;
257 | public void setPullWaveListener(PullWaveListener pullWaveListener)
258 | {
259 | this.pullWaveListener = pullWaveListener;
260 | }
261 |
262 | /**
263 | * 刷新结束
264 | */
265 | public void finishRefreshing() {
266 | if (mChildView != null) {
267 | // mChildView.animate().translationY(0).start();
268 | setChildViewTransLationY(0);
269 | }
270 | isRefreshing = false;
271 | }
272 |
273 | /**
274 | * 设置头部View
275 | * @param headerView
276 | */
277 | public void setHeaderView(final View headerView) {
278 | post(new Runnable() {
279 | @Override
280 | public void run() {
281 | mHeadLayout.addView(headerView);
282 | }
283 | });
284 | }
285 |
286 | /**
287 | * 设置wave的下拉高度
288 | * @param waveHeight
289 | */
290 | public void setWaveHeight(float waveHeight) {
291 | this.mWaveHeight = waveHeight;
292 | }
293 |
294 | /**
295 | * 设置下拉头的高度
296 | * @param headHeight
297 | */
298 | public void setHeaderHeight(float headHeight) {
299 | this.mHeadHeight = headHeight;
300 | }
301 | }
302 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/java/com/cjj/refresh/RippleView.java:
--------------------------------------------------------------------------------
1 | package com.cjj.refresh;
2 |
3 |
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | /**
12 | * cjj
13 | */
14 | public class RippleView extends View {
15 | private Paint mPaint;
16 | private int r;
17 | private RippleListener listener;
18 |
19 | public int getR() {
20 | return r;
21 | }
22 | public void setR(int r) {
23 | this.r = r;
24 | }
25 | public RippleView(Context context) {
26 | this(context, null, 0);
27 | }
28 |
29 | public RippleView(Context context, AttributeSet attrs) {
30 | this(context, attrs, 0);
31 | }
32 |
33 | public RippleView(Context context, AttributeSet attrs, int defStyleAttr) {
34 | super(context, attrs, defStyleAttr);
35 | init();
36 | }
37 |
38 | private void init() {
39 | mPaint = new Paint();
40 | mPaint.setAntiAlias(true);
41 | mPaint.setColor(Color.WHITE);
42 | mPaint.setAlpha(155);
43 | mPaint.setStyle(Paint.Style.FILL);
44 | }
45 |
46 | public void startReveal() {
47 | new Thread(new Runnable() {
48 | @Override
49 | public void run() {
50 | int bigRadius = (int) (Math.sqrt(Math.pow(getHeight(), 2)+ Math.pow(getWidth(), 2)));
51 | while (r"+getMeasuredWidth());
75 | Log.i("cjj","getMeasuredHeight---->"+getMeasuredHeight());
76 | Log.i("cjj","bitmapDis.getWidth()---->"+bitmapDis.getWidth());
77 | Log.i("cjj","bitmapDis.getHeight()---->"+bitmapDis.getHeight());
78 | canvas.drawBitmap(bitmapDis,rectF1,rectF,paint);
79 | //重置画笔
80 | path.reset();
81 | path.lineTo(0, headHeight);
82 | //绘制贝塞尔曲线
83 | path.quadTo(getMeasuredWidth() / 2, headHeight + waveHeight, getMeasuredWidth(), headHeight);
84 | path.lineTo(getMeasuredWidth(), 0);
85 | canvas.drawPath(path, paint);
86 | }
87 |
88 |
89 | static Bitmap drawableToBitmap(Drawable drawable) // drawable 转换成bitmap
90 | {
91 | int width = drawable.getIntrinsicWidth();// 取drawable的长宽
92 | int height = drawable.getIntrinsicHeight();
93 | Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;// 取drawable的颜色格式
94 | Bitmap bitmap = Bitmap.createBitmap(width, height, config);// 建立对应bitmap
95 | Canvas canvas = new Canvas(bitmap);// 建立对应bitmap的画布
96 | drawable.setBounds(0, 0, width, height);
97 | drawable.draw(canvas);// 把drawable内容画到画布中
98 | return bitmap;
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/res/drawable/gg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/beautifulrefreshlibrary/src/main/res/drawable/gg.jpg
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/res/layout/view_head.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
24 |
25 |
26 |
30 |
31 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF5722
4 |
--------------------------------------------------------------------------------
/beautifulrefreshlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BeautifulRefreshLibrary
3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue magna felis, ac maximus velit fringilla non. Curabitur eleifend velit risus. Donec tincidunt arcu id enim faucibus, ac maximus neque fringilla. In egestas sed ipsum et commodo. Duis tincidunt sollicitudin libero eget semper. Ut fermentum quam id ipsum dictum, eu pulvinar nunc maximus. Praesent erat tellus, finibus vel nulla accumsan, condimentum fermentum ligula. Nullam finibus posuere porttitor. In dui dolor, gravida ac nisi sit amet, rutrum fringilla ex. Curabitur eu lorem sed magna dignissim egestas. Duis viverra dui quis mauris auctor, sed feugiat arcu aliquet. Maecenas feugiat ac odio ac finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nunc ultricies placerat ante, id semper sem convallis et. Praesent finibus maximus elementum. Phasellus sed malesuada massa. Etiam eleifend diam maximus, ultricies enim et, congue ligula. Vestibulum at accumsan diam, vitae vehicula tellus. Curabitur ut nibh commodo, condimentum enim id, semper nisi. Aenean at eleifend diam. Ut consectetur eleifend urna ut euismod. Proin convallis gravida ligula id placerat. Aenean facilisis magna ut odio eleifend dictum. Suspendisse faucibus, ipsum eu varius cursus, orci ante luctus turpis, eget egestas justo augue id orci. Donec tincidunt laoreet neque. Vivamus pharetra erat orci, non rhoncus nunc placerat at. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse potenti. Vivamus accumsan metus ut finibus blandit. Quisque aliquet quam in tempus auctor. Suspendisse nibh tortor, dapibus vel quam accumsan, gravida ornare velit. Ut ut nunc pulvinar, pharetra ipsum quis, aliquet turpis. Nam eu massa lacus. Pellentesque quis tortor ipsum. Ut condimentum, purus sit amet maximus efficitur, ex sem lacinia quam, eget convallis dui leo a dui. Mauris posuere purus mauris, quis tristique diam hendrerit ut. Praesent tempus purus sed risus aliquet ultrices. Cras vitae maximus metus, quis convallis eros. Cras dignissim nisl ut magna efficitur convallis. In faucibus leo quis sollicitudin feugiat. Proin nec dui justo. Fusce in porta quam. Morbi ac tincidunt sem. Donec venenatis suscipit nulla, ut porta nibh tincidunt tincidunt. Curabitur et aliquet arcu, ut pharetra neque. Nam sagittis rutrum ante ut ultrices. Sed placerat felis vitae mauris ornare interdum. Cras non dolor convallis, tempus odio quis, finibus tortor. Nunc placerat sit amet lacus in ornare. Maecenas ultricies augue in magna placerat posuere. Interdum et malesuada fames ac ante ipsum primis in faucibus. Suspendisse venenatis nisl et velit venenatis tempus. Sed sed urna at turpis dictum fringilla volutpat ac erat. Cras efficitur orci tincidunt, rhoncus ante at, interdum est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur dapibus est a nulla porttitor, sed scelerisque nunc facilisis. Proin tempus, mauris et condimentum maximus, mi risus tempor nisi, non posuere justo libero vel arcu. Praesent commodo feugiat orci ac volutpat. Nullam vulputate pulvinar mauris id pellentesque.
4 |
5 |
6 |
--------------------------------------------------------------------------------
/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:1.2.3'
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 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/android-cjj/BeautifulRefreshLayout/2c089a3cdde5bc94df80406c2a4b61d0fec9a1a1/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Aug 04 10:34:46 CST 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.4-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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':beautifulrefreshlibrary'
2 |
--------------------------------------------------------------------------------