├── .gitignore ├── AutoHome ├── .gitignore ├── autohome_header_demo.gif ├── build.gradle ├── picture │ ├── loopview_picture1.jpg │ ├── loopview_picture2.jpg │ ├── loopview_picture3.jpg │ └── loopview_picture4.jpg ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kevin │ │ └── pulltorefresh │ │ └── autohome │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── loopview.json │ ├── java │ │ └── com │ │ │ └── kevin │ │ │ └── pulltorefresh │ │ │ └── autohome │ │ │ ├── LocalFileUtils.java │ │ │ ├── MainActivity.java │ │ │ └── loadinglayout │ │ │ └── AutoHomeHeaderLayout.java │ └── res │ │ ├── anim │ │ └── pointer_rotate.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── autohome_header_loadinglayout.xml │ │ └── recycler_header.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── load_icon_dial.png │ │ └── load_icon_pointer.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kevin │ └── pulltorefresh │ └── autohome │ └── ExampleUnitTest.java ├── JingDong ├── .gitignore ├── build.gradle ├── jingdong_header_demo.gif ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kevin │ │ └── pulltorefresh │ │ └── jingdong │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kevin │ │ │ └── pulltorefresh │ │ │ └── jingdong │ │ │ ├── MainActivity.java │ │ │ └── loadinglayout │ │ │ └── JingDongHeaderLayout.java │ └── res │ │ ├── drawable │ │ └── refreshing_anim.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── jingdong_header_loadinglayout.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── app_refresh_goods_0.png │ │ ├── app_refresh_people_0.png │ │ ├── app_refresh_people_1.png │ │ ├── app_refresh_people_2.png │ │ ├── app_refresh_people_3.png │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kevin │ └── pulltorefresh │ └── jingdong │ └── ExampleUnitTest.java ├── MeiTuan ├── .gitignore ├── build.gradle ├── meituan_header_demo.gif ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── kevin │ │ └── pulltorefresh │ │ └── meituan │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── kevin │ │ │ └── pulltorefresh │ │ │ └── meituan │ │ │ ├── MainActivity.java │ │ │ └── loadinglayout │ │ │ └── MeiTuanHeaderLayout.java │ └── res │ │ ├── drawable │ │ ├── pull_to_refresh_second_anim.xml │ │ └── pull_to_refresh_third_anim.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── meituan_header_loadinglayout.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── meituan_picture1.jpg │ │ └── meituan_picture2.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── pull_end_image_frame_01.png │ │ ├── pull_end_image_frame_02.png │ │ ├── pull_end_image_frame_03.png │ │ ├── pull_end_image_frame_04.png │ │ ├── pull_end_image_frame_05.png │ │ ├── pull_image.png │ │ ├── refreshing_image_frame_01.png │ │ ├── refreshing_image_frame_02.png │ │ ├── refreshing_image_frame_03.png │ │ ├── refreshing_image_frame_04.png │ │ ├── refreshing_image_frame_05.png │ │ ├── refreshing_image_frame_06.png │ │ ├── refreshing_image_frame_07.png │ │ └── refreshing_image_frame_08.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── kevin │ └── pulltorefresh │ └── meituan │ └── ExampleUnitTest.java ├── README-zh.md ├── README.md ├── Tmall ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── src │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── kevin │ │ │ └── pulltorefresh │ │ │ └── tmall │ │ │ └── ApplicationTest.java │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── kevin │ │ │ │ └── pulltorefresh │ │ │ │ └── tmall │ │ │ │ ├── MainActivity.java │ │ │ │ └── loadinglayout │ │ │ │ ├── TmallFooterLayout.java │ │ │ │ └── TmallHeaderLayout.java │ │ └── res │ │ │ ├── drawable │ │ │ ├── refreshing_footer_anim.xml │ │ │ └── refreshing_header_anim.xml │ │ │ ├── layout │ │ │ ├── activity_main.xml │ │ │ ├── layout_recycler_item.xml │ │ │ ├── tmall_footer_loadinglayout.xml │ │ │ └── tmall_header_loadinglayout.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ ├── tm_mui_bike_0.png │ │ │ ├── tm_mui_bike_1.png │ │ │ ├── tm_mui_bike_2.png │ │ │ ├── tm_mui_bike_3.png │ │ │ ├── tm_mui_bike_4.png │ │ │ ├── tm_mui_bike_5.png │ │ │ ├── tm_mui_bike_6.png │ │ │ └── tm_mui_bike_7.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── tm_load_cat_end.png │ │ │ ├── tm_load_cat_fail.png │ │ │ ├── tm_load_cat_full.png │ │ │ ├── tm_loading_cat_1.png │ │ │ ├── tm_loading_cat_10.png │ │ │ ├── tm_loading_cat_11.png │ │ │ ├── tm_loading_cat_12.png │ │ │ ├── tm_loading_cat_13.png │ │ │ ├── tm_loading_cat_14.png │ │ │ ├── tm_loading_cat_15.png │ │ │ ├── tm_loading_cat_16.png │ │ │ ├── tm_loading_cat_17.png │ │ │ ├── tm_loading_cat_18.png │ │ │ ├── tm_loading_cat_19.png │ │ │ ├── tm_loading_cat_2.png │ │ │ ├── tm_loading_cat_20.png │ │ │ ├── tm_loading_cat_3.png │ │ │ ├── tm_loading_cat_4.png │ │ │ ├── tm_loading_cat_5.png │ │ │ ├── tm_loading_cat_6.png │ │ │ ├── tm_loading_cat_7.png │ │ │ ├── tm_loading_cat_8.png │ │ │ └── tm_loading_cat_9.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ ├── tm_picture0.png │ │ │ ├── tm_picture1.png │ │ │ ├── tm_recycler0.png │ │ │ ├── tm_recycler1.png │ │ │ ├── tm_recycler2.png │ │ │ ├── tm_recycler3.png │ │ │ ├── tm_recycler4.png │ │ │ └── tm_recycler5.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ └── test │ │ └── java │ │ └── com │ │ └── kevin │ │ └── pulltorefresh │ │ └── tmall │ │ └── ExampleUnitTest.java └── tmall_demo.gif ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | 10 | /.idea 11 | /MeiTuan/build 12 | /AutoHome/build 13 | /Tmall/build -------------------------------------------------------------------------------- /AutoHome/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /AutoHome/autohome_header_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/autohome_header_demo.gif -------------------------------------------------------------------------------- /AutoHome/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.kevin.pulltorefresh.autohome" 9 | minSdkVersion 11 10 | targetSdkVersion 23 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 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile 'com.nineoldandroids:library:2.4.0' 27 | compile 'com.kevin:pulltorefresh:1.0.7' 28 | compile 'com.kevin:loopview:1.0.4' 29 | compile 'com.kevin:wraprecyclerview:1.0.1' 30 | } -------------------------------------------------------------------------------- /AutoHome/picture/loopview_picture1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/picture/loopview_picture1.jpg -------------------------------------------------------------------------------- /AutoHome/picture/loopview_picture2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/picture/loopview_picture2.jpg -------------------------------------------------------------------------------- /AutoHome/picture/loopview_picture3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/picture/loopview_picture3.jpg -------------------------------------------------------------------------------- /AutoHome/picture/loopview_picture4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/picture/loopview_picture4.jpg -------------------------------------------------------------------------------- /AutoHome/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:\studio-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /AutoHome/src/androidTest/java/com/kevin/pulltorefresh/autohome/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome; 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 | } -------------------------------------------------------------------------------- /AutoHome/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /AutoHome/src/main/assets/loopview.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": [ 3 | { 4 | "id": "0", 5 | "descText": "底特律之战 别克昂科威对比Jeep自由光", 6 | "imgUrl": "https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/picture/loopview_picture1.jpg", 7 | "link":"http://www.autohome.com.cn/drive/201512/882411-6.html#pvareaid=2023104" 8 | }, 9 | { 10 | "id": "1", 11 | "descText": "注重安全性 浅谈朗逸1.6L购车经历", 12 | "imgUrl": "https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/picture/loopview_picture2.jpg", 13 | "link":"http://club.autohome.com.cn/bbs/thread-c-614-46840565-1.html#pvareaid=2023107" 14 | }, 15 | { 16 | "id": "2", 17 | "descText": "未来的路一起走 入手奔驰CLS 400", 18 | "imgUrl": "https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/picture/loopview_picture3.jpg", 19 | "link":"http://club.autohome.com.cn/bbs/thread-c-365-48040044-1.html#pvareaid=2023108" 20 | }, 21 | { 22 | "id": "3", 23 | "descText": "实拍吉利博越1.8T四驱顶配车型", 24 | "imgUrl": "https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/picture/loopview_picture4.jpg", 25 | "link":"http://www.autohome.com.cn/advice/201512/883057.html#pvareaid=2023109" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /AutoHome/src/main/java/com/kevin/pulltorefresh/autohome/LocalFileUtils.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome; 2 | 3 | import android.content.Context; 4 | import android.content.res.AssetManager; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | 8 | import java.io.BufferedReader; 9 | import java.io.ByteArrayOutputStream; 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | import java.io.InputStreamReader; 13 | 14 | /** 15 | * 版权所有:----有限公司
16 | * 17 | * LocalFileUtils
18 | * 19 | *

20 | * @author zhou.wenkai ,Created on 2015-5-9 13:11:48
21 | * @Description Major Function:读取本地包内文件
22 | *

23 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!!
24 | * @author mender,Modified Date Modify Content: 25 | */ 26 | public class LocalFileUtils { 27 | 28 | /** 29 | * 获取Asset下文本内容 30 | * @param context 31 | * @param str 32 | * @return 33 | */ 34 | public final static String getStringFormAsset(Context context, String str) { 35 | BufferedReader in = null; 36 | try { 37 | in = new BufferedReader(new InputStreamReader(context.getAssets().open(str))); 38 | String line; 39 | StringBuilder buffer = new StringBuilder(); 40 | while ((line = in.readLine()) != null) { 41 | buffer.append(line).append('\n'); 42 | } 43 | return buffer.toString(); 44 | } catch (IOException e) { 45 | e.printStackTrace(); 46 | return ""; 47 | } finally { 48 | if (in != null) { 49 | try { 50 | in.close(); 51 | in = null; 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | } 57 | } 58 | 59 | /** 60 | * @description 从Assets中读取图片 61 | * 62 | * @param context 63 | * @param fileName 64 | * @return 图片 65 | * @date 2015-6-11 15:00:55 66 | */ 67 | public static Bitmap getImageFromAssetsFile(Context context, String fileName) { 68 | Bitmap image = null; 69 | AssetManager am = context.getAssets(); 70 | InputStream is = null; 71 | try { 72 | is = am.open(fileName); 73 | image = BitmapFactory.decodeStream(is); 74 | return image; 75 | } catch (IOException e) { 76 | e.printStackTrace(); 77 | return image; 78 | } finally { 79 | if(is != null) { 80 | try { 81 | is.close(); 82 | is = null; 83 | } catch (IOException e) { 84 | e.printStackTrace(); 85 | } 86 | } 87 | } 88 | } 89 | 90 | /** 91 | * 获取Raw下文本内容 92 | * @param context 93 | * @param rawId 94 | * @return 95 | */ 96 | public final static String getStringFormRaw(Context context, int rawId) { 97 | ByteArrayOutputStream baos = null; 98 | InputStream in = context.getResources().openRawResource(rawId); 99 | try { 100 | baos = new ByteArrayOutputStream(); 101 | byte[] buffer = new byte[1024]; 102 | int len = 0; 103 | while ((len = in.read(buffer)) != -1) { 104 | baos.write(buffer, 0, len); 105 | } 106 | baos.close(); 107 | return baos.toString(); 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | return ""; 111 | } finally { 112 | if (baos != null) { 113 | try { 114 | baos.close(); 115 | baos = null; 116 | } catch (IOException e) { 117 | e.printStackTrace(); 118 | } 119 | } 120 | } 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /AutoHome/src/main/java/com/kevin/pulltorefresh/autohome/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.FrameLayout; 12 | import android.widget.TextView; 13 | 14 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 15 | import com.handmark.pulltorefresh.library.extras.recyclerview.PullToRefreshRecyclerView; 16 | import com.kevin.loopview.AdLoopView; 17 | import com.kevin.pulltorefresh.autohome.loadinglayout.AutoHomeHeaderLayout; 18 | import com.kevin.wraprecyclerview.WrapAdapter; 19 | 20 | import java.util.Arrays; 21 | import java.util.LinkedList; 22 | 23 | /** 24 | * 版权所有:XXX有限公司
25 | * 26 | * MainActivity 27 | * 28 | * @author zhou.wenkai ,Created on 2015-12-22 9:04:49 29 | * @description Major Function:PullToRefresh框架之汽车之家刷新头部 30 | * 31 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 32 | * @author mender,Modified Date Modify Content: 33 | */ 34 | public class MainActivity extends AppCompatActivity { 35 | 36 | private String[] mStrings = { "Auto Home is a good website.", "There are a lot of friends who love cars."}; 37 | 38 | private PullToRefreshRecyclerView mPullToRefreshRecyclerView; 39 | private RecyclerView mRecyclerView; 40 | private LinkedList mListItems; 41 | // 自定义可添加头部、尾部 RecyclerView数据适配器包装类 42 | private WrapAdapter mWrapAdapter; 43 | private RecyclerViewAdapter mAdapter; 44 | private AdLoopView mAdLoopView; 45 | 46 | @Override 47 | protected void onCreate(Bundle savedInstanceState) { 48 | super.onCreate(savedInstanceState); 49 | setContentView(R.layout.activity_main); 50 | 51 | mListItems = new LinkedList<>(); 52 | mListItems.addAll(Arrays.asList(mStrings)); 53 | 54 | initViews(); 55 | initEvents(); 56 | } 57 | 58 | /** 59 | * 初始化View 60 | */ 61 | private void initViews() { 62 | mPullToRefreshRecyclerView = (PullToRefreshRecyclerView) this.findViewById(R.id.main_act_recycler_view); 63 | mPullToRefreshRecyclerView.setHeaderLayout(new AutoHomeHeaderLayout(this)); 64 | 65 | initRecyclerView(); 66 | initLoopView(); 67 | } 68 | 69 | /** 70 | * 初始化 RecyclerView 71 | */ 72 | private void initRecyclerView() { 73 | mRecyclerView = mPullToRefreshRecyclerView.getRefreshableView(); 74 | mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 75 | mAdapter = new RecyclerViewAdapter(); 76 | mWrapAdapter = new WrapAdapter<>(mAdapter); 77 | mRecyclerView.setAdapter(mWrapAdapter); 78 | } 79 | 80 | /** 81 | * 初始化LoopView 82 | * 83 | * 这里使用的是LoopView开源项目,项目地址:https://github.com/xuehuayous/Android-LoopView 84 | * 85 | * @return void 86 | */ 87 | private void initLoopView() { 88 | LayoutInflater inflater = LayoutInflater.from(this); 89 | FrameLayout layout = (FrameLayout) inflater.inflate(R.layout.recycler_header, null); 90 | mAdLoopView = (AdLoopView) layout.findViewById(R.id.home_frag_rotate_vp); 91 | mWrapAdapter.addHeaderView(layout); 92 | 93 | // 初始化RotateView数据 94 | String json = LocalFileUtils.getStringFormAsset(this, "loopview.json"); 95 | mAdLoopView.refreshData(json); 96 | mAdLoopView.startAutoLoop(); 97 | } 98 | 99 | private void initEvents() { 100 | mPullToRefreshRecyclerView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() { 101 | 102 | @Override 103 | public void onPullDownToRefresh(PullToRefreshBase refreshView) { 104 | new GetDataTask().execute(); 105 | } 106 | 107 | @Override 108 | public void onPullUpToRefresh(PullToRefreshBase refreshView) { 109 | new GetDataTask().execute(); 110 | } 111 | }); 112 | } 113 | 114 | private class GetDataTask extends AsyncTask { 115 | 116 | @Override 117 | protected String[] doInBackground(Void... params) { 118 | try { 119 | Thread.sleep(3000); 120 | } catch (InterruptedException e) { 121 | } 122 | return mStrings; 123 | } 124 | 125 | @Override 126 | protected void onPostExecute(String[] result) { 127 | mListItems.addFirst("Added after refresh..."); 128 | mWrapAdapter.notifyDataSetChanged(); 129 | 130 | // Call onRefreshComplete when the list has been refreshed. 131 | mPullToRefreshRecyclerView.onRefreshComplete(); 132 | 133 | super.onPostExecute(result); 134 | } 135 | } 136 | 137 | class RecyclerViewAdapter extends RecyclerView.Adapter { 138 | 139 | @Override 140 | public int getItemCount() { 141 | return mListItems.size(); 142 | } 143 | 144 | @Override 145 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 146 | MyViewHolder holder = new MyViewHolder(LayoutInflater.from( 147 | MainActivity.this).inflate(android.R.layout.simple_list_item_1, parent, 148 | false)); 149 | return holder; 150 | } 151 | 152 | @Override 153 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 154 | ((MyViewHolder)holder).tv.setText(mListItems.get(position)); 155 | } 156 | 157 | class MyViewHolder extends RecyclerView.ViewHolder { 158 | TextView tv; 159 | public MyViewHolder(View view) { 160 | super(view); 161 | tv = (TextView) view.findViewById(android.R.id.text1); 162 | } 163 | } 164 | 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /AutoHome/src/main/java/com/kevin/pulltorefresh/autohome/loadinglayout/AutoHomeHeaderLayout.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome.loadinglayout; 2 | 3 | import android.content.Context; 4 | import android.view.Gravity; 5 | import android.view.LayoutInflater; 6 | import android.view.animation.Animation; 7 | import android.view.animation.AnimationUtils; 8 | import android.widget.FrameLayout; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.handmark.pulltorefresh.library.LoadingLayoutBase; 13 | import com.kevin.pulltorefresh.autohome.R; 14 | import com.nineoldandroids.animation.ObjectAnimator; 15 | import com.nineoldandroids.view.ViewHelper; 16 | 17 | /** 18 | * Created by zhouwk on 2015/12/22 0022. 19 | */ 20 | public class AutoHomeHeaderLayout extends LoadingLayoutBase{ 21 | 22 | private FrameLayout mInnerLayout; 23 | private TextView mHeaderText; 24 | private TextView mSubHeaderText; 25 | private ImageView mDialImage; 26 | private ImageView mPointerImage; 27 | 28 | private CharSequence mPullLabel; 29 | private CharSequence mRefreshingLabel; 30 | private CharSequence mReleaseLabel; 31 | 32 | private Animation mAnimPointer; 33 | 34 | public AutoHomeHeaderLayout(Context context) { 35 | super(context); 36 | 37 | LayoutInflater.from(context).inflate(R.layout.autohome_header_loadinglayout, this); 38 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 39 | mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text); 40 | mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text); 41 | mDialImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_dial); 42 | mPointerImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_pointer); 43 | 44 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 45 | lp.gravity = Gravity.BOTTOM; 46 | 47 | // Load in labels 48 | mPullLabel = context.getString(R.string.autohome_pull_label); 49 | mRefreshingLabel = context.getString(R.string.autohome_refreshing_label); 50 | mReleaseLabel = context.getString(R.string.autohome_release_label); 51 | 52 | mAnimPointer = AnimationUtils.loadAnimation(context, R.anim.pointer_rotate); 53 | 54 | reset(); 55 | } 56 | 57 | // 获取"加载头部"高度 58 | @Override 59 | public int getContentSize() { 60 | return mInnerLayout.getHeight(); 61 | } 62 | 63 | // 开始下拉时的回调 64 | @Override 65 | public void pullToRefresh() { 66 | mHeaderText.setText(mPullLabel); 67 | } 68 | 69 | // "加载头部"完全显示时的回调 70 | @Override 71 | public void releaseToRefresh() { 72 | mHeaderText.setText(mReleaseLabel); 73 | } 74 | 75 | // 下拉拖动时的回调 76 | @Override 77 | public void onPull(float scaleOfLayout) { 78 | if(scaleOfLayout < 0.7f) scaleOfLayout = 0.7f; 79 | if(scaleOfLayout > 1.0f) scaleOfLayout = 1.0f; 80 | 81 | //旋转动画 82 | ViewHelper.setPivotX(mPointerImage, mPointerImage.getMeasuredWidth()/2); // 设置中心点 83 | ViewHelper.setPivotY(mPointerImage, mPointerImage.getMeasuredHeight()/2); 84 | ObjectAnimator animPY = ObjectAnimator.ofFloat(mPointerImage, "rotation", 0, 250).setDuration(300); 85 | animPY.setCurrentPlayTime((long) (scaleOfLayout * 1000 - 700)); 86 | } 87 | 88 | // 释放后刷新时的回调 89 | @Override 90 | public void refreshing() { 91 | mHeaderText.setText(mRefreshingLabel); 92 | mPointerImage.startAnimation(mAnimPointer); 93 | } 94 | 95 | @Override 96 | public void reset() { 97 | mPointerImage.clearAnimation(); 98 | } 99 | 100 | @Override 101 | public void setPullLabel(CharSequence pullLabel) { 102 | mPullLabel = pullLabel; 103 | } 104 | 105 | @Override 106 | public void setRefreshingLabel(CharSequence refreshingLabel) { 107 | mRefreshingLabel = refreshingLabel; 108 | } 109 | 110 | @Override 111 | public void setReleaseLabel(CharSequence releaseLabel) { 112 | mReleaseLabel = releaseLabel; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/anim/pointer_rotate.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/layout/autohome_header_loadinglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 18 | 19 | 27 | 28 | 36 | 37 | 38 | 42 | 43 | 48 | 49 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/layout/recycler_header.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-xhdpi/load_icon_dial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-xhdpi/load_icon_dial.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-xhdpi/load_icon_pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-xhdpi/load_icon_pointer.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/AutoHome/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AutoHome/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | AutoHome 3 | 4 | 下拉刷新 5 | 正在加载 6 | 松开刷新 7 | 8 | -------------------------------------------------------------------------------- /AutoHome/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /AutoHome/src/test/java/com/kevin/pulltorefresh/autohome/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.autohome; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /JingDong/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /JingDong/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.kevin.pulltorefresh.jingdong" 9 | minSdkVersion 11 10 | targetSdkVersion 23 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 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile 'com.nineoldandroids:library:2.4.0' 27 | compile 'com.kevin:pulltorefresh:1.0.7' 28 | } 29 | -------------------------------------------------------------------------------- /JingDong/jingdong_header_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/jingdong_header_demo.gif -------------------------------------------------------------------------------- /JingDong/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:\studio-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /JingDong/src/androidTest/java/com/kevin/pulltorefresh/jingdong/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.jingdong; 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 | } -------------------------------------------------------------------------------- /JingDong/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /JingDong/src/main/java/com/kevin/pulltorefresh/jingdong/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.jingdong; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.text.format.DateUtils; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.ListView; 9 | 10 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 11 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 12 | import com.kevin.pulltorefresh.jingdong.loadinglayout.JingDongHeaderLayout; 13 | 14 | import java.util.Arrays; 15 | import java.util.LinkedList; 16 | 17 | /** 18 | * 版权所有:XXX有限公司
19 | * 20 | * MainActivity 21 | * 22 | * @author zhou.wenkai ,Created on 2015-12-21 9:59:31 23 | * @description Major Function:PullToRefresh框架之京东刷新头部 24 | * 25 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 26 | * @author mender,Modified Date Modify Content: 27 | */ 28 | public class MainActivity extends AppCompatActivity { 29 | 30 | private String[] mStrings = {"Jingdong's mascot is a dog.", "But I like the wolf.", 31 | "The wolf is a very powerful animal."}; 32 | 33 | private PullToRefreshListView mPullToRefreshListView; 34 | private ListView mListView; 35 | 36 | private LinkedList mListItems; 37 | private ArrayAdapter mAdapter; 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | setContentView(R.layout.activity_main); 43 | 44 | mListItems = new LinkedList<>(); 45 | mListItems.addAll(Arrays.asList(mStrings)); 46 | 47 | initViews(); 48 | initEvents(); 49 | } 50 | 51 | /** 52 | * 初始化View 53 | */ 54 | private void initViews() { 55 | mPullToRefreshListView = (PullToRefreshListView) this.findViewById(R.id.main_act_listview); 56 | // 设置自定义"刷新头部" 57 | mPullToRefreshListView.setHeaderLayout(new JingDongHeaderLayout(this)); 58 | 59 | mListView = mPullToRefreshListView.getRefreshableView(); 60 | mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mListItems); 61 | mListView.setAdapter(mAdapter); 62 | } 63 | 64 | /** 65 | * 初始化事件 66 | */ 67 | private void initEvents() { 68 | mPullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener() { 69 | @Override 70 | public void onRefresh(PullToRefreshBase refreshView) { 71 | // Do work to refresh the list here. 72 | new GetDataTask().execute(); 73 | } 74 | }); 75 | } 76 | 77 | private class GetDataTask extends AsyncTask { 78 | 79 | @Override 80 | protected String[] doInBackground(Void... params) { 81 | try { 82 | Thread.sleep(3000); 83 | } catch (InterruptedException e) { 84 | } 85 | return mStrings; 86 | } 87 | 88 | @Override 89 | protected void onPostExecute(String[] result) { 90 | mListItems.addFirst("Added after refresh..."); 91 | mAdapter.notifyDataSetChanged(); 92 | 93 | // Call onRefreshComplete when the list has been refreshed. 94 | mPullToRefreshListView.onRefreshComplete(); 95 | 96 | super.onPostExecute(result); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /JingDong/src/main/java/com/kevin/pulltorefresh/jingdong/loadinglayout/JingDongHeaderLayout.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.jingdong.loadinglayout; 2 | 3 | 4 | import android.content.Context; 5 | import android.graphics.drawable.AnimationDrawable; 6 | import android.view.Gravity; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.widget.FrameLayout; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.handmark.pulltorefresh.library.LoadingLayoutBase; 14 | import com.kevin.pulltorefresh.jingdong.R; 15 | import com.nineoldandroids.animation.ObjectAnimator; 16 | import com.nineoldandroids.view.ViewHelper; 17 | 18 | /** 19 | * Created by zhouwk on 2015/12/21 0021. 20 | */ 21 | public class JingDongHeaderLayout extends LoadingLayoutBase { 22 | 23 | static final String LOG_TAG = "PullToRefresh-JingDongHeaderLayout"; 24 | 25 | private FrameLayout mInnerLayout; 26 | private TextView mHeaderText; 27 | private TextView mSubHeaderText; 28 | private ImageView mGoodsImage; 29 | private ImageView mPersonImage; 30 | 31 | private CharSequence mPullLabel; 32 | private CharSequence mRefreshingLabel; 33 | private CharSequence mReleaseLabel; 34 | 35 | private AnimationDrawable animP; 36 | 37 | public JingDongHeaderLayout(Context context) { 38 | super(context); 39 | 40 | LayoutInflater.from(context).inflate(R.layout.jingdong_header_loadinglayout, this); 41 | 42 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 43 | mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text); 44 | mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text); 45 | mGoodsImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_goods); 46 | mPersonImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_people); 47 | 48 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 49 | lp.gravity = Gravity.BOTTOM; 50 | 51 | // Load in labels 52 | mPullLabel = context.getString(R.string.jingdong_pull_label); 53 | mRefreshingLabel = context.getString(R.string.jingdong_refreshing_label); 54 | mReleaseLabel = context.getString(R.string.jingdong_release_label); 55 | 56 | reset(); 57 | } 58 | 59 | // 获取"加载头部"高度 60 | @Override 61 | public int getContentSize() { 62 | return mInnerLayout.getHeight(); 63 | } 64 | 65 | // 开始下拉时的回调 66 | @Override 67 | public void pullToRefresh() { 68 | mSubHeaderText.setText(mPullLabel); 69 | } 70 | 71 | // "加载头部"完全显示时的回调 72 | @Override 73 | public void releaseToRefresh() { 74 | mSubHeaderText.setText(mReleaseLabel); 75 | } 76 | 77 | // 下拉拖动时的回调 78 | @Override 79 | public void onPull(float scaleOfLayout) { 80 | scaleOfLayout = scaleOfLayout > 1.0f ? 1.0f : scaleOfLayout; 81 | 82 | if (mGoodsImage.getVisibility() != View.VISIBLE) { 83 | mGoodsImage.setVisibility(View.VISIBLE); 84 | } 85 | 86 | //透明度动画 87 | ObjectAnimator animAlphaP = ObjectAnimator.ofFloat(mPersonImage, "alpha", -1, 1).setDuration(300); 88 | animAlphaP.setCurrentPlayTime((long) (scaleOfLayout * 300)); 89 | ObjectAnimator animAlphaG = ObjectAnimator.ofFloat(mGoodsImage, "alpha", -1, 1).setDuration(300); 90 | animAlphaG.setCurrentPlayTime((long) (scaleOfLayout * 300)); 91 | 92 | //缩放动画 93 | ViewHelper.setPivotX(mPersonImage, 0); // 设置中心点 94 | ViewHelper.setPivotY(mPersonImage, 0); 95 | ObjectAnimator animPX = ObjectAnimator.ofFloat(mPersonImage, "scaleX", 0, 1).setDuration(300); 96 | animPX.setCurrentPlayTime((long) (scaleOfLayout * 300)); 97 | ObjectAnimator animPY = ObjectAnimator.ofFloat(mPersonImage, "scaleY", 0, 1).setDuration(300); 98 | animPY.setCurrentPlayTime((long) (scaleOfLayout * 300)); 99 | 100 | ViewHelper.setPivotX(mGoodsImage, mGoodsImage.getMeasuredWidth()); 101 | ObjectAnimator animGX = ObjectAnimator.ofFloat(mGoodsImage, "scaleX", 0, 1).setDuration(300); 102 | animGX.setCurrentPlayTime((long) (scaleOfLayout * 300)); 103 | ObjectAnimator animGY = ObjectAnimator.ofFloat(mGoodsImage, "scaleY", 0, 1).setDuration(300); 104 | animGY.setCurrentPlayTime((long) (scaleOfLayout * 300)); 105 | } 106 | 107 | // 释放后刷新时的回调 108 | @Override 109 | public void refreshing() { 110 | mSubHeaderText.setText(mRefreshingLabel); 111 | 112 | if (animP == null) { 113 | mPersonImage.setImageResource(R.drawable.refreshing_anim); 114 | animP = (AnimationDrawable) mPersonImage.getDrawable(); 115 | } 116 | animP.start(); 117 | if (mGoodsImage.getVisibility() == View.VISIBLE) { 118 | mGoodsImage.setVisibility(View.INVISIBLE); 119 | } 120 | } 121 | 122 | // 初始化到未刷新状态 123 | @Override 124 | public void reset() { 125 | if (animP != null) { 126 | animP.stop(); 127 | animP = null; 128 | } 129 | mPersonImage.setImageResource(R.mipmap.app_refresh_people_0); 130 | if (mGoodsImage.getVisibility() == View.VISIBLE) { 131 | mGoodsImage.setVisibility(View.INVISIBLE); 132 | } 133 | } 134 | 135 | @Override 136 | public void setPullLabel(CharSequence pullLabel) { 137 | mPullLabel = pullLabel; 138 | } 139 | 140 | @Override 141 | public void setRefreshingLabel(CharSequence refreshingLabel) { 142 | mRefreshingLabel = refreshingLabel; 143 | } 144 | 145 | @Override 146 | public void setReleaseLabel(CharSequence releaseLabel) { 147 | mReleaseLabel = releaseLabel; 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /JingDong/src/main/res/drawable/refreshing_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JingDong/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /JingDong/src/main/res/layout/jingdong_header_loadinglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 19 | 20 | 28 | 29 | 37 | 38 | 39 | 42 | 43 | 49 | 50 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/app_refresh_goods_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/app_refresh_goods_0.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_0.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_1.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_2.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/app_refresh_people_3.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /JingDong/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/JingDong/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /JingDong/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /JingDong/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /JingDong/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /JingDong/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PullToRefresh_JingDong 3 | 4 | 下拉可以刷新 5 | 正在加载中 6 | 松开后刷新 7 | 8 | -------------------------------------------------------------------------------- /JingDong/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /JingDong/src/test/java/com/kevin/pulltorefresh/jingdong/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.jingdong; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /MeiTuan/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MeiTuan/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.kevin.pulltorefresh.meituan" 9 | minSdkVersion 11 10 | targetSdkVersion 23 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 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile 'com.nineoldandroids:library:2.4.0' 27 | compile 'com.kevin:pulltorefresh:1.0.7' 28 | } -------------------------------------------------------------------------------- /MeiTuan/meituan_header_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/meituan_header_demo.gif -------------------------------------------------------------------------------- /MeiTuan/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:\studio-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /MeiTuan/src/androidTest/java/com/kevin/pulltorefresh/meituan/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.meituan; 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 | } -------------------------------------------------------------------------------- /MeiTuan/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MeiTuan/src/main/java/com/kevin/pulltorefresh/meituan/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.meituan; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.widget.ScrollView; 7 | 8 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 9 | import com.handmark.pulltorefresh.library.PullToRefreshScrollView; 10 | import com.kevin.pulltorefresh.meituan.loadinglayout.MeiTuanHeaderLayout; 11 | 12 | /** 13 | * 版权所有:XXX有限公司
14 | * 15 | * MainActivity 16 | * 17 | * @author zhou.wenkai ,Created on 2015-12-21 14:58:38 18 | * @description Major Function:PullToRefresh框架之美团刷新头部 19 | * 20 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 21 | * @author mender,Modified Date Modify Content: 22 | */ 23 | public class MainActivity extends AppCompatActivity { 24 | 25 | private PullToRefreshScrollView mPullToRefreshScrollView; 26 | 27 | @Override 28 | protected void onCreate(Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.activity_main); 31 | 32 | initViews(); 33 | initEvents(); 34 | } 35 | 36 | /** 37 | * 初始化Views 38 | */ 39 | private void initViews() { 40 | mPullToRefreshScrollView = (PullToRefreshScrollView) this.findViewById(R.id.main_act_scrollview); 41 | mPullToRefreshScrollView.setHeaderLayout(new MeiTuanHeaderLayout(this)); 42 | } 43 | 44 | /** 45 | * 初始化事件 46 | */ 47 | private void initEvents() { 48 | mPullToRefreshScrollView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener() { 49 | 50 | @Override 51 | public void onRefresh(PullToRefreshBase refreshView) { 52 | new GetDataTask().execute(); 53 | } 54 | }); 55 | } 56 | 57 | private class GetDataTask extends AsyncTask { 58 | 59 | @Override 60 | protected String[] doInBackground(Void... params) { 61 | // Simulates a background job. 62 | try { 63 | Thread.sleep(3000); 64 | } catch (InterruptedException e) { 65 | } 66 | return null; 67 | } 68 | 69 | @Override 70 | protected void onPostExecute(String[] result) { 71 | // Do some stuff here 72 | 73 | // Call onRefreshComplete when the list has been refreshed. 74 | mPullToRefreshScrollView.onRefreshComplete(); 75 | 76 | super.onPostExecute(result); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MeiTuan/src/main/java/com/kevin/pulltorefresh/meituan/loadinglayout/MeiTuanHeaderLayout.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.meituan.loadinglayout; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.content.Context; 5 | import android.graphics.drawable.AnimationDrawable; 6 | import android.view.Gravity; 7 | import android.view.LayoutInflater; 8 | import android.widget.FrameLayout; 9 | import android.widget.ImageView; 10 | 11 | import com.handmark.pulltorefresh.library.LoadingLayoutBase; 12 | import com.kevin.pulltorefresh.meituan.R; 13 | import com.nineoldandroids.view.ViewHelper; 14 | 15 | /** 16 | * Created by zhouwk on 2015/12/21 0021. 17 | */ 18 | public class MeiTuanHeaderLayout extends LoadingLayoutBase{ 19 | 20 | static final String LOG_TAG = "PullToRefresh-MeiTuanHeaderLayout"; 21 | 22 | private FrameLayout mInnerLayout; 23 | private ImageView mBabyImage; 24 | 25 | private AnimationDrawable animBabyShow; 26 | private AnimationDrawable animBabyShake; 27 | 28 | public MeiTuanHeaderLayout(Context context) { 29 | super(context); 30 | 31 | LayoutInflater.from(context).inflate(R.layout.meituan_header_loadinglayout, this); 32 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 33 | mBabyImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_baby); 34 | 35 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 36 | lp.gravity = Gravity.BOTTOM; 37 | 38 | reset(); 39 | } 40 | 41 | // 获取"加载头部"高度 42 | @Override 43 | public int getContentSize() { 44 | return mInnerLayout.getHeight(); 45 | } 46 | 47 | // 开始下拉时的回调 48 | @Override 49 | public void pullToRefresh() { 50 | mBabyImage.setImageResource(R.mipmap.pull_image); 51 | } 52 | 53 | // "加载头部"完全显示时的回调 54 | @Override 55 | public void releaseToRefresh() { 56 | mBabyImage.setImageResource(R.drawable.pull_to_refresh_second_anim); 57 | if (animBabyShow == null) { 58 | animBabyShow = (AnimationDrawable) mBabyImage.getDrawable(); 59 | } 60 | animBabyShow.start(); 61 | } 62 | 63 | // 下拉拖动时的回调 64 | @Override 65 | public void onPull(float scaleOfLayout) { 66 | scaleOfLayout = scaleOfLayout > 1.0f ? 1.0f : scaleOfLayout; 67 | 68 | //缩放动画 69 | ViewHelper.setPivotY(mBabyImage, mBabyImage.getMeasuredHeight()); // 设置中心点 70 | ViewHelper.setPivotX(mBabyImage, mBabyImage.getMeasuredWidth() / 2); 71 | ObjectAnimator animPX = ObjectAnimator.ofFloat(mBabyImage, "scaleX", 0, 1).setDuration(300); 72 | animPX.setCurrentPlayTime((long) (scaleOfLayout * 300)); 73 | ObjectAnimator animPY = ObjectAnimator.ofFloat(mBabyImage, "scaleY", 0, 1).setDuration(300); 74 | animPY.setCurrentPlayTime((long) (scaleOfLayout * 300)); 75 | } 76 | 77 | // 释放后刷新时的回调 78 | @Override 79 | public void refreshing() { 80 | if(null != animBabyShow) { 81 | animBabyShow.stop(); 82 | } 83 | mBabyImage.setImageResource(R.drawable.pull_to_refresh_third_anim); 84 | if (animBabyShake == null) { 85 | animBabyShake = (AnimationDrawable) mBabyImage.getDrawable(); 86 | } 87 | animBabyShake.start(); 88 | } 89 | 90 | @Override 91 | public void reset() { 92 | if(animBabyShow != null) { 93 | animBabyShow.stop(); 94 | animBabyShow = null; 95 | } 96 | if (animBabyShake != null) { 97 | animBabyShake.stop(); 98 | animBabyShake = null; 99 | } 100 | } 101 | 102 | @Override 103 | public void setPullLabel(CharSequence pullLabel) { 104 | 105 | } 106 | 107 | @Override 108 | public void setRefreshingLabel(CharSequence refreshingLabel) { 109 | 110 | } 111 | 112 | @Override 113 | public void setReleaseLabel(CharSequence releaseLabel) { 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/drawable/pull_to_refresh_second_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/drawable/pull_to_refresh_third_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | 16 | 21 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/layout/meituan_header_loadinglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-hdpi/meituan_picture1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-hdpi/meituan_picture1.jpg -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-hdpi/meituan_picture2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-hdpi/meituan_picture2.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_01.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_02.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_03.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_04.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_end_image_frame_05.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/pull_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/pull_image.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_01.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_02.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_03.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_04.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_05.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_06.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_07.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xhdpi/refreshing_image_frame_08.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/MeiTuan/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MeiTuan/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PullToRefresh_MeiTuan 3 | 4 | -------------------------------------------------------------------------------- /MeiTuan/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MeiTuan/src/test/java/com/kevin/pulltorefresh/meituan/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.meituan; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | 2 | # PullToRefresh-Demo 3 | **[English](https://github.com/xuehuayous/PullToRefresh-Demo)** **[中文](https://github.com/xuehuayous/PullToRefresh-Demo/blob/master/README-zh.md)** 4 | 5 | - 该项目是 [Modified PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) 项目的一些示例演示。 6 | 7 | - [PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) 是在[chrisbanes/Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh)基础上完善而来。 8 | 9 | - [PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) 扩展了支持 RecyclerView,并且可以轻松定制刷新加载样式。 10 | 11 | ## 在项目中使用[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) 12 | 13 | 如果您的项目使用 Gradle 构建, 只需要在您的`build.gradle`文件添加下面一行到 `dependencies` : 14 | 15 | ``` 16 | compile 'com.kevin:pulltorefresh:1.0.7' 17 | ``` 18 | #Modules 19 | 20 | ##京东商城 21 | 这是一个用 **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** 实现的京东商城的加载头部示例。尽管使用的是PullToRefreshListView,您可以使用相同的方式来使用其他PullToRefresh控件。 22 | 23 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/JingDong/jingdong_header_demo.gif) 24 | 25 | ##美团 26 | 这是一个用 **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** 实现的美团的加载头部示例。尽管使用的是PullToRefreshScrollView,您可以使用相同的方式来使用其他PullToRefresh控件。 27 | 28 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/MeiTuan/meituan_header_demo.gif) 29 | 30 | ##汽车之家 31 | 这是一个用 **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** 实现的汽车之家的刷新加载示例,同时使用了[Android-LoopView](https://github.com/xuehuayous/Android-LoopView),使用它你可以轻松实现轮转大图。尽管使用的是PullToRefreshRecyclerView,您可以使用相同的方式来使用其他PullToRefresh控件。 32 | 33 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/autohome_header_demo.gif) 34 | 35 | #天猫 36 | 这是一个用 **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** 实现的天猫的刷新加载示例,同时使用了[WrapRecyclerView](https://github.com/xuehuayous/WrapRecyclerView), 使用它您可以轻松为RecyclerView添加头部和尾部。尽管使用的是PullToRefreshRecyclerView,您可以使用相同的方式来使用其他PullToRefresh控件。 37 | 38 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/Tmall/tmall_demo.gif) 39 | 40 | ## License 41 | 42 | Copyright 2015, Kevin.zhou 43 | 44 | Licensed under the Apache License, Version 2.0 (the "License"); 45 | you may not use this file except in compliance with the License. 46 | You may obtain a copy of the License at 47 | 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | 50 | Unless required by applicable law or agreed to in writing, software 51 | distributed under the License is distributed on an "AS IS" BASIS, 52 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | See the License for the specific language governing permissions and 54 | limitations under the License. 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # PullToRefresh-Demo 3 | **[English](https://github.com/xuehuayous/PullToRefresh-Demo)** **[中文](https://github.com/xuehuayous/PullToRefresh-Demo/blob/master/README-zh.md)** 4 | 5 | - This project is some demos of [Modified PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh). 6 | 7 | - [PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) is forked from [chrisbanes/Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh). 8 | 9 | - [PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) extends support RecyclerView, and can be easily customized to refresh loading styles. 10 | 11 | ## Using [Modified PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh) in your application 12 | 13 | If you are building with Gradle, simply add the following line to the `dependencies` section of your `build.gradle` file: 14 | 15 | ``` 16 | compile 'com.kevin:pulltorefresh:1.0.7' 17 | ``` 18 | #Modules 19 | 20 | ##JingDong 21 | This module a demo of **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** use in JingDong. Although the use in the moudle is PullToRefreshListView, you can use any other PullToRefresh Widget. 22 | 23 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/JingDong/jingdong_header_demo.gif) 24 | 25 | ##MeiTuan 26 | This module a demo of **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** use in MeiTuan. Although the use in the moudle is PullToRefreshScrollView, you can use any other PullToRefresh Widget. 27 | 28 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/MeiTuan/meituan_header_demo.gif) 29 | 30 | ##AutoHome 31 | This module a demo of **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** use in AutoHome, and it used [Android-LoopView](https://github.com/xuehuayous/Android-LoopView), you can use it to easily achieve the rotation picture. Although the use in the moudle is PullToRefreshRecyclerView, you can use any other PullToRefresh Widget. 32 | 33 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/AutoHome/autohome_header_demo.gif) 34 | 35 | #Tmall 36 | This module a demo of **[PullToRefresh](https://github.com/xuehuayous/Android-PullToRefresh)** use in Tmall,and it used [WrapRecyclerView](https://github.com/xuehuayous/WrapRecyclerView), it allows you to easily add headers and footers for RecyclerView. Although the use in the moudle is PullToRefreshRecyclerView, you can use any other PullToRefresh Widget. 37 | 38 | ![Screenshot](https://raw.githubusercontent.com/xuehuayous/PullToRefresh-Demo/master/Tmall/tmall_demo.gif) 39 | 40 | ## License 41 | 42 | Copyright 2015, Kevin.zhou 43 | 44 | Licensed under the Apache License, Version 2.0 (the "License"); 45 | you may not use this file except in compliance with the License. 46 | You may obtain a copy of the License at 47 | 48 | http://www.apache.org/licenses/LICENSE-2.0 49 | 50 | Unless required by applicable law or agreed to in writing, software 51 | distributed under the License is distributed on an "AS IS" BASIS, 52 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 53 | See the License for the specific language governing permissions and 54 | limitations under the License. 55 | -------------------------------------------------------------------------------- /Tmall/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Tmall/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.kevin.pulltorefresh.tmall" 9 | minSdkVersion 8 10 | targetSdkVersion 23 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 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile 'com.kevin:pulltorefresh:1.0.7' 27 | compile 'com.kevin:wraprecyclerview:1.0.1' 28 | } 29 | -------------------------------------------------------------------------------- /Tmall/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:\studio-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Tmall/src/androidTest/java/com/kevin/pulltorefresh/tmall/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.tmall; 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 | } -------------------------------------------------------------------------------- /Tmall/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Tmall/src/main/java/com/kevin/pulltorefresh/tmall/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.tmall; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.support.v7.widget.GridLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ImageView; 12 | 13 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 14 | import com.handmark.pulltorefresh.library.extras.recyclerview.PullToRefreshRecyclerView; 15 | import com.kevin.pulltorefresh.tmall.loadinglayout.TmallFooterLayout; 16 | import com.kevin.pulltorefresh.tmall.loadinglayout.TmallHeaderLayout; 17 | import com.kevin.wraprecyclerview.WrapAdapter; 18 | 19 | import java.util.LinkedList; 20 | 21 | /** 22 | * 版权所有:XXX有限公司
23 | * 24 | * MainActivity 25 | * 26 | * @author zhou.wenkai ,Created on 2015-12-30 11:21:46 27 | * @description Major Function:PullToRefresh框架之天猫刷新头部 28 | * 29 | * 注:如果您修改了本类请填写以下内容作为记录,如非本人操作劳烦通知,谢谢!!! 30 | * @author mender,Modified Date Modify Content: 31 | */ 32 | public class MainActivity extends AppCompatActivity { 33 | 34 | PullToRefreshRecyclerView mPullToRefreshRecyclerView; 35 | // 自定义可添加头部、尾部 RecyclerView数据适配器包装类 36 | private WrapAdapter mWrapAdapter; 37 | private RecyclerView mRecyclerView; 38 | private RecyclerViewAdapter mAdapter; 39 | 40 | private LinkedList mListItems; 41 | 42 | @Override 43 | protected void onCreate(Bundle savedInstanceState) { 44 | super.onCreate(savedInstanceState); 45 | setContentView(R.layout.activity_main); 46 | 47 | mListItems = new LinkedList<>(); 48 | mListItems.add(R.mipmap.tm_recycler0); 49 | mListItems.add(R.mipmap.tm_recycler2); 50 | mListItems.add(R.mipmap.tm_recycler4); 51 | 52 | initViews(); 53 | initEvents(); 54 | } 55 | 56 | private void initViews() { 57 | mPullToRefreshRecyclerView = (PullToRefreshRecyclerView) this.findViewById(R.id.main_act_recyclerview); 58 | mPullToRefreshRecyclerView.setHeaderLayout(new TmallHeaderLayout(this)); 59 | mPullToRefreshRecyclerView.setFooterLayout(new TmallFooterLayout(this)); 60 | 61 | initRecyclerView(); 62 | } 63 | 64 | /** 65 | * 初始化 RecyclerView 66 | */ 67 | private void initRecyclerView() { 68 | mRecyclerView = mPullToRefreshRecyclerView.getRefreshableView(); 69 | // mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 70 | mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2)); 71 | 72 | mPullToRefreshRecyclerView.setScrollingWhileRefreshingEnabled(false); 73 | 74 | 75 | mAdapter = new RecyclerViewAdapter(); 76 | mWrapAdapter = new WrapAdapter<>(mAdapter); 77 | mWrapAdapter.adjustSpanSize(mRecyclerView); 78 | mRecyclerView.setAdapter(mWrapAdapter); 79 | 80 | // 添加头部广告轮播,这里用一张图片模拟实现。广告轮播图请参考AutoHome(汽车之家)中的实现方式 81 | ImageView loopViewImage = new ImageView(this); 82 | ViewGroup.LayoutParams loopViewParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 83 | loopViewImage.setLayoutParams(loopViewParams); 84 | loopViewImage.setBackgroundResource(R.mipmap.tm_picture0); 85 | mWrapAdapter.addHeaderView(loopViewImage); 86 | 87 | // 添加头部功能选择,这里用一张图片模拟实现。 88 | ImageView functionImage = new ImageView(this); 89 | ViewGroup.LayoutParams functionParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 90 | functionImage.setLayoutParams(functionParams); 91 | functionImage.setBackgroundResource(R.mipmap.tm_picture1); 92 | mWrapAdapter.addHeaderView(functionImage); 93 | } 94 | 95 | private void initEvents() { 96 | mPullToRefreshRecyclerView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2() { 97 | 98 | @Override 99 | public void onPullDownToRefresh(PullToRefreshBase refreshView) { 100 | new GetDataTask().execute("下拉刷新"); 101 | } 102 | 103 | @Override 104 | public void onPullUpToRefresh(PullToRefreshBase refreshView) { 105 | new GetDataTask().execute("上拉加载"); 106 | } 107 | }); 108 | } 109 | 110 | private class GetDataTask extends AsyncTask { 111 | 112 | @Override 113 | protected Integer[] doInBackground(String... params) { 114 | try { 115 | Thread.sleep(3000); 116 | } catch (InterruptedException e) { 117 | } 118 | 119 | if(params[0].equals("下拉刷新")) { 120 | return new Integer[0]; 121 | } else { 122 | Integer[] a1 = {R.mipmap.tm_recycler1, R.mipmap.tm_recycler3, R.mipmap.tm_recycler5}; 123 | return a1; 124 | } 125 | } 126 | 127 | @Override 128 | protected void onPostExecute(Integer[] result) { 129 | for(Integer id : result) { 130 | mListItems.addLast(id); 131 | } 132 | mWrapAdapter.notifyDataSetChanged(); 133 | 134 | // Call onRefreshComplete when the list has been refreshed. 135 | mPullToRefreshRecyclerView.onRefreshComplete(); 136 | 137 | super.onPostExecute(result); 138 | } 139 | } 140 | 141 | class RecyclerViewAdapter extends RecyclerView.Adapter { 142 | 143 | @Override 144 | public int getItemCount() { 145 | return mListItems.size(); 146 | } 147 | 148 | @Override 149 | public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 150 | MyViewHolder holder = new MyViewHolder(LayoutInflater.from( 151 | MainActivity.this).inflate(R.layout.layout_recycler_item, parent, 152 | false)); 153 | return holder; 154 | } 155 | 156 | @Override 157 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 158 | // ((MyViewHolder)holder).iv.setText(mListItems.get(position)); 159 | // ((MyViewHolder)holder).iv.setImageResource(mListItems.get(position)); 160 | ((MyViewHolder)holder).iv.setBackgroundResource(mListItems.get(position)); 161 | } 162 | 163 | class MyViewHolder extends RecyclerView.ViewHolder { 164 | ImageView iv; 165 | public MyViewHolder(View view) { 166 | super(view); 167 | iv = (ImageView) view.findViewById(R.id.recycler_item_iv); 168 | } 169 | } 170 | 171 | } 172 | 173 | 174 | } 175 | -------------------------------------------------------------------------------- /Tmall/src/main/java/com/kevin/pulltorefresh/tmall/loadinglayout/TmallFooterLayout.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.tmall.loadinglayout; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.AnimationDrawable; 5 | import android.view.Gravity; 6 | import android.view.LayoutInflater; 7 | import android.widget.FrameLayout; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.handmark.pulltorefresh.library.LoadingLayoutBase; 12 | import com.kevin.pulltorefresh.tmall.R; 13 | 14 | /** 15 | * Created by zhouwk on 2015/12/30 0030. 16 | */ 17 | public class TmallFooterLayout extends LoadingLayoutBase{ 18 | 19 | private FrameLayout mInnerLayout; 20 | private ImageView mCatImage; 21 | 22 | private AnimationDrawable animCat; 23 | 24 | public TmallFooterLayout(Context context) { 25 | super(context); 26 | 27 | LayoutInflater.from(context).inflate(R.layout.tmall_footer_loadinglayout, this); 28 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 29 | mCatImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_cat); 30 | 31 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 32 | lp.gravity = Gravity.TOP; 33 | 34 | reset(); 35 | } 36 | 37 | // 获取"加载头部"高度 38 | @Override 39 | public int getContentSize() { 40 | return mInnerLayout.getHeight(); 41 | } 42 | 43 | // 开始下拉时的回调 44 | @Override 45 | public void pullToRefresh() { 46 | } 47 | 48 | // "加载头部"完全显示时的回调 49 | @Override 50 | public void releaseToRefresh() { 51 | 52 | if (animCat == null) { 53 | mCatImage.setImageResource(R.drawable.refreshing_footer_anim); 54 | animCat = (AnimationDrawable) mCatImage.getDrawable(); 55 | } 56 | animCat.start(); 57 | } 58 | 59 | // 下拉拖动时的回调 60 | @Override 61 | public void onPull(float scaleOfLayout) { 62 | 63 | } 64 | 65 | // 释放后刷新时的回调 66 | @Override 67 | public void refreshing() { 68 | } 69 | 70 | // 初始化到未刷新状态 71 | @Override 72 | public void reset() { 73 | if (animCat != null) { 74 | animCat.stop(); 75 | animCat = null; 76 | } 77 | mCatImage.setImageResource(R.mipmap.tm_load_cat_full); 78 | } 79 | 80 | @Override 81 | public void setPullLabel(CharSequence pullLabel) { 82 | } 83 | 84 | @Override 85 | public void setRefreshingLabel(CharSequence refreshingLabel) { 86 | } 87 | 88 | @Override 89 | public void setReleaseLabel(CharSequence releaseLabel) { 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Tmall/src/main/java/com/kevin/pulltorefresh/tmall/loadinglayout/TmallHeaderLayout.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.tmall.loadinglayout; 2 | 3 | import android.content.Context; 4 | import android.graphics.drawable.AnimationDrawable; 5 | import android.view.Gravity; 6 | import android.view.LayoutInflater; 7 | import android.widget.FrameLayout; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import com.handmark.pulltorefresh.library.LoadingLayoutBase; 12 | import com.kevin.pulltorefresh.tmall.R; 13 | 14 | /** 15 | * Created by zhouwk on 2015/12/30 0030. 16 | */ 17 | public class TmallHeaderLayout extends LoadingLayoutBase{ 18 | 19 | private FrameLayout mInnerLayout; 20 | private TextView mHeaderText; 21 | private ImageView mBikeImage; 22 | 23 | private CharSequence mPullLabel; 24 | private CharSequence mRefreshingLabel; 25 | private CharSequence mReleaseLabel; 26 | 27 | private AnimationDrawable animBike; 28 | 29 | public TmallHeaderLayout(Context context) { 30 | super(context); 31 | 32 | LayoutInflater.from(context).inflate(R.layout.tmall_header_loadinglayout, this); 33 | mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); 34 | mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text); 35 | mBikeImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_bike); 36 | 37 | LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); 38 | lp.gravity = Gravity.BOTTOM; 39 | 40 | // Load in labels 41 | mPullLabel = context.getString(R.string.tmall_pull_label); 42 | mRefreshingLabel = context.getString(R.string.tmall_refreshing_label); 43 | mReleaseLabel = context.getString(R.string.tmall_release_label); 44 | 45 | reset(); 46 | } 47 | 48 | // 获取"加载头部"高度 49 | @Override 50 | public int getContentSize() { 51 | // 设置未完全显示的时候就促发刷新动作 52 | return mInnerLayout.getHeight() * 7 / 10; 53 | } 54 | 55 | // 开始下拉时的回调 56 | @Override 57 | public void pullToRefresh() { 58 | mHeaderText.setText(mPullLabel); 59 | } 60 | 61 | // "加载头部"完全显示时的回调 62 | @Override 63 | public void releaseToRefresh() { 64 | mHeaderText.setText(mReleaseLabel); 65 | 66 | if (animBike == null) { 67 | mBikeImage.setImageResource(R.drawable.refreshing_header_anim); 68 | animBike = (AnimationDrawable) mBikeImage.getDrawable(); 69 | } 70 | animBike.start(); 71 | } 72 | 73 | // 下拉拖动时的回调 74 | @Override 75 | public void onPull(float scaleOfLayout) { 76 | 77 | } 78 | 79 | // 释放后刷新时的回调 80 | @Override 81 | public void refreshing() { 82 | mHeaderText.setText(mRefreshingLabel); 83 | } 84 | 85 | // 初始化到未刷新状态 86 | @Override 87 | public void reset() { 88 | if (animBike != null) { 89 | animBike.stop(); 90 | animBike = null; 91 | } 92 | mBikeImage.setImageResource(R.mipmap.tm_mui_bike_0); 93 | } 94 | 95 | @Override 96 | public void setPullLabel(CharSequence pullLabel) { 97 | mPullLabel = pullLabel; 98 | } 99 | 100 | @Override 101 | public void setRefreshingLabel(CharSequence refreshingLabel) { 102 | mRefreshingLabel = refreshingLabel; 103 | } 104 | 105 | @Override 106 | public void setReleaseLabel(CharSequence releaseLabel) { 107 | mReleaseLabel = releaseLabel; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Tmall/src/main/res/drawable/refreshing_footer_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tmall/src/main/res/drawable/refreshing_header_anim.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Tmall/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /Tmall/src/main/res/layout/layout_recycler_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /Tmall/src/main/res/layout/tmall_footer_loadinglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 19 | 26 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Tmall/src/main/res/layout/tmall_header_loadinglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 22 | 23 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_0.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_1.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_2.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_3.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_4.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_5.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_6.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-mdpi/tm_mui_bike_7.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_end.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_fail.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_full.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_load_cat_full.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_1.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_10.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_11.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_12.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_13.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_14.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_15.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_16.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_17.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_18.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_19.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_2.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_20.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_3.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_4.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_5.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_6.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_7.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_8.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xhdpi/tm_loading_cat_9.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_picture0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_picture0.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_picture1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_picture1.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler0.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler1.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler2.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler3.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler4.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxhdpi/tm_recycler5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxhdpi/tm_recycler5.png -------------------------------------------------------------------------------- /Tmall/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Tmall/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /Tmall/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /Tmall/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /Tmall/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Tmall 3 | 4 | 下拉刷新 5 | 正在刷新... 6 | 松开立即刷新 7 | 8 | -------------------------------------------------------------------------------- /Tmall/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Tmall/src/test/java/com/kevin/pulltorefresh/tmall/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.kevin.pulltorefresh.tmall; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /Tmall/tmall_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/Tmall/tmall_demo.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.0.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 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Mon Dec 21 09:31:52 GMT+08:00 2015 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WenkaiZhou/PullToRefresh-Demo/f05dc49b7473fd0e0f1df506a1db2f55e9550db6/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Apr 10 21:09:20 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-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 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /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 ':JingDong', ':MeiTuan', ':AutoHome', ':Tmall' 2 | --------------------------------------------------------------------------------