├── .gitignore ├── README.md ├── build.gradle ├── demo ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── pullrefresh │ │ └── demo │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pullrefresh │ │ └── demo │ │ ├── DemoAct.java │ │ ├── RecyclerViewAct.java │ │ └── ScrollViewAct.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ ├── ic_launcher.png │ └── pulltorefresh_arrow.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ ├── activity_main.xml │ └── recycler.xml │ ├── menu │ └── menu_main.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── lib ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── pullrefreshlayout │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── pullrefreshlayout │ │ ├── DefaultHeadView.java │ │ ├── ILoadingLayout.java │ │ ├── PullRefresScrollView.java │ │ ├── PullRefreshRecyclerView.java │ │ ├── RefreshLayout.java │ │ └── WaterfallRecyclerView.java │ └── res │ ├── anim │ ├── down_to_up.xml │ └── up_to_down.xml │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ ├── ic_launcher.png │ └── pulltorefresh_arrow.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ ├── layout │ └── head_layout.xml │ ├── values-zh │ └── strings.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── recyclerview.gif ├── scrollview.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | .DS_Store 3 | 4 | # library 5 | mgim/ 6 | mglibs/ 7 | mgim-android/ 8 | library/ 9 | 10 | # android generated 11 | bin/ 12 | gen/ 13 | 14 | # eclipse 15 | .classpath 16 | .settings 17 | .project 18 | 19 | local.properties 20 | project.properties 21 | 22 | # IDEA 23 | .idea/ 24 | *.iml 25 | out/ 26 | 27 | # gradle 28 | build/ 29 | .gradle/ 30 | gradle/ 31 | gradlew 32 | gradlew.bat 33 | gradle.properties 34 | 35 | # build 36 | lint.xml 37 | lint.html 38 | proguard-rules.txt 39 | 40 | run.sh 41 | com_crashlytics_export_strings.xml 42 | crashlytics-build.properties 43 | Mogujie4Android/libs/eventbus-2.2.1.jar 44 | 45 | # test 46 | test.html 47 | 48 | Mogujie4Android/assets/crashlytics-build.properties -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## PullRefreshLayout 2 | 3 | a pull down to Refresh Layout . 4 | 5 | 6 | support RecyclerView & ScrollView 7 | 8 | --------------------- 9 | 10 | ## how to use 11 | 12 | ``` compile 'com.pullrefreshlayout:lib:0.5.3@aar ``` 13 | 14 | ### demo 15 | 16 | RecyclerView 17 | 18 | ![Alt Text](https://github.com/6a209/PullRefreshLayout/raw/master/recyclerview.gif) 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | mavenCentral() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:1.0.1' 8 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.1' 9 | classpath 'com.github.dcendents:android-maven-plugin:1.2' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | mavenCentral() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /demo/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 20 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.pullrefresh.demo" 9 | minSdkVersion 15 10 | targetSdkVersion 20 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | 22 | 23 | repositories { 24 | mavenCentral() 25 | } 26 | 27 | 28 | dependencies { 29 | provided fileTree(dir: 'libs', include: ['*.jar']) 30 | compile project(':lib') 31 | } 32 | -------------------------------------------------------------------------------- /demo/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/6a209/dev/android/android-sdks/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 | -------------------------------------------------------------------------------- /demo/src/androidTest/java/com/pullrefresh/demo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.pullrefresh.demo; 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 | } -------------------------------------------------------------------------------- /demo/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /demo/src/main/java/com/pullrefresh/demo/DemoAct.java: -------------------------------------------------------------------------------- 1 | package com.pullrefresh.demo; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.util.Log; 8 | 9 | /** 10 | * Created by 6a209 on 14/10/29. 11 | */ 12 | public class DemoAct extends Activity{ 13 | 14 | @Override 15 | public void onCreate(Bundle bundle){ 16 | super.onCreate(bundle); 17 | setContentView(R.layout.activity_main); 18 | Log.e("DemoAct", getClassLoader().toString()); 19 | } 20 | 21 | 22 | 23 | public void toScrollAct(View view){ 24 | Intent intent = new Intent(this, ScrollViewAct.class); 25 | startActivity(intent); 26 | } 27 | 28 | public void toRecyclerAct(View view){ 29 | Intent intent = new Intent(this, RecyclerViewAct.class); 30 | startActivity(intent); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demo/src/main/java/com/pullrefresh/demo/RecyclerViewAct.java: -------------------------------------------------------------------------------- 1 | package com.pullrefresh.demo; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.LayoutInflater; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | import android.util.Log; 10 | 11 | import com.pullrefreshlayout.PullRefreshRecyclerView; 12 | import com.pullrefreshlayout.RefreshLayout; 13 | 14 | /** 15 | * Created by 6a209 on 14/10/21. 16 | */ 17 | public class RecyclerViewAct extends Activity{ 18 | 19 | @Override 20 | public void onCreate(Bundle bundle){ 21 | super.onCreate(bundle); 22 | 23 | Log.e("DemoAct", getClassLoader().toString()); 24 | String [] datas = new String[50]; 25 | for(int i = 0; i < 50; i++){ 26 | datas[i] = "it is test data " + i; 27 | } 28 | MyAdapter adapter = new MyAdapter(datas); 29 | 30 | setContentView(R.layout.recycler); 31 | 32 | final PullRefreshRecyclerView pullRefreshRecyclerView = (PullRefreshRecyclerView)findViewById(R.id.recycler); 33 | RecyclerView recyclerView = (RecyclerView)pullRefreshRecyclerView.getRefreshView(); 34 | recyclerView.setAdapter(adapter); 35 | 36 | // setContentView(pullRefreshRecyclerView); 37 | pullRefreshRecyclerView.setOnRefreshListener(new RefreshLayout.OnRefreshListener() { 38 | @Override 39 | public void onPullDown(float y) { 40 | 41 | } 42 | 43 | @Override 44 | public void onRefresh() { 45 | pullRefreshRecyclerView.postDelayed(new Runnable() { 46 | @Override 47 | public void run() { 48 | pullRefreshRecyclerView.refreshOver(null); 49 | } 50 | }, 2000); 51 | } 52 | 53 | @Override 54 | public void onRefreshOver(Object obj) { 55 | 56 | } 57 | 58 | 59 | }); 60 | } 61 | 62 | public static class ViewHolder extends RecyclerView.ViewHolder { 63 | public TextView mTextView; 64 | public ViewHolder(TextView v) { 65 | super(v); 66 | mTextView = v; 67 | } 68 | } 69 | 70 | public static class MyAdapter extends RecyclerView.Adapter { 71 | private String[] mDataset; 72 | 73 | 74 | public MyAdapter(String[] myDataset) { 75 | mDataset = myDataset; 76 | } 77 | 78 | @Override 79 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 80 | TextView v = (TextView) LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1, parent, false); 81 | ViewHolder vh = new ViewHolder(v); 82 | return vh; 83 | } 84 | 85 | 86 | @Override 87 | public void onBindViewHolder(ViewHolder holder, int position) { 88 | holder.mTextView.setText(mDataset[position]); 89 | 90 | } 91 | 92 | @Override 93 | public int getItemCount() { 94 | return mDataset.length; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /demo/src/main/java/com/pullrefresh/demo/ScrollViewAct.java: -------------------------------------------------------------------------------- 1 | package com.pullrefresh.demo; 2 | 3 | import android.app.Activity; 4 | import android.graphics.Color; 5 | import android.os.Bundle; 6 | import android.support.v4.view.ViewPager; 7 | import android.view.Gravity; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | import android.widget.ScrollView; 12 | import android.widget.TextView; 13 | 14 | import com.pullrefreshlayout.PullRefresScrollView; 15 | import com.pullrefreshlayout.RefreshLayout; 16 | 17 | 18 | public class ScrollViewAct extends Activity { 19 | 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | final PullRefresScrollView scrollView = new PullRefresScrollView(this); 24 | setContentView(scrollView); 25 | ViewPager viewPager = new ViewPager(this); 26 | 27 | TextView tv = new TextView(this); 28 | tv.setGravity(Gravity.CENTER); 29 | tv.setPadding(0, 300, 0, 300); 30 | tv.setBackgroundColor(Color.BLACK); 31 | tv.setTextSize(80); 32 | tv.setText("Hi \n Android \n here \n come \n from \n 6a209"); 33 | ((ScrollView)scrollView.getRefreshView()).addView(tv); 34 | 35 | tv.setOnClickListener(new View.OnClickListener() { 36 | @Override 37 | public void onClick(View v) { 38 | scrollView.setToRefreshing(); 39 | } 40 | }); 41 | scrollView.setOnRefreshListener(new RefreshLayout.OnRefreshListener() { 42 | @Override 43 | public void onPullDown(float y) { 44 | 45 | } 46 | 47 | @Override 48 | public void onRefresh() { 49 | scrollView.postDelayed(new Runnable() { 50 | @Override 51 | public void run() { 52 | scrollView.refreshOver(null); 53 | } 54 | }, 2000); 55 | } 56 | 57 | @Override 58 | public void onRefreshOver(Object obj) { 59 | 60 | } 61 | }); 62 | } 63 | 64 | 65 | @Override 66 | public boolean onCreateOptionsMenu(Menu menu) { 67 | // Inflate the menu; this adds items to the action bar if it is present. 68 | getMenuInflater().inflate(R.menu.menu_main, menu); 69 | return true; 70 | } 71 | 72 | @Override 73 | public boolean onOptionsItemSelected(MenuItem item) { 74 | // Handle action bar item clicks here. The action bar will 75 | // automatically handle clicks on the Home/Up button, so long 76 | // as you specify a parent activity in AndroidManifest.xml. 77 | int id = item.getItemId(); 78 | 79 | //noinspection SimplifiableIfStatement 80 | if (id == R.id.action_settings) { 81 | return true; 82 | } 83 | 84 | return super.onOptionsItemSelected(item); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /demo/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/6a209/PullRefreshLayout/74c6ca3432b26d87c11deff15c6c2482c904850b/demo/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/6a209/PullRefreshLayout/74c6ca3432b26d87c11deff15c6c2482c904850b/demo/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/6a209/PullRefreshLayout/74c6ca3432b26d87c11deff15c6c2482c904850b/demo/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xhdpi/pulltorefresh_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/6a209/PullRefreshLayout/74c6ca3432b26d87c11deff15c6c2482c904850b/demo/src/main/res/drawable-xhdpi/pulltorefresh_arrow.png -------------------------------------------------------------------------------- /demo/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/6a209/PullRefreshLayout/74c6ca3432b26d87c11deff15c6c2482c904850b/demo/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 |