├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── handmark │ │ └── pulltorefresh │ │ └── samples │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── ptr_webview2_sample.html │ ├── java │ │ └── com │ │ │ └── handmark │ │ │ └── pulltorefresh │ │ │ └── samples │ │ │ ├── LauncherActivity.java │ │ │ ├── PullToRefreshExpandableListActivity.java │ │ │ ├── PullToRefreshGridActivity.java │ │ │ ├── PullToRefreshHorizontalScrollViewActivity.java │ │ │ ├── PullToRefreshListActivity.java │ │ │ ├── PullToRefreshListFragmentActivity.java │ │ │ ├── PullToRefreshListInViewPagerActivity.java │ │ │ ├── PullToRefreshRecyclerViewListActivity.java │ │ │ ├── PullToRefreshScrollViewActivity.java │ │ │ ├── PullToRefreshViewPagerActivity.java │ │ │ ├── PullToRefreshWebView2Activity.java │ │ │ └── PullToRefreshWebViewActivity.java │ └── res │ │ ├── drawable-hdpi │ │ ├── android.png │ │ └── icon.png │ │ ├── drawable-ldpi │ │ └── icon.png │ │ ├── drawable-mdpi │ │ └── icon.png │ │ ├── drawable-nodpi │ │ └── wallpaper.jpg │ │ ├── drawable-xhdpi │ │ └── android.png │ │ ├── drawable │ │ └── icon.png │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_ptr_expandable_list.xml │ │ ├── activity_ptr_grid.xml │ │ ├── activity_ptr_horizontalscrollview.xml │ │ ├── activity_ptr_list.xml │ │ ├── activity_ptr_list_fragment.xml │ │ ├── activity_ptr_list_in_vp.xml │ │ ├── activity_ptr_recycle_list.xml │ │ ├── activity_ptr_scrollview.xml │ │ ├── activity_ptr_viewpager.xml │ │ ├── activity_ptr_webview.xml │ │ ├── activity_ptr_webview2.xml │ │ └── layout_listview_in_viewpager.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── raw │ │ ├── pull_event.mp3 │ │ ├── refreshing_sound.mp3 │ │ └── reset_sound.mp3 │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── handmark │ └── pulltorefresh │ └── samples │ └── ExampleUnitTest.java ├── build.gradle ├── extras ├── pulltorefreshlistfragment │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── lazy │ │ │ └── pulltorefreshlistfragment │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── handmark │ │ │ │ └── pulltorefresh │ │ │ │ └── extras │ │ │ │ └── listfragment │ │ │ │ ├── PullToRefreshBaseListFragment.java │ │ │ │ ├── PullToRefreshExpandableListFragment.java │ │ │ │ └── PullToRefreshListFragment.java │ │ └── res │ │ │ ├── layout │ │ │ └── need_this_for_maven.xml │ │ │ └── values │ │ │ └── strings.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── lazy │ │ └── pulltorefreshlistfragment │ │ └── ExampleUnitTest.java └── pulltorefreshviewpager │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── lazy │ │ └── pulltorefreshviewpager │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── handmark │ │ │ └── pulltorefresh │ │ │ └── extras │ │ │ └── viewpager │ │ │ └── PullToRefreshViewPager.java │ └── res │ │ ├── layout │ │ └── need_this_for_maven.xml │ │ └── values │ │ ├── ids.xml │ │ └── strings.xml │ └── test │ └── java │ └── com │ └── lazy │ └── pulltorefreshviewpager │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── lazy │ │ └── library │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── handmark │ │ │ └── pulltorefresh │ │ │ └── library │ │ │ ├── ILoadingLayout.java │ │ │ ├── IPullToRefresh.java │ │ │ ├── LoadingLayoutProxy.java │ │ │ ├── OverscrollHelper.java │ │ │ ├── PullToRefreshAdapterViewBase.java │ │ │ ├── PullToRefreshBase.java │ │ │ ├── PullToRefreshExpandableListView.java │ │ │ ├── PullToRefreshGridView.java │ │ │ ├── PullToRefreshHorizontalScrollView.java │ │ │ ├── PullToRefreshListView.java │ │ │ ├── PullToRefreshRecyclerView.java │ │ │ ├── PullToRefreshRecyclerViewAdapterViewBase.java │ │ │ ├── PullToRefreshScrollView.java │ │ │ ├── PullToRefreshWebView.java │ │ │ ├── extras │ │ │ ├── PullToRefreshWebView2.java │ │ │ └── SoundPullEventListener.java │ │ │ └── internal │ │ │ ├── EmptyViewMethodAccessor.java │ │ │ ├── FlipLoadingLayout.java │ │ │ ├── HeaderAndFooterWrapper.java │ │ │ ├── IndicatorLayout.java │ │ │ ├── LoadingLayout.java │ │ │ ├── RotateLoadingLayout.java │ │ │ ├── Utils.java │ │ │ ├── ViewCompat.java │ │ │ ├── ViewHolder.java │ │ │ └── WrapperUtils.java │ └── res │ │ ├── anim │ │ ├── slide_in_from_bottom.xml │ │ ├── slide_in_from_top.xml │ │ ├── slide_out_to_bottom.xml │ │ └── slide_out_to_top.xml │ │ ├── drawable-hdpi │ │ ├── default_ptr_flip.png │ │ ├── default_ptr_rotate.png │ │ └── indicator_arrow.png │ │ ├── drawable-mdpi │ │ ├── default_ptr_flip.png │ │ ├── default_ptr_rotate.png │ │ └── indicator_arrow.png │ │ ├── drawable-xhdpi │ │ ├── default_ptr_flip.png │ │ ├── default_ptr_rotate.png │ │ └── indicator_arrow.png │ │ ├── drawable │ │ ├── indicator_bg_bottom.xml │ │ └── indicator_bg_top.xml │ │ ├── layout │ │ ├── pull_to_refresh_header_horizontal.xml │ │ └── pull_to_refresh_header_vertical.xml │ │ ├── values-ar │ │ └── pull_refresh_strings.xml │ │ ├── values-cs │ │ └── pull_refresh_strings.xml │ │ ├── values-de │ │ └── pull_refresh_strings.xml │ │ ├── values-es │ │ └── pull_refresh_strings.xml │ │ ├── values-fi │ │ └── pull_refresh_strings.xml │ │ ├── values-fr │ │ └── pull_refresh_strings.xml │ │ ├── values-he │ │ └── pull_refresh_strings.xml │ │ ├── values-it │ │ └── pull_refresh_strings.xml │ │ ├── values-iw │ │ └── pull_refresh_strings.xml │ │ ├── values-ja │ │ └── pull_refresh_strings.xml │ │ ├── values-ko │ │ └── pull_refresh_strings.xml │ │ ├── values-nl │ │ └── pull_refresh_strings.xml │ │ ├── values-pl │ │ └── pull_refresh_strings.xml │ │ ├── values-pt-rBR │ │ └── pull_refresh_strings.xml │ │ ├── values-pt │ │ └── pull_refresh_strings.xml │ │ ├── values-ro │ │ └── pull_refresh_strings.xml │ │ ├── values-ru │ │ └── pull_refresh_strings.xml │ │ ├── values-zh │ │ └── pull_refresh_strings.xml │ │ └── values │ │ ├── attrs.xml │ │ ├── dimens.xml │ │ ├── ids.xml │ │ └── pull_refresh_strings.xml │ └── test │ └── java │ └── com │ └── lazy │ └── library │ └── ExampleUnitTest.java └── 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 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-PullToRefresh 2 | Android-PullToRefresh 复活了,一个强大的Andriod 下拉刷新框架,支持RecyclerView ,ListView... 3 | 4 | 5 | # 前言 6 | 最近想开发一个共用的下拉刷新组件,便研究研究优秀的Android-PullToRefresh, 可惜这个优秀库不维护了/(ㄒoㄒ)/~~, 7 | 所以便将它转为AndroidStudio 工程,加入了RecyclerView的支持,方便大家学习~ 8 | 9 | # Android-PullToRefresh库 github 地址 10 | [Android-PullToRefresh](https://github.com/chrisbanes/Android-PullToRefresh) 11 | 12 | --- 13 | 14 | # PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED 15 | 16 | * * * 17 | 18 | # Pull To Refresh Views for Android 19 | 20 | ![Screenshot](https://github.com/chrisbanes/Android-PullToRefresh/raw/master/header_graphic.png) 21 | 22 | This project aims to provide a reusable Pull to Refresh widget for Android. It was originally based on Johan Nilsson's [library](https://github.com/johannilsson/android-pulltorefresh) (mainly for graphics, strings and animations), but these have been replaced since. 23 | 24 | ## Features 25 | 26 | * Supports both Pulling Down from the top, and Pulling Up from the bottom (or even both). 27 | * Animated Scrolling for all devices. 28 | * Over Scroll supports for devices on Android v2.3+. 29 | * Currently works with: 30 | * **ListView** 31 | * **ExpandableListView** 32 | * **GridView** 33 | * **WebView** 34 | * **ScrollView** 35 | * **HorizontalScrollView** 36 | * **ViewPager** 37 | * Integrated End of List Listener for use of detecting when the user has scrolled to the bottom. 38 | * Maven Support. 39 | * Indicators to show the user when a Pull-to-Refresh is available. 40 | * Support for **ListFragment**! 41 | * Lots of [Customisation](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Customisation) options! 42 | 43 | Repository at . 44 | 45 | ## Sample Application 46 | The sample application (the source is in the repository) has been published onto Google Play for easy access: 47 | 48 | [![Get it on Google Play](http://www.android.com/images/brand/get_it_on_play_logo_small.png)](http://play.google.com/store/apps/details?id=com.handmark.pulltorefresh.samples) 49 | 50 | ## Usage 51 | To begin using the library, please see the [Quick Start Guide](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Quick-Start-Guide) page. 52 | 53 | ### Customisation 54 | Please see the [Customisation](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Customisation) page for more information on how to change the behaviour and look of the View. 55 | 56 | ### Pull Up to Refresh 57 | By default this library is set to Pull Down to Refresh, but if you want to allow Pulling Up to Refresh then you can do so. You can even set the View to enable both Pulling Up and Pulling Down using the 'both' setting. See the [Customisation](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Customisation) page for more information on how to set this. 58 | 59 | ## Apps 60 | Want to see which Apps are already using Android-PullToRefresh? Have a look [here](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Apps). If you have an App which is not on the list, [let me know](http://www.senab.co.uk/contact/). 61 | 62 | ## Changelog 63 | Please see the new [Changelog](https://github.com/chrisbanes/Android-PullToRefresh/wiki/Changelog) page to see what's recently changed. 64 | 65 | ## Pull Requests 66 | 67 | I will gladly accept pull requests for fixes and feature enhancements but please do them in the dev branch. The master branch is for the latest stable code, dev is where I try things out before releasing them as stable. Any pull requests that are against master from now on will be closed asking for you to do another pull against dev. 68 | 69 | ## Acknowledgments 70 | 71 | * [Stefano Dacchille](https://github.com/stefanodacchille) 72 | * [Steve Lhomme](https://github.com/robUx4) 73 | * [Maxim Galkin](https://github.com/mgalkin) 74 | * [Scorcher](https://github.com/Scorcher) 75 | 76 | 77 | ## License 78 | 79 | Copyright 2011, 2012 Chris Banes 80 | 81 | Licensed under the Apache License, Version 2.0 (the "License"); 82 | you may not use this file except in compliance with the License. 83 | You may obtain a copy of the License at 84 | 85 | http://www.apache.org/licenses/LICENSE-2.0 86 | 87 | Unless required by applicable law or agreed to in writing, software 88 | distributed under the License is distributed on an "AS IS" BASIS, 89 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 90 | See the License for the specific language governing permissions and 91 | limitations under the License. 92 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.idea 3 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "26.0.0" 6 | defaultConfig { 7 | applicationId "com.handmark.pulltorefresh.samples" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 2110 11 | versionName "2.1.1" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 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(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':library') 30 | compile project(':extras/:pulltorefreshlistfragment') 31 | compile project(':extras/:pulltorefreshviewpager') 32 | } 33 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/system/MyDevFiles/Android-SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/handmark/pulltorefresh/samples/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.samples; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.handmark.pulltorefresh.samples", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 23 | 26 | 29 | 32 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /app/src/main/assets/ptr_webview2_sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | PullToRefreshWebView2 Sample 4 | 5 | 17 | 18 | 19 | 20 | 21 |

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sollicitudin mauris varius lacus 22 | porttitor eget blandit massa facilisis. Nulla pellentesque odio sed purus fermentum vitae 23 | viverra orci faucibus. Sed ullamcorper condimentum vulputate. Curabitur sit amet convallis 24 | velit. Vestibulum posuere eleifend risus ac adipiscing. Nam pulvinar nulla a velit faucibus 25 | imperdiet. Praesent eget nisi ac justo blandit sagittis. Maecenas at leo nisi, nec varius 26 | nisl.

27 |

In hac habitasse platea dictumst. Morbi neque tortor, vestibulum sed viverra a, luctus vel lorem. 28 | Nunc turpis eros, varius eget commodo et, euismod at eros. Sed tincidunt mi purus, vel posuere 29 | dui. Vestibulum ante lectus, porta sed mattis bibendum, scelerisque cursus sapien. Cras ultrices 30 | imperdiet fermentum. Aenean nisi nulla, euismod non blandit ac, dictum quis libero. Morbi 31 | consectetur tempor mollis. Suspendisse eget nunc arcu, vel ullamcorper augue. Integer malesuada, 32 | diam nec faucibus mollis, nisl velit euismod enim, ac mattis justo neque sit amet mauris. 33 | Vivamus pretium imperdiet pharetra.

34 |

Integer sagittis augue sit amet lectus pulvinar sit amet commodo tortor mattis. Maecenas quis 35 | tellus eget ante eleifend sollicitudin non et nibh. Maecenas luctus euismod tristique. Fusce in 36 | odio nec diam blandit facilisis. Sed nec arcu eros. Vivamus quis tortor a metus tempus aliquam 37 | eget volutpat magna. Pellentesque id ultrices dolor. Sed blandit aliquet quam. Phasellus dapibus 38 | euismod vulputate. Aenean blandit, elit vitae vestibulum tincidunt, metus dui accumsan nulla, 39 | sit amet vehicula mauris lacus in est. Etiam dignissim pellentesque nulla vel malesuada. Cras 40 | vel lorem justo.

41 |

Sed condimentum nisl sit amet libero vestibulum hendrerit. Duis auctor tempus placerat. Proin 42 | velit ante, ornare nec dictum nec, hendrerit eu arcu. Etiam ut diam ornare quam venenatis 43 | pulvinar vitae vel leo. Vivamus consectetur, ante id interdum rhoncus, magna eros pulvinar 44 | lacus, a gravida nibh arcu vitae eros. Nulla scelerisque laoreet feugiat. Mauris sit amet 45 | gravida felis.

46 |

Nulla ac dolor sapien, vestibulum venenatis justo. Cras placerat velit vitae nibh pellentesque 47 | ultricies. Suspendisse adipiscing enim eu justo iaculis eu pretium urna fermentum. Duis 48 | porttitor nunc non nunc mattis vestibulum. Etiam elit tellus, feugiat in bibendum eget, 49 | adipiscing nec metus. Ut ut sem lacus, quis faucibus diam. Curabitur a nulla fermentum tortor 50 | dignissim posuere. Fusce faucibus ante ut sem imperdiet imperdiet eget vitae lorem. Etiam 51 | fringilla ornare ipsum, in sagittis quam ornare vitae. Nullam venenatis orci sit amet sapien 52 | adipiscing gravida. Proin turpis lectus, hendrerit vitae vehicula ut, auctor ac lectus. 53 | Pellentesque sollicitudin blandit ligula quis commodo. Mauris vulputate lectus in velit luctus 54 | aliquam. Quisque eget tincidunt elit. Quisque et augue quam, sed scelerisque eros.

55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/LauncherActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.ListActivity; 19 | import android.content.Intent; 20 | import android.os.Bundle; 21 | import android.view.View; 22 | import android.widget.ArrayAdapter; 23 | import android.widget.ListView; 24 | 25 | public class LauncherActivity extends ListActivity { 26 | 27 | public static final String[] options = {"RecyclerView", "ListView", "ExpandableListView", "GridView", "WebView", "ScrollView", 28 | "Horizontal ScrollView", "ViewPager", "ListView Fragment", "WebView Advanced", "ListView in ViewPager"}; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, options)); 34 | } 35 | 36 | @Override 37 | protected void onListItemClick(ListView l, View v, int position, long id) { 38 | Intent intent; 39 | 40 | switch (position) { 41 | default: 42 | case 0: 43 | intent = new Intent(this, PullToRefreshRecyclerViewListActivity.class); 44 | break; 45 | case 1: 46 | intent = new Intent(this, PullToRefreshListActivity.class); 47 | break; 48 | case 2: 49 | intent = new Intent(this, PullToRefreshExpandableListActivity.class); 50 | break; 51 | case 3: 52 | intent = new Intent(this, PullToRefreshGridActivity.class); 53 | break; 54 | case 4: 55 | intent = new Intent(this, PullToRefreshWebViewActivity.class); 56 | break; 57 | case 5: 58 | intent = new Intent(this, PullToRefreshScrollViewActivity.class); 59 | break; 60 | case 6: 61 | intent = new Intent(this, PullToRefreshHorizontalScrollViewActivity.class); 62 | break; 63 | case 7: 64 | intent = new Intent(this, PullToRefreshViewPagerActivity.class); 65 | break; 66 | case 8: 67 | intent = new Intent(this, PullToRefreshListFragmentActivity.class); 68 | break; 69 | case 9: 70 | intent = new Intent(this, PullToRefreshWebView2Activity.class); 71 | break; 72 | case 10: 73 | intent = new Intent(this, PullToRefreshListInViewPagerActivity.class); 74 | break; 75 | } 76 | 77 | startActivity(intent); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshExpandableListActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.ExpandableListActivity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.widget.ExpandableListView; 22 | import android.widget.SimpleExpandableListAdapter; 23 | 24 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 25 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 26 | import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView; 27 | 28 | import java.util.ArrayList; 29 | import java.util.HashMap; 30 | import java.util.List; 31 | import java.util.Map; 32 | 33 | public final class PullToRefreshExpandableListActivity extends ExpandableListActivity { 34 | private static final String KEY = "key"; 35 | 36 | private List> groupData = new ArrayList>(); 37 | private List>> childData = new ArrayList>>(); 38 | 39 | private PullToRefreshExpandableListView mPullRefreshListView; 40 | private SimpleExpandableListAdapter mAdapter; 41 | 42 | /** Called when the activity is first created. */ 43 | @Override 44 | public void onCreate(Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_ptr_expandable_list); 47 | 48 | mPullRefreshListView = (PullToRefreshExpandableListView) findViewById(R.id.pull_refresh_expandable_list); 49 | 50 | // Set a listener to be invoked when the list should be refreshed. 51 | mPullRefreshListView.setOnRefreshListener(new OnRefreshListener() { 52 | @Override 53 | public void onRefresh(PullToRefreshBase refreshView) { 54 | // Do work to refresh the list here. 55 | new GetDataTask().execute(); 56 | } 57 | }); 58 | 59 | for (String group : mGroupStrings) { 60 | Map groupMap1 = new HashMap(); 61 | groupData.add(groupMap1); 62 | groupMap1.put(KEY, group); 63 | 64 | List> childList = new ArrayList>(); 65 | for (String string : mChildStrings) { 66 | Map childMap = new HashMap(); 67 | childList.add(childMap); 68 | childMap.put(KEY, string); 69 | } 70 | childData.add(childList); 71 | } 72 | 73 | mAdapter = new SimpleExpandableListAdapter(this, groupData, android.R.layout.simple_expandable_list_item_1, 74 | new String[]{KEY}, new int[]{android.R.id.text1}, childData, 75 | android.R.layout.simple_expandable_list_item_2, new String[]{KEY}, new int[]{android.R.id.text1}); 76 | setListAdapter(mAdapter); 77 | } 78 | 79 | private class GetDataTask extends AsyncTask { 80 | 81 | @Override 82 | protected String[] doInBackground(Void... params) { 83 | // Simulates a background job. 84 | try { 85 | Thread.sleep(2000); 86 | } catch (InterruptedException e) { 87 | } 88 | return mChildStrings; 89 | } 90 | 91 | @Override 92 | protected void onPostExecute(String[] result) { 93 | Map newMap = new HashMap(); 94 | newMap.put(KEY, "Added after refresh..."); 95 | groupData.add(newMap); 96 | 97 | List> childList = new ArrayList>(); 98 | for (String string : mChildStrings) { 99 | Map childMap = new HashMap(); 100 | childMap.put(KEY, string); 101 | childList.add(childMap); 102 | } 103 | childData.add(childList); 104 | 105 | mAdapter.notifyDataSetChanged(); 106 | 107 | // Call onRefreshComplete when the list has been refreshed. 108 | mPullRefreshListView.onRefreshComplete(); 109 | 110 | super.onPostExecute(result); 111 | } 112 | } 113 | 114 | private String[] mChildStrings = {"Child One", "Child Two", "Child Three", "Child Four", "Child Five", "Child Six"}; 115 | 116 | private String[] mGroupStrings = {"Group One", "Group Two", "Group Three"}; 117 | } 118 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshGridActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.view.Gravity; 22 | import android.view.Menu; 23 | import android.view.MenuItem; 24 | import android.widget.ArrayAdapter; 25 | import android.widget.GridView; 26 | import android.widget.TextView; 27 | import android.widget.Toast; 28 | 29 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 30 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode; 31 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2; 32 | import com.handmark.pulltorefresh.library.PullToRefreshGridView; 33 | 34 | import java.util.Arrays; 35 | import java.util.LinkedList; 36 | 37 | public final class PullToRefreshGridActivity extends Activity { 38 | 39 | static final int MENU_SET_MODE = 0; 40 | 41 | private LinkedList mListItems; 42 | private PullToRefreshGridView mPullRefreshGridView; 43 | private GridView mGridView; 44 | private ArrayAdapter mAdapter; 45 | 46 | /** Called when the activity is first created. */ 47 | @Override 48 | public void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | setContentView(R.layout.activity_ptr_grid); 51 | 52 | mPullRefreshGridView = (PullToRefreshGridView) findViewById(R.id.pull_refresh_grid); 53 | mGridView = mPullRefreshGridView.getRefreshableView(); 54 | 55 | // Set a listener to be invoked when the list should be refreshed. 56 | mPullRefreshGridView.setOnRefreshListener(new OnRefreshListener2() { 57 | 58 | @Override 59 | public void onPullDownToRefresh(PullToRefreshBase refreshView) { 60 | Toast.makeText(PullToRefreshGridActivity.this, "Pull Down!", Toast.LENGTH_SHORT).show(); 61 | new GetDataTask().execute(); 62 | } 63 | 64 | @Override 65 | public void onPullUpToRefresh(PullToRefreshBase refreshView) { 66 | Toast.makeText(PullToRefreshGridActivity.this, "Pull Up!", Toast.LENGTH_SHORT).show(); 67 | new GetDataTask().execute(); 68 | } 69 | 70 | }); 71 | 72 | mListItems = new LinkedList(); 73 | 74 | TextView tv = new TextView(this); 75 | tv.setGravity(Gravity.CENTER); 76 | tv.setText("Empty View, Pull Down/Up to Add Items"); 77 | mPullRefreshGridView.setEmptyView(tv); 78 | 79 | mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mListItems); 80 | mGridView.setAdapter(mAdapter); 81 | } 82 | 83 | private class GetDataTask extends AsyncTask { 84 | 85 | @Override 86 | protected String[] doInBackground(Void... params) { 87 | // Simulates a background job. 88 | try { 89 | Thread.sleep(2000); 90 | } catch (InterruptedException e) { 91 | } 92 | return mStrings; 93 | } 94 | 95 | @Override 96 | protected void onPostExecute(String[] result) { 97 | mListItems.addFirst("Added after refresh..."); 98 | mListItems.addAll(Arrays.asList(result)); 99 | mAdapter.notifyDataSetChanged(); 100 | 101 | // Call onRefreshComplete when the list has been refreshed. 102 | mPullRefreshGridView.onRefreshComplete(); 103 | 104 | super.onPostExecute(result); 105 | } 106 | } 107 | 108 | @Override 109 | public boolean onCreateOptionsMenu(Menu menu) { 110 | menu.add(0, MENU_SET_MODE, 0, 111 | mPullRefreshGridView.getMode() == Mode.BOTH ? "Change to MODE_PULL_DOWN" 112 | : "Change to MODE_PULL_BOTH"); 113 | return super.onCreateOptionsMenu(menu); 114 | } 115 | 116 | @Override 117 | public boolean onPrepareOptionsMenu(Menu menu) { 118 | MenuItem setModeItem = menu.findItem(MENU_SET_MODE); 119 | setModeItem.setTitle(mPullRefreshGridView.getMode() == Mode.BOTH ? "Change to MODE_PULL_FROM_START" 120 | : "Change to MODE_PULL_BOTH"); 121 | 122 | return super.onPrepareOptionsMenu(menu); 123 | } 124 | 125 | @Override 126 | public boolean onOptionsItemSelected(MenuItem item) { 127 | switch (item.getItemId()) { 128 | case MENU_SET_MODE: 129 | mPullRefreshGridView 130 | .setMode(mPullRefreshGridView.getMode() == Mode.BOTH ? Mode.PULL_FROM_START 131 | : Mode.BOTH); 132 | break; 133 | } 134 | 135 | return super.onOptionsItemSelected(item); 136 | } 137 | 138 | private String[] mStrings = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 139 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 140 | "Allgauer Emmentaler"}; 141 | } 142 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshHorizontalScrollViewActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.widget.HorizontalScrollView; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 24 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 25 | import com.handmark.pulltorefresh.library.PullToRefreshHorizontalScrollView; 26 | 27 | public final class PullToRefreshHorizontalScrollViewActivity extends Activity { 28 | 29 | PullToRefreshHorizontalScrollView mPullRefreshScrollView; 30 | HorizontalScrollView mScrollView; 31 | 32 | /** Called when the activity is first created. */ 33 | @Override 34 | public void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_ptr_horizontalscrollview); 37 | 38 | mPullRefreshScrollView = (PullToRefreshHorizontalScrollView) findViewById(R.id.pull_refresh_horizontalscrollview); 39 | mPullRefreshScrollView.setOnRefreshListener(new OnRefreshListener() { 40 | 41 | @Override 42 | public void onRefresh(PullToRefreshBase refreshView) { 43 | new GetDataTask().execute(); 44 | } 45 | }); 46 | 47 | mScrollView = mPullRefreshScrollView.getRefreshableView(); 48 | } 49 | 50 | private class GetDataTask extends AsyncTask { 51 | 52 | @Override 53 | protected String[] doInBackground(Void... params) { 54 | // Simulates a background job. 55 | try { 56 | Thread.sleep(4000); 57 | } catch (InterruptedException e) { 58 | } 59 | return null; 60 | } 61 | 62 | @Override 63 | protected void onPostExecute(String[] result) { 64 | // Do some stuff here 65 | 66 | // Call onRefreshComplete when the list has been refreshed. 67 | mPullRefreshScrollView.onRefreshComplete(); 68 | 69 | super.onPostExecute(result); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshListActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.ListActivity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.text.format.DateUtils; 22 | import android.view.ContextMenu; 23 | import android.view.ContextMenu.ContextMenuInfo; 24 | import android.view.Menu; 25 | import android.view.MenuItem; 26 | import android.view.View; 27 | import android.widget.AdapterView.AdapterContextMenuInfo; 28 | import android.widget.ArrayAdapter; 29 | import android.widget.ListView; 30 | import android.widget.Toast; 31 | 32 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 33 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode; 34 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnLastItemVisibleListener; 35 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 36 | import com.handmark.pulltorefresh.library.PullToRefreshBase.State; 37 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 38 | import com.handmark.pulltorefresh.library.extras.SoundPullEventListener; 39 | 40 | import java.util.Arrays; 41 | import java.util.LinkedList; 42 | 43 | public final class PullToRefreshListActivity extends ListActivity { 44 | 45 | static final int MENU_MANUAL_REFRESH = 0; 46 | static final int MENU_DISABLE_SCROLL = 1; 47 | static final int MENU_SET_MODE = 2; 48 | static final int MENU_DEMO = 3; 49 | 50 | private LinkedList mListItems; 51 | private PullToRefreshListView mPullRefreshListView; 52 | private ArrayAdapter mAdapter; 53 | 54 | /** Called when the activity is first created. */ 55 | @Override 56 | public void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | setContentView(R.layout.activity_ptr_list); 59 | 60 | mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.pull_refresh_list); 61 | 62 | // Set a listener to be invoked when the list should be refreshed. 63 | mPullRefreshListView.setOnRefreshListener(new OnRefreshListener() { 64 | @Override 65 | public void onRefresh(PullToRefreshBase refreshView) { 66 | String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), 67 | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); 68 | 69 | // Update the LastUpdatedLabel 70 | refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label); 71 | 72 | // Do work to refresh the list here. 73 | new GetDataTask().execute(); 74 | } 75 | }); 76 | 77 | // Add an end-of-list listener 78 | mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() { 79 | 80 | @Override 81 | public void onLastItemVisible() { 82 | Toast.makeText(PullToRefreshListActivity.this, "End of List!", Toast.LENGTH_SHORT).show(); 83 | } 84 | }); 85 | 86 | ListView actualListView = mPullRefreshListView.getRefreshableView(); 87 | 88 | // Need to use the Actual ListView when registering for Context Menu 89 | registerForContextMenu(actualListView); 90 | 91 | mListItems = new LinkedList(); 92 | mListItems.addAll(Arrays.asList(mStrings)); 93 | 94 | mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mListItems); 95 | 96 | /** 97 | * Add Sound Event Listener 98 | */ 99 | SoundPullEventListener soundListener = new SoundPullEventListener(this); 100 | soundListener.addSoundEvent(State.PULL_TO_REFRESH, R.raw.pull_event); 101 | soundListener.addSoundEvent(State.RESET, R.raw.reset_sound); 102 | soundListener.addSoundEvent(State.REFRESHING, R.raw.refreshing_sound); 103 | mPullRefreshListView.setOnPullEventListener(soundListener); 104 | 105 | // You can also just use setListAdapter(mAdapter) or 106 | // mPullRefreshListView.setAdapter(mAdapter) 107 | actualListView.setAdapter(mAdapter); 108 | } 109 | 110 | private class GetDataTask extends AsyncTask { 111 | 112 | @Override 113 | protected String[] doInBackground(Void... params) { 114 | // Simulates a background job. 115 | try { 116 | Thread.sleep(4000); 117 | } catch (InterruptedException e) { 118 | } 119 | return mStrings; 120 | } 121 | 122 | @Override 123 | protected void onPostExecute(String[] result) { 124 | mListItems.addFirst("Added after refresh..."); 125 | mAdapter.notifyDataSetChanged(); 126 | 127 | // Call onRefreshComplete when the list has been refreshed. 128 | mPullRefreshListView.onRefreshComplete(); 129 | 130 | super.onPostExecute(result); 131 | } 132 | } 133 | 134 | @Override 135 | public boolean onCreateOptionsMenu(Menu menu) { 136 | menu.add(0, MENU_MANUAL_REFRESH, 0, "Manual Refresh"); 137 | menu.add(0, MENU_DISABLE_SCROLL, 1, 138 | mPullRefreshListView.isScrollingWhileRefreshingEnabled() ? "Disable Scrolling while Refreshing" 139 | : "Enable Scrolling while Refreshing"); 140 | menu.add(0, MENU_SET_MODE, 0, mPullRefreshListView.getMode() == Mode.BOTH ? "Change to MODE_PULL_DOWN" 141 | : "Change to MODE_PULL_BOTH"); 142 | menu.add(0, MENU_DEMO, 0, "Demo"); 143 | return super.onCreateOptionsMenu(menu); 144 | } 145 | 146 | @Override 147 | public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { 148 | AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; 149 | 150 | menu.setHeaderTitle("Item: " + getListView().getItemAtPosition(info.position)); 151 | menu.add("Item 1"); 152 | menu.add("Item 2"); 153 | menu.add("Item 3"); 154 | menu.add("Item 4"); 155 | 156 | super.onCreateContextMenu(menu, v, menuInfo); 157 | } 158 | 159 | @Override 160 | public boolean onPrepareOptionsMenu(Menu menu) { 161 | MenuItem disableItem = menu.findItem(MENU_DISABLE_SCROLL); 162 | disableItem 163 | .setTitle(mPullRefreshListView.isScrollingWhileRefreshingEnabled() ? "Disable Scrolling while Refreshing" 164 | : "Enable Scrolling while Refreshing"); 165 | 166 | MenuItem setModeItem = menu.findItem(MENU_SET_MODE); 167 | setModeItem.setTitle(mPullRefreshListView.getMode() == Mode.BOTH ? "Change to MODE_FROM_START" 168 | : "Change to MODE_PULL_BOTH"); 169 | 170 | return super.onPrepareOptionsMenu(menu); 171 | } 172 | 173 | @Override 174 | public boolean onOptionsItemSelected(MenuItem item) { 175 | 176 | switch (item.getItemId()) { 177 | case MENU_MANUAL_REFRESH: 178 | new GetDataTask().execute(); 179 | mPullRefreshListView.setRefreshing(false); 180 | break; 181 | case MENU_DISABLE_SCROLL: 182 | mPullRefreshListView.setScrollingWhileRefreshingEnabled(!mPullRefreshListView 183 | .isScrollingWhileRefreshingEnabled()); 184 | break; 185 | case MENU_SET_MODE: 186 | mPullRefreshListView.setMode(mPullRefreshListView.getMode() == Mode.BOTH ? Mode.PULL_FROM_START 187 | : Mode.BOTH); 188 | break; 189 | case MENU_DEMO: 190 | mPullRefreshListView.demo(); 191 | break; 192 | } 193 | 194 | return super.onOptionsItemSelected(item); 195 | } 196 | 197 | private String[] mStrings = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 198 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 199 | "Allgauer Emmentaler", "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 200 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 201 | "Allgauer Emmentaler"}; 202 | } 203 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshListFragmentActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.os.AsyncTask; 19 | import android.os.Bundle; 20 | import android.support.v4.app.FragmentActivity; 21 | import android.widget.ArrayAdapter; 22 | import android.widget.ListView; 23 | 24 | import com.handmark.pulltorefresh.extras.listfragment.PullToRefreshListFragment; 25 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 26 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 27 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 28 | 29 | import java.util.Arrays; 30 | import java.util.LinkedList; 31 | 32 | public final class PullToRefreshListFragmentActivity extends FragmentActivity implements OnRefreshListener { 33 | 34 | private LinkedList mListItems; 35 | private ArrayAdapter mAdapter; 36 | 37 | private PullToRefreshListFragment mPullRefreshListFragment; 38 | private PullToRefreshListView mPullRefreshListView; 39 | 40 | /** Called when the activity is first created. */ 41 | @Override 42 | public void onCreate(Bundle savedInstanceState) { 43 | super.onCreate(savedInstanceState); 44 | setContentView(R.layout.activity_ptr_list_fragment); 45 | 46 | mPullRefreshListFragment = (PullToRefreshListFragment) getSupportFragmentManager().findFragmentById( 47 | R.id.frag_ptr_list); 48 | 49 | // Get PullToRefreshListView from Fragment 50 | mPullRefreshListView = mPullRefreshListFragment.getPullToRefreshListView(); 51 | 52 | // Set a listener to be invoked when the list should be refreshed. 53 | mPullRefreshListView.setOnRefreshListener(this); 54 | 55 | // You can also just use mPullRefreshListFragment.getListView() 56 | ListView actualListView = mPullRefreshListView.getRefreshableView(); 57 | 58 | mListItems = new LinkedList(); 59 | mListItems.addAll(Arrays.asList(mStrings)); 60 | mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mListItems); 61 | 62 | // You can also just use setListAdapter(mAdapter) or 63 | // mPullRefreshListView.setAdapter(mAdapter) 64 | actualListView.setAdapter(mAdapter); 65 | 66 | mPullRefreshListFragment.setListShown(true); 67 | } 68 | 69 | @Override 70 | public void onRefresh(PullToRefreshBase refreshView) { 71 | // Do work to refresh the list here. 72 | new GetDataTask().execute(); 73 | } 74 | 75 | private class GetDataTask extends AsyncTask { 76 | 77 | @Override 78 | protected String[] doInBackground(Void... params) { 79 | // Simulates a background job. 80 | try { 81 | Thread.sleep(4000); 82 | } catch (InterruptedException e) { 83 | } 84 | return mStrings; 85 | } 86 | 87 | @Override 88 | protected void onPostExecute(String[] result) { 89 | mListItems.addFirst("Added after refresh..."); 90 | mAdapter.notifyDataSetChanged(); 91 | 92 | // Call onRefreshComplete when the list has been refreshed. 93 | mPullRefreshListView.onRefreshComplete(); 94 | 95 | super.onPostExecute(result); 96 | } 97 | } 98 | 99 | private String[] mStrings = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 100 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 101 | "Allgauer Emmentaler", "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 102 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 103 | "Allgauer Emmentaler"}; 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshListInViewPagerActivity.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.samples; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.os.AsyncTask; 6 | import android.os.Bundle; 7 | import android.support.v4.view.PagerAdapter; 8 | import android.support.v4.view.ViewPager; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.ViewGroup.LayoutParams; 13 | import android.widget.ArrayAdapter; 14 | import android.widget.ListAdapter; 15 | import android.widget.ListView; 16 | 17 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 18 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 19 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 20 | 21 | import java.util.Arrays; 22 | 23 | public class PullToRefreshListInViewPagerActivity extends Activity implements OnRefreshListener { 24 | 25 | private static final String[] STRINGS = {"Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", 26 | "Ackawi", "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 27 | "Allgauer Emmentaler", "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi", 28 | "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale", "Aisy Cendre", 29 | "Allgauer Emmentaler"}; 30 | 31 | private ViewPager mViewPager; 32 | 33 | @Override 34 | protected void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_ptr_list_in_vp); 37 | 38 | mViewPager = (ViewPager) findViewById(R.id.vp_list); 39 | mViewPager.setAdapter(new ListViewPagerAdapter()); 40 | } 41 | 42 | private class ListViewPagerAdapter extends PagerAdapter { 43 | 44 | @Override 45 | public View instantiateItem(ViewGroup container, int position) { 46 | Context context = container.getContext(); 47 | 48 | PullToRefreshListView plv = (PullToRefreshListView) LayoutInflater.from(context).inflate( 49 | R.layout.layout_listview_in_viewpager, container, false); 50 | 51 | ListAdapter adapter = new ArrayAdapter(context, android.R.layout.simple_list_item_1, 52 | Arrays.asList(STRINGS)); 53 | plv.setAdapter(adapter); 54 | 55 | plv.setOnRefreshListener(PullToRefreshListInViewPagerActivity.this); 56 | 57 | // Now just add ListView to ViewPager and return it 58 | container.addView(plv, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 59 | 60 | return plv; 61 | } 62 | 63 | @Override 64 | public void destroyItem(ViewGroup container, int position, Object object) { 65 | container.removeView((View) object); 66 | } 67 | 68 | @Override 69 | public boolean isViewFromObject(View view, Object object) { 70 | return view == object; 71 | } 72 | 73 | @Override 74 | public int getCount() { 75 | return 3; 76 | } 77 | 78 | } 79 | 80 | @Override 81 | public void onRefresh(PullToRefreshBase refreshView) { 82 | new GetDataTask(refreshView).execute(); 83 | } 84 | 85 | private static class GetDataTask extends AsyncTask { 86 | 87 | PullToRefreshBase mRefreshedView; 88 | 89 | public GetDataTask(PullToRefreshBase refreshedView) { 90 | mRefreshedView = refreshedView; 91 | } 92 | 93 | @Override 94 | protected Void doInBackground(Void... params) { 95 | // Simulates a background job. 96 | try { 97 | Thread.sleep(4000); 98 | } catch (InterruptedException e) { 99 | } 100 | return null; 101 | } 102 | 103 | @Override 104 | protected void onPostExecute(Void result) { 105 | mRefreshedView.onRefreshComplete(); 106 | super.onPostExecute(result); 107 | } 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshScrollViewActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.widget.ScrollView; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 24 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 25 | import com.handmark.pulltorefresh.library.PullToRefreshScrollView; 26 | 27 | public final class PullToRefreshScrollViewActivity extends Activity { 28 | 29 | PullToRefreshScrollView mPullRefreshScrollView; 30 | ScrollView mScrollView; 31 | 32 | /** Called when the activity is first created. */ 33 | @Override 34 | public void onCreate(Bundle savedInstanceState) { 35 | super.onCreate(savedInstanceState); 36 | setContentView(R.layout.activity_ptr_scrollview); 37 | 38 | mPullRefreshScrollView = (PullToRefreshScrollView) findViewById(R.id.pull_refresh_scrollview); 39 | mPullRefreshScrollView.setOnRefreshListener(new OnRefreshListener() { 40 | 41 | @Override 42 | public void onRefresh(PullToRefreshBase refreshView) { 43 | new GetDataTask().execute(); 44 | } 45 | }); 46 | 47 | mScrollView = mPullRefreshScrollView.getRefreshableView(); 48 | } 49 | 50 | private class GetDataTask extends AsyncTask { 51 | 52 | @Override 53 | protected String[] doInBackground(Void... params) { 54 | // Simulates a background job. 55 | try { 56 | Thread.sleep(4000); 57 | } catch (InterruptedException e) { 58 | } 59 | return null; 60 | } 61 | 62 | @Override 63 | protected void onPostExecute(String[] result) { 64 | // Do some stuff here 65 | 66 | // Call onRefreshComplete when the list has been refreshed. 67 | mPullRefreshScrollView.onRefreshComplete(); 68 | 69 | super.onPostExecute(result); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshViewPagerActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.AsyncTask; 20 | import android.os.Bundle; 21 | import android.support.v4.view.PagerAdapter; 22 | import android.support.v4.view.ViewPager; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.view.ViewGroup.LayoutParams; 26 | import android.widget.ImageView; 27 | 28 | import com.handmark.pulltorefresh.extras.viewpager.PullToRefreshViewPager; 29 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 30 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 31 | 32 | public class PullToRefreshViewPagerActivity extends Activity implements OnRefreshListener { 33 | 34 | private PullToRefreshViewPager mPullToRefreshViewPager; 35 | 36 | @Override 37 | public void onCreate(Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | setContentView(R.layout.activity_ptr_viewpager); 40 | 41 | mPullToRefreshViewPager = (PullToRefreshViewPager) findViewById(R.id.pull_refresh_viewpager); 42 | mPullToRefreshViewPager.setOnRefreshListener(this); 43 | 44 | ViewPager vp = mPullToRefreshViewPager.getRefreshableView(); 45 | vp.setAdapter(new SamplePagerAdapter()); 46 | } 47 | 48 | @Override 49 | public void onRefresh(PullToRefreshBase refreshView) { 50 | new GetDataTask().execute(); 51 | } 52 | 53 | static class SamplePagerAdapter extends PagerAdapter { 54 | 55 | private static int[] sDrawables = {R.drawable.wallpaper, R.drawable.wallpaper, R.drawable.wallpaper, 56 | R.drawable.wallpaper, R.drawable.wallpaper, R.drawable.wallpaper}; 57 | 58 | @Override 59 | public int getCount() { 60 | return sDrawables.length; 61 | } 62 | 63 | @Override 64 | public View instantiateItem(ViewGroup container, int position) { 65 | ImageView imageView = new ImageView(container.getContext()); 66 | imageView.setImageResource(sDrawables[position]); 67 | 68 | // Now just add ImageView to ViewPager and return it 69 | container.addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 70 | 71 | return imageView; 72 | } 73 | 74 | @Override 75 | public void destroyItem(ViewGroup container, int position, Object object) { 76 | container.removeView((View) object); 77 | } 78 | 79 | @Override 80 | public boolean isViewFromObject(View view, Object object) { 81 | return view == object; 82 | } 83 | } 84 | 85 | private class GetDataTask extends AsyncTask { 86 | 87 | @Override 88 | protected Void doInBackground(Void... params) { 89 | // Simulates a background job. 90 | try { 91 | Thread.sleep(4000); 92 | } catch (InterruptedException e) { 93 | } 94 | return null; 95 | } 96 | 97 | @Override 98 | protected void onPostExecute(Void result) { 99 | mPullToRefreshViewPager.onRefreshComplete(); 100 | super.onPostExecute(result); 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshWebView2Activity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.Bundle; 20 | import android.webkit.WebView; 21 | import android.webkit.WebViewClient; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 24 | import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener; 25 | import com.handmark.pulltorefresh.library.extras.PullToRefreshWebView2; 26 | 27 | public final class PullToRefreshWebView2Activity extends Activity implements OnRefreshListener { 28 | 29 | /** Called when the activity is first created. */ 30 | @Override 31 | public void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_ptr_webview2); 34 | 35 | PullToRefreshWebView2 pullRefreshWebView = (PullToRefreshWebView2) findViewById(R.id.pull_refresh_webview2); 36 | pullRefreshWebView.setOnRefreshListener(this); 37 | 38 | WebView webView = pullRefreshWebView.getRefreshableView(); 39 | webView.getSettings().setJavaScriptEnabled(true); 40 | webView.setWebViewClient(new SampleWebViewClient()); 41 | 42 | // We just load a prepared HTML page from the assets folder for this 43 | // sample, see that file for the Javascript implementation 44 | webView.loadUrl("file:///android_asset/ptr_webview2_sample.html"); 45 | } 46 | 47 | private static class SampleWebViewClient extends WebViewClient { 48 | @Override 49 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 50 | view.loadUrl(url); 51 | return true; 52 | } 53 | } 54 | 55 | @Override 56 | public void onRefresh(final PullToRefreshBase refreshView) { 57 | // This is very contrived example, we just wait 2 seconds, then call 58 | // onRefreshComplete() 59 | refreshView.postDelayed(new Runnable() { 60 | @Override 61 | public void run() { 62 | refreshView.onRefreshComplete(); 63 | } 64 | }, 2 * 1000); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/handmark/pulltorefresh/samples/PullToRefreshWebViewActivity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.samples; 17 | 18 | import android.app.Activity; 19 | import android.os.Bundle; 20 | import android.webkit.WebView; 21 | import android.webkit.WebViewClient; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshWebView; 24 | 25 | public final class PullToRefreshWebViewActivity extends Activity { 26 | 27 | PullToRefreshWebView mPullRefreshWebView; 28 | WebView mWebView; 29 | 30 | /** Called when the activity is first created. */ 31 | @Override 32 | public void onCreate(Bundle savedInstanceState) { 33 | super.onCreate(savedInstanceState); 34 | setContentView(R.layout.activity_ptr_webview); 35 | 36 | mPullRefreshWebView = (PullToRefreshWebView) findViewById(R.id.pull_refresh_webview); 37 | mWebView = mPullRefreshWebView.getRefreshableView(); 38 | 39 | mWebView.getSettings().setJavaScriptEnabled(true); 40 | mWebView.setWebViewClient(new SampleWebViewClient()); 41 | mWebView.loadUrl("http://www.google.com"); 42 | 43 | } 44 | 45 | private static class SampleWebViewClient extends WebViewClient { 46 | @Override 47 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 48 | view.loadUrl(url); 49 | return true; 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-hdpi/android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-nodpi/wallpaper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-nodpi/wallpaper.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable-xhdpi/android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/drawable/icon.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_expandable_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_horizontalscrollview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 15 | 16 | 20 | 21 | 26 | 27 | 32 | 33 | 38 | 39 | 44 | 45 | 50 | 51 | 56 | 57 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_list_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_list_in_vp.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_recycle_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_scrollview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 15 | 16 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_viewpager.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_webview.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_ptr_webview2.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_listview_in_viewpager.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/raw/pull_event.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/raw/pull_event.mp3 -------------------------------------------------------------------------------- /app/src/main/res/raw/refreshing_sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/raw/refreshing_sound.mp3 -------------------------------------------------------------------------------- /app/src/main/res/raw/reset_sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/app/src/main/res/raw/reset_sound.mp3 -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World, PullToRefreshActivity! 5 | pulltorefreshexample 6 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sollicitudin mauris varius lacus porttitor eget blandit massa facilisis. Nulla pellentesque odio sed purus fermentum vitae viverra orci faucibus. Sed ullamcorper condimentum vulputate. Curabitur sit amet convallis velit. Vestibulum posuere eleifend risus ac adipiscing. Nam pulvinar nulla a velit faucibus imperdiet. Praesent eget nisi ac justo blandit sagittis. Maecenas at leo nisi, nec varius nisl.\nIn hac habitasse platea dictumst. Morbi neque tortor, vestibulum sed viverra a, luctus vel lorem. Nunc turpis eros, varius eget commodo et, euismod at eros. Sed tincidunt mi purus, vel posuere dui. Vestibulum ante lectus, porta sed mattis bibendum, scelerisque cursus sapien. Cras ultrices imperdiet fermentum. Aenean nisi nulla, euismod non blandit ac, dictum quis libero. Morbi consectetur tempor mollis. Suspendisse eget nunc arcu, vel ullamcorper augue. Integer malesuada, diam nec faucibus mollis, nisl velit euismod enim, ac mattis justo neque sit amet mauris. Vivamus pretium imperdiet pharetra.\nInteger sagittis augue sit amet lectus pulvinar sit amet commodo tortor mattis. Maecenas quis tellus eget ante eleifend sollicitudin non et nibh. Maecenas luctus euismod tristique. Fusce in odio nec diam blandit facilisis. Sed nec arcu eros. Vivamus quis tortor a metus tempus aliquam eget volutpat magna. Pellentesque id ultrices dolor. Sed blandit aliquet quam. Phasellus dapibus euismod vulputate. Aenean blandit, elit vitae vestibulum tincidunt, metus dui accumsan nulla, sit amet vehicula mauris lacus in est. Etiam dignissim pellentesque nulla vel malesuada. Cras vel lorem justo.\nSed condimentum nisl sit amet libero vestibulum hendrerit. Duis auctor tempus placerat. Proin velit ante, ornare nec dictum nec, hendrerit eu arcu. Etiam ut diam ornare quam venenatis pulvinar vitae vel leo. Vivamus consectetur, ante id interdum rhoncus, magna eros pulvinar lacus, a gravida nibh arcu vitae eros. Nulla scelerisque laoreet feugiat. Mauris sit amet gravida felis.\nNulla ac dolor sapien, vestibulum venenatis justo. Cras placerat velit vitae nibh pellentesque ultricies. Suspendisse adipiscing enim eu justo iaculis eu pretium urna fermentum. Duis porttitor nunc non nunc mattis vestibulum. Etiam elit tellus, feugiat in bibendum eget, adipiscing nec metus. Ut ut sem lacus, quis faucibus diam. Curabitur a nulla fermentum tortor dignissim posuere. Fusce faucibus ante ut sem imperdiet imperdiet eget vitae lorem. Etiam fringilla ornare ipsum, in sagittis quam ornare vitae. Nullam venenatis orci sit amet sapien adipiscing gravida. Proin turpis lectus, hendrerit vitae vehicula ut, auctor ac lectus. Pellentesque sollicitudin blandit ligula quis commodo. Mauris vulputate lectus in velit luctus aliquam. Quisque eget tincidunt elit. Quisque et augue quam, sed scelerisque eros. 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/handmark/pulltorefresh/samples/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.samples; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /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.2.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 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "26.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.3.1' 30 | testCompile 'junit:junit:4.12' 31 | provided project(':library') 32 | } 33 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/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/system/MyDevFiles/Android-SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/androidTest/java/com/lazy/pulltorefreshlistfragment/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.pulltorefreshlistfragment; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.lazy.pulltorefreshlistfragment.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshBaseListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.support.v4.app.ListFragment; 20 | import android.view.LayoutInflater; 21 | import android.view.View; 22 | import android.view.ViewGroup; 23 | import android.widget.AbsListView; 24 | import android.widget.ListView; 25 | 26 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 27 | 28 | abstract class PullToRefreshBaseListFragment> extends ListFragment { 29 | 30 | private T mPullToRefreshListView; 31 | 32 | @Override 33 | public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 34 | View layout = super.onCreateView(inflater, container, savedInstanceState); 35 | 36 | ListView lv = (ListView) layout.findViewById(android.R.id.list); 37 | ViewGroup parent = (ViewGroup) lv.getParent(); 38 | 39 | // Remove ListView and add PullToRefreshListView in its place 40 | int lvIndex = parent.indexOfChild(lv); 41 | parent.removeViewAt(lvIndex); 42 | mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState); 43 | parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams()); 44 | 45 | return layout; 46 | } 47 | 48 | /** 49 | * @return The {@link PullToRefreshBase} attached to this ListFragment. 50 | */ 51 | public final T getPullToRefreshListView() { 52 | return mPullToRefreshListView; 53 | } 54 | 55 | /** 56 | * Returns the {@link PullToRefreshBase} which will replace the ListView 57 | * created from ListFragment. You should override this method if you wish to 58 | * customise the {@link PullToRefreshBase} from the default. 59 | * 60 | * @param inflater - LayoutInflater which can be used to inflate from XML. 61 | * @param savedInstanceState - Bundle passed through from 62 | * {@link ListFragment#onCreateView(LayoutInflater, ViewGroup, Bundle) 63 | * onCreateView(...)} 64 | * @return The {@link PullToRefreshBase} which will replace the ListView. 65 | */ 66 | protected abstract T onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState); 67 | 68 | } -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshExpandableListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.support.v4.app.ListFragment; 20 | import android.view.LayoutInflater; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView; 23 | 24 | /** 25 | * A sample implementation of how to use {@link PullToRefreshExpandableListView} 26 | * with {@link ListFragment}. This implementation simply replaces the ListView 27 | * that {@code ListFragment} creates with a new 28 | * {@code PullToRefreshExpandableListView}. This means that ListFragment still 29 | * works 100% (e.g. setListShown(...) ). 30 | *

31 | * The new PullToRefreshListView is created in the method 32 | * {@link #onCreatePullToRefreshListView(LayoutInflater, Bundle)}. If you wish 33 | * to customise the {@code PullToRefreshExpandableListView} then override this 34 | * method and return your customised instance. 35 | * 36 | * @author Chris Banes 37 | * 38 | */ 39 | public class PullToRefreshExpandableListFragment extends PullToRefreshBaseListFragment { 40 | 41 | protected PullToRefreshExpandableListView onCreatePullToRefreshListView(LayoutInflater inflater, 42 | Bundle savedInstanceState) { 43 | return new PullToRefreshExpandableListView(getActivity()); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/java/com/handmark/pulltorefresh/extras/listfragment/PullToRefreshListFragment.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.listfragment; 17 | 18 | import android.os.Bundle; 19 | import android.support.v4.app.ListFragment; 20 | import android.view.LayoutInflater; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshListView; 23 | 24 | /** 25 | * A sample implementation of how to use {@link PullToRefreshListView} with 26 | * {@link ListFragment}. This implementation simply replaces the ListView that 27 | * {@code ListFragment} creates with a new PullToRefreshListView. This means 28 | * that ListFragment still works 100% (e.g. setListShown(...) ). 29 | *

30 | * The new PullToRefreshListView is created in the method 31 | * {@link #onCreatePullToRefreshListView(LayoutInflater, Bundle)}. If you wish 32 | * to customise the {@code PullToRefreshListView} then override this method and 33 | * return your customised instance. 34 | * 35 | * @author Chris Banes 36 | * 37 | */ 38 | public class PullToRefreshListFragment extends PullToRefreshBaseListFragment { 39 | 40 | protected PullToRefreshListView onCreatePullToRefreshListView(LayoutInflater inflater, Bundle savedInstanceState) { 41 | return new PullToRefreshListView(getActivity()); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/res/layout/need_this_for_maven.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PullToRefreshListFragment 3 | 4 | -------------------------------------------------------------------------------- /extras/pulltorefreshlistfragment/src/test/java/com/lazy/pulltorefreshlistfragment/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.pulltorefreshlistfragment; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "26.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.3.1' 30 | testCompile 'junit:junit:4.12' 31 | provided project(':library') 32 | } 33 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/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/system/MyDevFiles/Android-SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/androidTest/java/com/lazy/pulltorefreshviewpager/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.pulltorefreshviewpager; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.lazy.pulltorefreshviewpager.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/main/java/com/handmark/pulltorefresh/extras/viewpager/PullToRefreshViewPager.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.extras.viewpager; 17 | 18 | import android.content.Context; 19 | import android.support.v4.view.PagerAdapter; 20 | import android.support.v4.view.ViewPager; 21 | import android.util.AttributeSet; 22 | 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 24 | 25 | public class PullToRefreshViewPager extends PullToRefreshBase { 26 | 27 | public PullToRefreshViewPager(Context context) { 28 | super(context); 29 | } 30 | 31 | public PullToRefreshViewPager(Context context, AttributeSet attrs) { 32 | super(context, attrs); 33 | } 34 | 35 | @Override 36 | public final Orientation getPullToRefreshScrollDirection() { 37 | return Orientation.HORIZONTAL; 38 | } 39 | 40 | @Override 41 | protected ViewPager createRefreshableView(Context context, AttributeSet attrs) { 42 | ViewPager viewPager = new ViewPager(context, attrs); 43 | viewPager.setId(R.id.viewpager); 44 | return viewPager; 45 | } 46 | 47 | @Override 48 | protected boolean isReadyForPullStart() { 49 | ViewPager refreshableView = getRefreshableView(); 50 | 51 | PagerAdapter adapter = refreshableView.getAdapter(); 52 | if (null != adapter) { 53 | return refreshableView.getCurrentItem() == 0; 54 | } 55 | 56 | return false; 57 | } 58 | 59 | @Override 60 | protected boolean isReadyForPullEnd() { 61 | ViewPager refreshableView = getRefreshableView(); 62 | 63 | PagerAdapter adapter = refreshableView.getAdapter(); 64 | if (null != adapter) { 65 | return refreshableView.getCurrentItem() == adapter.getCount() - 1; 66 | } 67 | 68 | return false; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/main/res/layout/need_this_for_maven.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | PullToRefreshViewPager 3 | 4 | -------------------------------------------------------------------------------- /extras/pulltorefreshviewpager/src/test/java/com/lazy/pulltorefreshviewpager/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.pulltorefreshviewpager; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-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 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "26.0.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | compile fileTree(include: ['*.jar'], dir: 'libs') 26 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 27 | exclude group: 'com.android.support', module: 'support-annotations' 28 | }) 29 | compile 'com.android.support:appcompat-v7:25.3.1' 30 | testCompile 'junit:junit:4.12' 31 | compile 'com.android.support:recyclerview-v7:25.3.1' 32 | } 33 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/system/MyDevFiles/Android-SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/lazy/library/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.library; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.assertEquals; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.lazy.library.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/ILoadingLayout.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library; 2 | 3 | import android.graphics.Typeface; 4 | import android.graphics.drawable.Drawable; 5 | 6 | public interface ILoadingLayout { 7 | 8 | /** 9 | * Set the Last Updated Text. This displayed under the main label when 10 | * Pulling 11 | * 12 | * @param label - Label to set 13 | */ 14 | public void setLastUpdatedLabel(CharSequence label); 15 | 16 | /** 17 | * Set the drawable used in the loading layout. This is the same as calling 18 | * setLoadingDrawable(drawable, Mode.BOTH) 19 | * 20 | * @param drawable - Drawable to display 21 | */ 22 | public void setLoadingDrawable(Drawable drawable); 23 | 24 | /** 25 | * Set Text to show when the Widget is being Pulled 26 | * setPullLabel(releaseLabel, Mode.BOTH) 27 | * 28 | * @param pullLabel - CharSequence to display 29 | */ 30 | public void setPullLabel(CharSequence pullLabel); 31 | 32 | /** 33 | * Set Text to show when the Widget is refreshing 34 | * setRefreshingLabel(releaseLabel, Mode.BOTH) 35 | * 36 | * @param refreshingLabel - CharSequence to display 37 | */ 38 | public void setRefreshingLabel(CharSequence refreshingLabel); 39 | 40 | /** 41 | * Set Text to show when the Widget is being pulled, and will refresh when 42 | * released. This is the same as calling 43 | * setReleaseLabel(releaseLabel, Mode.BOTH) 44 | * 45 | * @param releaseLabel - CharSequence to display 46 | */ 47 | public void setReleaseLabel(CharSequence releaseLabel); 48 | 49 | /** 50 | * Set's the Sets the typeface and style in which the text should be 51 | * displayed. Please see 52 | * {@link android.widget.TextView#setTypeface(Typeface) 53 | * TextView#setTypeface(Typeface)}. 54 | */ 55 | public void setTextTypeface(Typeface tf); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/LoadingLayoutProxy.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library; 2 | 3 | import android.graphics.Typeface; 4 | import android.graphics.drawable.Drawable; 5 | 6 | import com.handmark.pulltorefresh.library.internal.LoadingLayout; 7 | 8 | import java.util.HashSet; 9 | 10 | public class LoadingLayoutProxy implements ILoadingLayout { 11 | 12 | private final HashSet mLoadingLayouts; 13 | 14 | LoadingLayoutProxy() { 15 | mLoadingLayouts = new HashSet(); 16 | } 17 | 18 | /** 19 | * This allows you to add extra LoadingLayout instances to this proxy. This 20 | * is only necessary if you keep your own instances, and want to have them 21 | * included in any 22 | * {@link PullToRefreshBase#createLoadingLayoutProxy(boolean, boolean) 23 | * createLoadingLayoutProxy(...)} calls. 24 | * 25 | * @param layout - LoadingLayout to have included. 26 | */ 27 | public void addLayout(LoadingLayout layout) { 28 | if (null != layout) { 29 | mLoadingLayouts.add(layout); 30 | } 31 | } 32 | 33 | @Override 34 | public void setLastUpdatedLabel(CharSequence label) { 35 | for (LoadingLayout layout : mLoadingLayouts) { 36 | layout.setLastUpdatedLabel(label); 37 | } 38 | } 39 | 40 | @Override 41 | public void setLoadingDrawable(Drawable drawable) { 42 | for (LoadingLayout layout : mLoadingLayouts) { 43 | layout.setLoadingDrawable(drawable); 44 | } 45 | } 46 | 47 | @Override 48 | public void setRefreshingLabel(CharSequence refreshingLabel) { 49 | for (LoadingLayout layout : mLoadingLayouts) { 50 | layout.setRefreshingLabel(refreshingLabel); 51 | } 52 | } 53 | 54 | @Override 55 | public void setPullLabel(CharSequence label) { 56 | for (LoadingLayout layout : mLoadingLayouts) { 57 | layout.setPullLabel(label); 58 | } 59 | } 60 | 61 | @Override 62 | public void setReleaseLabel(CharSequence label) { 63 | for (LoadingLayout layout : mLoadingLayouts) { 64 | layout.setReleaseLabel(label); 65 | } 66 | } 67 | 68 | public void setTextTypeface(Typeface tf) { 69 | for (LoadingLayout layout : mLoadingLayouts) { 70 | layout.setTextTypeface(tf); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshExpandableListView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.ExpandableListView; 25 | 26 | import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor; 27 | 28 | public class PullToRefreshExpandableListView extends PullToRefreshAdapterViewBase { 29 | 30 | public PullToRefreshExpandableListView(Context context) { 31 | super(context); 32 | } 33 | 34 | public PullToRefreshExpandableListView(Context context, AttributeSet attrs) { 35 | super(context, attrs); 36 | } 37 | 38 | public PullToRefreshExpandableListView(Context context, Mode mode) { 39 | super(context, mode); 40 | } 41 | 42 | public PullToRefreshExpandableListView(Context context, Mode mode, AnimationStyle style) { 43 | super(context, mode, style); 44 | } 45 | 46 | @Override 47 | public final Orientation getPullToRefreshScrollDirection() { 48 | return Orientation.VERTICAL; 49 | } 50 | 51 | @Override 52 | protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) { 53 | final ExpandableListView lv; 54 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 55 | lv = new InternalExpandableListViewSDK9(context, attrs); 56 | } else { 57 | lv = new InternalExpandableListView(context, attrs); 58 | } 59 | 60 | // Set it to this so it can be used in ListActivity/ListFragment 61 | lv.setId(android.R.id.list); 62 | return lv; 63 | } 64 | 65 | class InternalExpandableListView extends ExpandableListView implements EmptyViewMethodAccessor { 66 | 67 | public InternalExpandableListView(Context context, AttributeSet attrs) { 68 | super(context, attrs); 69 | } 70 | 71 | @Override 72 | public void setEmptyView(View emptyView) { 73 | PullToRefreshExpandableListView.this.setEmptyView(emptyView); 74 | } 75 | 76 | @Override 77 | public void setEmptyViewInternal(View emptyView) { 78 | super.setEmptyView(emptyView); 79 | } 80 | } 81 | 82 | @TargetApi(9) 83 | final class InternalExpandableListViewSDK9 extends InternalExpandableListView { 84 | 85 | public InternalExpandableListViewSDK9(Context context, AttributeSet attrs) { 86 | super(context, attrs); 87 | } 88 | 89 | @Override 90 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 91 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 92 | 93 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 94 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 95 | 96 | // Does all of the hard work... 97 | OverscrollHelper.overScrollBy(PullToRefreshExpandableListView.this, deltaX, scrollX, deltaY, scrollY, 98 | isTouchEvent); 99 | 100 | return returnValue; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshGridView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.GridView; 25 | 26 | import com.handmark.pulltorefresh.library.internal.EmptyViewMethodAccessor; 27 | 28 | public class PullToRefreshGridView extends PullToRefreshAdapterViewBase { 29 | 30 | public PullToRefreshGridView(Context context) { 31 | super(context); 32 | } 33 | 34 | public PullToRefreshGridView(Context context, AttributeSet attrs) { 35 | super(context, attrs); 36 | } 37 | 38 | public PullToRefreshGridView(Context context, Mode mode) { 39 | super(context, mode); 40 | } 41 | 42 | public PullToRefreshGridView(Context context, Mode mode, AnimationStyle style) { 43 | super(context, mode, style); 44 | } 45 | 46 | @Override 47 | public final Orientation getPullToRefreshScrollDirection() { 48 | return Orientation.VERTICAL; 49 | } 50 | 51 | @Override 52 | protected final GridView createRefreshableView(Context context, AttributeSet attrs) { 53 | final GridView gv; 54 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 55 | gv = new InternalGridViewSDK9(context, attrs); 56 | } else { 57 | gv = new InternalGridView(context, attrs); 58 | } 59 | 60 | // Use Generated ID (from res/values/ids.xml) 61 | gv.setId(R.id.gridview); 62 | return gv; 63 | } 64 | 65 | class InternalGridView extends GridView implements EmptyViewMethodAccessor { 66 | 67 | public InternalGridView(Context context, AttributeSet attrs) { 68 | super(context, attrs); 69 | } 70 | 71 | @Override 72 | public void setEmptyView(View emptyView) { 73 | PullToRefreshGridView.this.setEmptyView(emptyView); 74 | } 75 | 76 | @Override 77 | public void setEmptyViewInternal(View emptyView) { 78 | super.setEmptyView(emptyView); 79 | } 80 | } 81 | 82 | @TargetApi(9) 83 | final class InternalGridViewSDK9 extends InternalGridView { 84 | 85 | public InternalGridViewSDK9(Context context, AttributeSet attrs) { 86 | super(context, attrs); 87 | } 88 | 89 | @Override 90 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 91 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 92 | 93 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 94 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 95 | 96 | // Does all of the hard work... 97 | OverscrollHelper.overScrollBy(PullToRefreshGridView.this, deltaX, scrollX, deltaY, scrollY, isTouchEvent); 98 | 99 | return returnValue; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshHorizontalScrollView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.HorizontalScrollView; 25 | 26 | public class PullToRefreshHorizontalScrollView extends PullToRefreshBase { 27 | 28 | public PullToRefreshHorizontalScrollView(Context context) { 29 | super(context); 30 | } 31 | 32 | public PullToRefreshHorizontalScrollView(Context context, AttributeSet attrs) { 33 | super(context, attrs); 34 | } 35 | 36 | public PullToRefreshHorizontalScrollView(Context context, Mode mode) { 37 | super(context, mode); 38 | } 39 | 40 | public PullToRefreshHorizontalScrollView(Context context, Mode mode, AnimationStyle style) { 41 | super(context, mode, style); 42 | } 43 | 44 | @Override 45 | public final Orientation getPullToRefreshScrollDirection() { 46 | return Orientation.HORIZONTAL; 47 | } 48 | 49 | @Override 50 | protected HorizontalScrollView createRefreshableView(Context context, AttributeSet attrs) { 51 | HorizontalScrollView scrollView; 52 | 53 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 54 | scrollView = new InternalHorizontalScrollViewSDK9(context, attrs); 55 | } else { 56 | scrollView = new HorizontalScrollView(context, attrs); 57 | } 58 | 59 | scrollView.setId(R.id.scrollview); 60 | return scrollView; 61 | } 62 | 63 | @Override 64 | protected boolean isReadyForPullStart() { 65 | return mRefreshableView.getScrollX() == 0; 66 | } 67 | 68 | @Override 69 | protected boolean isReadyForPullEnd() { 70 | View scrollViewChild = mRefreshableView.getChildAt(0); 71 | if (null != scrollViewChild) { 72 | return mRefreshableView.getScrollX() >= (scrollViewChild.getWidth() - getWidth()); 73 | } 74 | return false; 75 | } 76 | 77 | @TargetApi(9) 78 | final class InternalHorizontalScrollViewSDK9 extends HorizontalScrollView { 79 | 80 | public InternalHorizontalScrollViewSDK9(Context context, AttributeSet attrs) { 81 | super(context, attrs); 82 | } 83 | 84 | @Override 85 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 86 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 87 | 88 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 89 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 90 | 91 | // Does all of the hard work... 92 | OverscrollHelper.overScrollBy(PullToRefreshHorizontalScrollView.this, deltaX, scrollX, deltaY, scrollY, 93 | getScrollRange(), isTouchEvent); 94 | 95 | return returnValue; 96 | } 97 | 98 | /** 99 | * Taken from the AOSP ScrollView source 100 | */ 101 | private int getScrollRange() { 102 | int scrollRange = 0; 103 | if (getChildCount() > 0) { 104 | View child = getChildAt(0); 105 | scrollRange = Math.max(0, child.getWidth() - (getWidth() - getPaddingLeft() - getPaddingRight())); 106 | } 107 | return scrollRange; 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshScrollView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.util.AttributeSet; 23 | import android.view.View; 24 | import android.widget.ScrollView; 25 | 26 | public class PullToRefreshScrollView extends PullToRefreshBase { 27 | 28 | public PullToRefreshScrollView(Context context) { 29 | super(context); 30 | } 31 | 32 | public PullToRefreshScrollView(Context context, AttributeSet attrs) { 33 | super(context, attrs); 34 | } 35 | 36 | public PullToRefreshScrollView(Context context, Mode mode) { 37 | super(context, mode); 38 | } 39 | 40 | public PullToRefreshScrollView(Context context, Mode mode, AnimationStyle style) { 41 | super(context, mode, style); 42 | } 43 | 44 | @Override 45 | public final Orientation getPullToRefreshScrollDirection() { 46 | return Orientation.VERTICAL; 47 | } 48 | 49 | @Override 50 | protected ScrollView createRefreshableView(Context context, AttributeSet attrs) { 51 | ScrollView scrollView; 52 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 53 | scrollView = new InternalScrollViewSDK9(context, attrs); 54 | } else { 55 | scrollView = new ScrollView(context, attrs); 56 | } 57 | 58 | scrollView.setId(R.id.scrollview); 59 | return scrollView; 60 | } 61 | 62 | @Override 63 | protected boolean isReadyForPullStart() { 64 | return mRefreshableView.getScrollY() == 0; 65 | } 66 | 67 | @Override 68 | protected boolean isReadyForPullEnd() { 69 | View scrollViewChild = mRefreshableView.getChildAt(0); 70 | if (null != scrollViewChild) { 71 | return mRefreshableView.getScrollY() >= (scrollViewChild.getHeight() - getHeight()); 72 | } 73 | return false; 74 | } 75 | 76 | @TargetApi(9) 77 | final class InternalScrollViewSDK9 extends ScrollView { 78 | 79 | public InternalScrollViewSDK9(Context context, AttributeSet attrs) { 80 | super(context, attrs); 81 | } 82 | 83 | @Override 84 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 85 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 86 | 87 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 88 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 89 | 90 | // Does all of the hard work... 91 | OverscrollHelper.overScrollBy(PullToRefreshScrollView.this, deltaX, scrollX, deltaY, scrollY, 92 | getScrollRange(), isTouchEvent); 93 | 94 | return returnValue; 95 | } 96 | 97 | /** 98 | * Taken from the AOSP ScrollView source 99 | */ 100 | private int getScrollRange() { 101 | int scrollRange = 0; 102 | if (getChildCount() > 0) { 103 | View child = getChildAt(0); 104 | scrollRange = Math.max(0, child.getHeight() - (getHeight() - getPaddingBottom() - getPaddingTop())); 105 | } 106 | return scrollRange; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/PullToRefreshWebView.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library; 17 | 18 | import android.annotation.TargetApi; 19 | import android.content.Context; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.os.Bundle; 23 | import android.util.AttributeSet; 24 | import android.webkit.WebChromeClient; 25 | import android.webkit.WebView; 26 | 27 | public class PullToRefreshWebView extends PullToRefreshBase { 28 | 29 | private static final OnRefreshListener defaultOnRefreshListener = new OnRefreshListener() { 30 | 31 | @Override 32 | public void onRefresh(PullToRefreshBase refreshView) { 33 | refreshView.getRefreshableView().reload(); 34 | } 35 | 36 | }; 37 | 38 | private final WebChromeClient defaultWebChromeClient = new WebChromeClient() { 39 | 40 | @Override 41 | public void onProgressChanged(WebView view, int newProgress) { 42 | if (newProgress == 100) { 43 | onRefreshComplete(); 44 | } 45 | } 46 | 47 | }; 48 | 49 | public PullToRefreshWebView(Context context) { 50 | super(context); 51 | 52 | /** 53 | * Added so that by default, Pull-to-Refresh refreshes the page 54 | */ 55 | setOnRefreshListener(defaultOnRefreshListener); 56 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 57 | } 58 | 59 | public PullToRefreshWebView(Context context, AttributeSet attrs) { 60 | super(context, attrs); 61 | 62 | /** 63 | * Added so that by default, Pull-to-Refresh refreshes the page 64 | */ 65 | setOnRefreshListener(defaultOnRefreshListener); 66 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 67 | } 68 | 69 | public PullToRefreshWebView(Context context, Mode mode) { 70 | super(context, mode); 71 | 72 | /** 73 | * Added so that by default, Pull-to-Refresh refreshes the page 74 | */ 75 | setOnRefreshListener(defaultOnRefreshListener); 76 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 77 | } 78 | 79 | public PullToRefreshWebView(Context context, Mode mode, AnimationStyle style) { 80 | super(context, mode, style); 81 | 82 | /** 83 | * Added so that by default, Pull-to-Refresh refreshes the page 84 | */ 85 | setOnRefreshListener(defaultOnRefreshListener); 86 | mRefreshableView.setWebChromeClient(defaultWebChromeClient); 87 | } 88 | 89 | @Override 90 | public final Orientation getPullToRefreshScrollDirection() { 91 | return Orientation.VERTICAL; 92 | } 93 | 94 | @Override 95 | protected WebView createRefreshableView(Context context, AttributeSet attrs) { 96 | WebView webView; 97 | if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) { 98 | webView = new InternalWebViewSDK9(context, attrs); 99 | } else { 100 | webView = new WebView(context, attrs); 101 | } 102 | 103 | webView.setId(R.id.webview); 104 | return webView; 105 | } 106 | 107 | @Override 108 | protected boolean isReadyForPullStart() { 109 | return mRefreshableView.getScrollY() == 0; 110 | } 111 | 112 | @Override 113 | protected boolean isReadyForPullEnd() { 114 | double exactContentHeight = Math.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()); 115 | return mRefreshableView.getScrollY() >= (exactContentHeight - mRefreshableView.getHeight()); 116 | } 117 | 118 | @Override 119 | protected void onPtrRestoreInstanceState(Bundle savedInstanceState) { 120 | super.onPtrRestoreInstanceState(savedInstanceState); 121 | mRefreshableView.restoreState(savedInstanceState); 122 | } 123 | 124 | @Override 125 | protected void onPtrSaveInstanceState(Bundle saveState) { 126 | super.onPtrSaveInstanceState(saveState); 127 | mRefreshableView.saveState(saveState); 128 | } 129 | 130 | @TargetApi(9) 131 | final class InternalWebViewSDK9 extends WebView { 132 | 133 | // WebView doesn't always scroll back to it's edge so we add some 134 | // fuzziness 135 | static final int OVERSCROLL_FUZZY_THRESHOLD = 2; 136 | 137 | // WebView seems quite reluctant to overscroll so we use the scale 138 | // factor to scale it's value 139 | static final float OVERSCROLL_SCALE_FACTOR = 1.5f; 140 | 141 | public InternalWebViewSDK9(Context context, AttributeSet attrs) { 142 | super(context, attrs); 143 | } 144 | 145 | @Override 146 | protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, 147 | int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) { 148 | 149 | final boolean returnValue = super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, 150 | scrollRangeY, maxOverScrollX, maxOverScrollY, isTouchEvent); 151 | 152 | // Does all of the hard work... 153 | OverscrollHelper.overScrollBy(PullToRefreshWebView.this, deltaX, scrollX, deltaY, scrollY, 154 | getScrollRange(), OVERSCROLL_FUZZY_THRESHOLD, OVERSCROLL_SCALE_FACTOR, isTouchEvent); 155 | 156 | return returnValue; 157 | } 158 | 159 | private int getScrollRange() { 160 | return (int) Math.max(0, Math.floor(mRefreshableView.getContentHeight() * mRefreshableView.getScale()) 161 | - (getHeight() - getPaddingBottom() - getPaddingTop())); 162 | } 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/extras/PullToRefreshWebView2.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.extras; 17 | 18 | import android.content.Context; 19 | import android.util.AttributeSet; 20 | import android.webkit.WebView; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshWebView; 23 | 24 | import java.util.concurrent.atomic.AtomicBoolean; 25 | 26 | /** 27 | * An advanced version of {@link PullToRefreshWebView} which delegates the 28 | * triggering of the PullToRefresh gesture to the Javascript running within the 29 | * WebView. This means that you should only use this class if: 30 | *

31 | *

38 | *

39 | *

40 | * The way this call works is that when a PullToRefresh gesture is in action, 41 | * the following Javascript methods will be called: 42 | * isReadyForPullDown() and isReadyForPullUp(), it is 43 | * your job to calculate whether the view is in a state where a PullToRefresh 44 | * can happen, and return the result via the callback mechanism. An example can 45 | * be seen below: 46 | *

47 | * 48 | *

 49 |  * function isReadyForPullDown() {
 50 |  *   var result = ...  // Probably using the .scrollTop DOM attribute
 51 |  *   ptr.isReadyForPullDownResponse(result);
 52 |  * }
 53 |  *
 54 |  * function isReadyForPullUp() {
 55 |  *   var result = ...  // Probably using the .scrollBottom DOM attribute
 56 |  *   ptr.isReadyForPullUpResponse(result);
 57 |  * }
 58 |  * 
59 | * 60 | * @author Chris Banes 61 | */ 62 | public class PullToRefreshWebView2 extends PullToRefreshWebView { 63 | 64 | static final String JS_INTERFACE_PKG = "ptr"; 65 | static final String DEF_JS_READY_PULL_DOWN_CALL = "javascript:isReadyForPullDown();"; 66 | static final String DEF_JS_READY_PULL_UP_CALL = "javascript:isReadyForPullUp();"; 67 | 68 | public PullToRefreshWebView2(Context context) { 69 | super(context); 70 | } 71 | 72 | public PullToRefreshWebView2(Context context, AttributeSet attrs) { 73 | super(context, attrs); 74 | } 75 | 76 | public PullToRefreshWebView2(Context context, Mode mode) { 77 | super(context, mode); 78 | } 79 | 80 | private JsValueCallback mJsCallback; 81 | private final AtomicBoolean mIsReadyForPullDown = new AtomicBoolean(false); 82 | private final AtomicBoolean mIsReadyForPullUp = new AtomicBoolean(false); 83 | 84 | @Override 85 | protected WebView createRefreshableView(Context context, AttributeSet attrs) { 86 | WebView webView = super.createRefreshableView(context, attrs); 87 | 88 | // Need to add JS Interface so we can get the response back 89 | mJsCallback = new JsValueCallback(); 90 | webView.addJavascriptInterface(mJsCallback, JS_INTERFACE_PKG); 91 | 92 | return webView; 93 | } 94 | 95 | @Override 96 | protected boolean isReadyForPullStart() { 97 | // Call Javascript... 98 | getRefreshableView().loadUrl(DEF_JS_READY_PULL_DOWN_CALL); 99 | 100 | // Response will be given to JsValueCallback, which will update 101 | // mIsReadyForPullDown 102 | 103 | return mIsReadyForPullDown.get(); 104 | } 105 | 106 | @Override 107 | protected boolean isReadyForPullEnd() { 108 | // Call Javascript... 109 | getRefreshableView().loadUrl(DEF_JS_READY_PULL_UP_CALL); 110 | 111 | // Response will be given to JsValueCallback, which will update 112 | // mIsReadyForPullUp 113 | 114 | return mIsReadyForPullUp.get(); 115 | } 116 | 117 | /** 118 | * Used for response from Javascript 119 | * 120 | * @author Chris Banes 121 | */ 122 | final class JsValueCallback { 123 | 124 | public void isReadyForPullUpResponse(boolean response) { 125 | mIsReadyForPullUp.set(response); 126 | } 127 | 128 | public void isReadyForPullDownResponse(boolean response) { 129 | mIsReadyForPullDown.set(response); 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/extras/SoundPullEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.extras; 17 | 18 | import android.content.Context; 19 | import android.media.MediaPlayer; 20 | import android.view.View; 21 | 22 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 23 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode; 24 | import com.handmark.pulltorefresh.library.PullToRefreshBase.State; 25 | 26 | import java.util.HashMap; 27 | 28 | public class SoundPullEventListener implements PullToRefreshBase.OnPullEventListener { 29 | 30 | private final Context mContext; 31 | private final HashMap mSoundMap; 32 | 33 | private MediaPlayer mCurrentMediaPlayer; 34 | 35 | /** 36 | * Constructor 37 | * 38 | * @param context - Context 39 | */ 40 | public SoundPullEventListener(Context context) { 41 | mContext = context; 42 | mSoundMap = new HashMap(); 43 | } 44 | 45 | @Override 46 | public final void onPullEvent(PullToRefreshBase refreshView, State event, Mode direction) { 47 | Integer soundResIdObj = mSoundMap.get(event); 48 | if (null != soundResIdObj) { 49 | playSound(soundResIdObj.intValue()); 50 | } 51 | } 52 | 53 | /** 54 | * Set the Sounds to be played when a Pull Event happens. You specify which 55 | * sound plays for which events by calling this method multiple times for 56 | * each event. 57 | *

58 | * If you've already set a sound for a certain event, and add another sound 59 | * for that event, only the new sound will be played. 60 | * 61 | * @param event - The event for which the sound will be played. 62 | * @param resId - Resource Id of the sound file to be played (e.g. 63 | * R.raw.pull_sound) 64 | */ 65 | public void addSoundEvent(State event, int resId) { 66 | mSoundMap.put(event, resId); 67 | } 68 | 69 | /** 70 | * Clears all of the previously set sounds and events. 71 | */ 72 | public void clearSounds() { 73 | mSoundMap.clear(); 74 | } 75 | 76 | /** 77 | * Gets the current (or last) MediaPlayer instance. 78 | */ 79 | public MediaPlayer getCurrentMediaPlayer() { 80 | return mCurrentMediaPlayer; 81 | } 82 | 83 | private void playSound(int resId) { 84 | // Stop current player, if there's one playing 85 | if (null != mCurrentMediaPlayer) { 86 | mCurrentMediaPlayer.stop(); 87 | mCurrentMediaPlayer.release(); 88 | } 89 | 90 | mCurrentMediaPlayer = MediaPlayer.create(mContext, resId); 91 | if (null != mCurrentMediaPlayer) { 92 | mCurrentMediaPlayer.start(); 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/EmptyViewMethodAccessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.view.View; 19 | 20 | /** 21 | * Interface that allows PullToRefreshBase to hijack the call to 22 | * AdapterView.setEmptyView() 23 | * 24 | * @author chris 25 | */ 26 | public interface EmptyViewMethodAccessor { 27 | 28 | /** 29 | * Calls upto AdapterView.setEmptyView() 30 | * 31 | * @param emptyView - to set as Empty View 32 | */ 33 | public void setEmptyViewInternal(View emptyView); 34 | 35 | /** 36 | * Should call PullToRefreshBase.setEmptyView() which will then 37 | * automatically call through to setEmptyViewInternal() 38 | * 39 | * @param emptyView - to set as Empty View 40 | */ 41 | public void setEmptyView(View emptyView); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/FlipLoadingLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.Matrix; 22 | import android.graphics.drawable.Drawable; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.view.animation.Animation; 26 | import android.view.animation.RotateAnimation; 27 | import android.widget.ImageView.ScaleType; 28 | 29 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode; 30 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation; 31 | import com.handmark.pulltorefresh.library.R; 32 | 33 | @SuppressLint("ViewConstructor") 34 | public class FlipLoadingLayout extends LoadingLayout { 35 | 36 | static final int FLIP_ANIMATION_DURATION = 150; 37 | 38 | private final Animation mRotateAnimation, mResetRotateAnimation; 39 | 40 | public FlipLoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) { 41 | super(context, mode, scrollDirection, attrs); 42 | 43 | final int rotateAngle = mode == Mode.PULL_FROM_START ? -180 : 180; 44 | 45 | mRotateAnimation = new RotateAnimation(0, rotateAngle, Animation.RELATIVE_TO_SELF, 0.5f, 46 | Animation.RELATIVE_TO_SELF, 0.5f); 47 | mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 48 | mRotateAnimation.setDuration(FLIP_ANIMATION_DURATION); 49 | mRotateAnimation.setFillAfter(true); 50 | 51 | mResetRotateAnimation = new RotateAnimation(rotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f, 52 | Animation.RELATIVE_TO_SELF, 0.5f); 53 | mResetRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 54 | mResetRotateAnimation.setDuration(FLIP_ANIMATION_DURATION); 55 | mResetRotateAnimation.setFillAfter(true); 56 | } 57 | 58 | @Override 59 | protected void onLoadingDrawableSet(Drawable imageDrawable) { 60 | if (null != imageDrawable) { 61 | final int dHeight = imageDrawable.getIntrinsicHeight(); 62 | final int dWidth = imageDrawable.getIntrinsicWidth(); 63 | 64 | /** 65 | * We need to set the width/height of the ImageView so that it is 66 | * square with each side the size of the largest drawable dimension. 67 | * This is so that it doesn't clip when rotated. 68 | */ 69 | ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams(); 70 | lp.width = lp.height = Math.max(dHeight, dWidth); 71 | mHeaderImage.requestLayout(); 72 | 73 | /** 74 | * We now rotate the Drawable so that is at the correct rotation, 75 | * and is centered. 76 | */ 77 | mHeaderImage.setScaleType(ScaleType.MATRIX); 78 | Matrix matrix = new Matrix(); 79 | matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f); 80 | matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f); 81 | mHeaderImage.setImageMatrix(matrix); 82 | } 83 | } 84 | 85 | @Override 86 | protected void onPullImpl(float scaleOfLayout) { 87 | // NO-OP 88 | } 89 | 90 | @Override 91 | protected void pullToRefreshImpl() { 92 | // Only start reset Animation, we've previously show the rotate anim 93 | if (mRotateAnimation == mHeaderImage.getAnimation()) { 94 | mHeaderImage.startAnimation(mResetRotateAnimation); 95 | } 96 | } 97 | 98 | @Override 99 | protected void refreshingImpl() { 100 | mHeaderImage.clearAnimation(); 101 | mHeaderImage.setVisibility(View.INVISIBLE); 102 | mHeaderProgress.setVisibility(View.VISIBLE); 103 | } 104 | 105 | @Override 106 | protected void releaseToRefreshImpl() { 107 | mHeaderImage.startAnimation(mRotateAnimation); 108 | } 109 | 110 | @Override 111 | protected void resetImpl() { 112 | mHeaderImage.clearAnimation(); 113 | mHeaderProgress.setVisibility(View.GONE); 114 | mHeaderImage.setVisibility(View.VISIBLE); 115 | } 116 | 117 | @Override 118 | protected int getDefaultDrawableResId() { 119 | return R.drawable.default_ptr_flip; 120 | } 121 | 122 | private float getDrawableRotationAngle() { 123 | float angle = 0f; 124 | switch (mMode) { 125 | case PULL_FROM_END: 126 | if (mScrollDirection == Orientation.HORIZONTAL) { 127 | angle = 90f; 128 | } else { 129 | angle = 180f; 130 | } 131 | break; 132 | 133 | case PULL_FROM_START: 134 | if (mScrollDirection == Orientation.HORIZONTAL) { 135 | angle = 270f; 136 | } 137 | break; 138 | 139 | default: 140 | break; 141 | } 142 | 143 | return angle; 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/HeaderAndFooterWrapper.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library.internal; 2 | 3 | import android.support.v4.util.SparseArrayCompat; 4 | import android.support.v7.widget.GridLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | 10 | public class HeaderAndFooterWrapper extends RecyclerView.Adapter { 11 | private static final int BASE_ITEM_TYPE_HEADER = 100000; 12 | private static final int BASE_ITEM_TYPE_FOOTER = 200000; 13 | 14 | private SparseArrayCompat mHeaderViews = new SparseArrayCompat<>(); 15 | private SparseArrayCompat mFootViews = new SparseArrayCompat<>(); 16 | 17 | private RecyclerView.Adapter mInnerAdapter; 18 | 19 | public HeaderAndFooterWrapper() { 20 | } 21 | 22 | public HeaderAndFooterWrapper(RecyclerView.Adapter adapter) { 23 | mInnerAdapter = adapter; 24 | } 25 | 26 | public void setInnerAdapter(RecyclerView.Adapter mInnerAdapter) { 27 | this.mInnerAdapter = mInnerAdapter; 28 | } 29 | 30 | @Override 31 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 32 | if (mHeaderViews.get(viewType) != null) { 33 | ViewHolder holder = ViewHolder.createViewHolder(parent.getContext(), mHeaderViews.get(viewType)); 34 | return holder; 35 | 36 | } else if (mFootViews.get(viewType) != null) { 37 | ViewHolder holder = ViewHolder.createViewHolder(parent.getContext(), mFootViews.get(viewType)); 38 | return holder; 39 | } 40 | return mInnerAdapter.onCreateViewHolder(parent, viewType); 41 | } 42 | 43 | @Override 44 | public int getItemViewType(int position) { 45 | if (isHeaderViewPos(position)) { 46 | return mHeaderViews.keyAt(position); 47 | } else if (isFooterViewPos(position)) { 48 | return mFootViews.keyAt(position - getHeadersCount() - getRealItemCount()); 49 | } 50 | return mInnerAdapter.getItemViewType(position - getHeadersCount()); 51 | } 52 | 53 | private int getRealItemCount() { 54 | return mInnerAdapter.getItemCount(); 55 | } 56 | 57 | 58 | @Override 59 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 60 | if (isHeaderViewPos(position)) { 61 | return; 62 | } 63 | if (isFooterViewPos(position)) { 64 | return; 65 | } 66 | mInnerAdapter.onBindViewHolder(holder, position - getHeadersCount()); 67 | } 68 | 69 | @Override 70 | public int getItemCount() { 71 | return getHeadersCount() + getFootersCount() + getRealItemCount(); 72 | } 73 | 74 | @Override 75 | public void onAttachedToRecyclerView(RecyclerView recyclerView) { 76 | WrapperUtils.onAttachedToRecyclerView(mInnerAdapter, recyclerView, new WrapperUtils.SpanSizeCallback() { 77 | @Override 78 | public int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position) { 79 | int viewType = getItemViewType(position); 80 | if (mHeaderViews.get(viewType) != null) { 81 | return layoutManager.getSpanCount(); 82 | } else if (mFootViews.get(viewType) != null) { 83 | return layoutManager.getSpanCount(); 84 | } 85 | if (oldLookup != null) 86 | return oldLookup.getSpanSize(position); 87 | return 1; 88 | } 89 | }); 90 | } 91 | 92 | @Override 93 | public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { 94 | mInnerAdapter.onViewAttachedToWindow(holder); 95 | int position = holder.getLayoutPosition(); 96 | if (isHeaderViewPos(position) || isFooterViewPos(position)) { 97 | WrapperUtils.setFullSpan(holder); 98 | } 99 | } 100 | 101 | private boolean isHeaderViewPos(int position) { 102 | return position < getHeadersCount(); 103 | } 104 | 105 | private boolean isFooterViewPos(int position) { 106 | return position >= getHeadersCount() + getRealItemCount(); 107 | } 108 | 109 | 110 | public void addHeaderView(View view) { 111 | mHeaderViews.put(mHeaderViews.size() + BASE_ITEM_TYPE_HEADER, view); 112 | } 113 | 114 | public void addFootView(View view) { 115 | mFootViews.put(mFootViews.size() + BASE_ITEM_TYPE_FOOTER, view); 116 | } 117 | 118 | public int getHeadersCount() { 119 | return mHeaderViews.size(); 120 | } 121 | 122 | public int getFootersCount() { 123 | return mFootViews.size(); 124 | } 125 | 126 | public RecyclerView.Adapter getInnerAdapter() { 127 | return mInnerAdapter; 128 | } 129 | } -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/IndicatorLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.SuppressLint; 19 | import android.content.Context; 20 | import android.graphics.Matrix; 21 | import android.graphics.drawable.Drawable; 22 | import android.view.View; 23 | import android.view.animation.Animation; 24 | import android.view.animation.Animation.AnimationListener; 25 | import android.view.animation.AnimationUtils; 26 | import android.view.animation.Interpolator; 27 | import android.view.animation.LinearInterpolator; 28 | import android.view.animation.RotateAnimation; 29 | import android.widget.FrameLayout; 30 | import android.widget.ImageView; 31 | import android.widget.ImageView.ScaleType; 32 | 33 | import com.handmark.pulltorefresh.library.PullToRefreshBase; 34 | import com.handmark.pulltorefresh.library.R; 35 | 36 | @SuppressLint("ViewConstructor") 37 | public class IndicatorLayout extends FrameLayout implements AnimationListener { 38 | 39 | static final int DEFAULT_ROTATION_ANIMATION_DURATION = 150; 40 | 41 | private Animation mInAnim, mOutAnim; 42 | private ImageView mArrowImageView; 43 | 44 | private final Animation mRotateAnimation, mResetRotateAnimation; 45 | 46 | public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) { 47 | super(context); 48 | mArrowImageView = new ImageView(context); 49 | 50 | Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow); 51 | mArrowImageView.setImageDrawable(arrowD); 52 | 53 | final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding); 54 | mArrowImageView.setPadding(padding, padding, padding, padding); 55 | addView(mArrowImageView); 56 | 57 | int inAnimResId, outAnimResId; 58 | switch (mode) { 59 | case PULL_FROM_END: 60 | inAnimResId = R.anim.slide_in_from_bottom; 61 | outAnimResId = R.anim.slide_out_to_bottom; 62 | setBackgroundResource(R.drawable.indicator_bg_bottom); 63 | 64 | // Rotate Arrow so it's pointing the correct way 65 | mArrowImageView.setScaleType(ScaleType.MATRIX); 66 | Matrix matrix = new Matrix(); 67 | matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f); 68 | mArrowImageView.setImageMatrix(matrix); 69 | break; 70 | default: 71 | case PULL_FROM_START: 72 | inAnimResId = R.anim.slide_in_from_top; 73 | outAnimResId = R.anim.slide_out_to_top; 74 | setBackgroundResource(R.drawable.indicator_bg_top); 75 | break; 76 | } 77 | 78 | mInAnim = AnimationUtils.loadAnimation(context, inAnimResId); 79 | mInAnim.setAnimationListener(this); 80 | 81 | mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId); 82 | mOutAnim.setAnimationListener(this); 83 | 84 | final Interpolator interpolator = new LinearInterpolator(); 85 | mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 86 | 0.5f); 87 | mRotateAnimation.setInterpolator(interpolator); 88 | mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); 89 | mRotateAnimation.setFillAfter(true); 90 | 91 | mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f, 92 | Animation.RELATIVE_TO_SELF, 0.5f); 93 | mResetRotateAnimation.setInterpolator(interpolator); 94 | mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION); 95 | mResetRotateAnimation.setFillAfter(true); 96 | 97 | } 98 | 99 | public final boolean isVisible() { 100 | Animation currentAnim = getAnimation(); 101 | if (null != currentAnim) { 102 | return mInAnim == currentAnim; 103 | } 104 | 105 | return getVisibility() == View.VISIBLE; 106 | } 107 | 108 | public void hide() { 109 | startAnimation(mOutAnim); 110 | } 111 | 112 | public void show() { 113 | mArrowImageView.clearAnimation(); 114 | startAnimation(mInAnim); 115 | } 116 | 117 | @Override 118 | public void onAnimationEnd(Animation animation) { 119 | if (animation == mOutAnim) { 120 | mArrowImageView.clearAnimation(); 121 | setVisibility(View.GONE); 122 | } else if (animation == mInAnim) { 123 | setVisibility(View.VISIBLE); 124 | } 125 | 126 | clearAnimation(); 127 | } 128 | 129 | @Override 130 | public void onAnimationRepeat(Animation animation) { 131 | // NO-OP 132 | } 133 | 134 | @Override 135 | public void onAnimationStart(Animation animation) { 136 | setVisibility(View.VISIBLE); 137 | } 138 | 139 | public void releaseToRefresh() { 140 | mArrowImageView.startAnimation(mRotateAnimation); 141 | } 142 | 143 | public void pullToRefresh() { 144 | mArrowImageView.startAnimation(mResetRotateAnimation); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/RotateLoadingLayout.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.content.Context; 19 | import android.content.res.TypedArray; 20 | import android.graphics.Matrix; 21 | import android.graphics.drawable.Drawable; 22 | import android.view.animation.Animation; 23 | import android.view.animation.RotateAnimation; 24 | import android.widget.ImageView.ScaleType; 25 | 26 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode; 27 | import com.handmark.pulltorefresh.library.PullToRefreshBase.Orientation; 28 | import com.handmark.pulltorefresh.library.R; 29 | 30 | public class RotateLoadingLayout extends LoadingLayout { 31 | 32 | static final int ROTATION_ANIMATION_DURATION = 1200; 33 | 34 | private final Animation mRotateAnimation; 35 | private final Matrix mHeaderImageMatrix; 36 | 37 | private float mRotationPivotX, mRotationPivotY; 38 | 39 | private final boolean mRotateDrawableWhilePulling; 40 | 41 | public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) { 42 | super(context, mode, scrollDirection, attrs); 43 | 44 | mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true); 45 | 46 | mHeaderImage.setScaleType(ScaleType.MATRIX); 47 | mHeaderImageMatrix = new Matrix(); 48 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 49 | 50 | mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 51 | 0.5f); 52 | mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); 53 | mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); 54 | mRotateAnimation.setRepeatCount(Animation.INFINITE); 55 | mRotateAnimation.setRepeatMode(Animation.RESTART); 56 | } 57 | 58 | public void onLoadingDrawableSet(Drawable imageDrawable) { 59 | if (null != imageDrawable) { 60 | mRotationPivotX = Math.round(imageDrawable.getIntrinsicWidth() / 2f); 61 | mRotationPivotY = Math.round(imageDrawable.getIntrinsicHeight() / 2f); 62 | } 63 | } 64 | 65 | protected void onPullImpl(float scaleOfLayout) { 66 | float angle; 67 | if (mRotateDrawableWhilePulling) { 68 | angle = scaleOfLayout * 90f; 69 | } else { 70 | angle = Math.max(0f, Math.min(180f, scaleOfLayout * 360f - 180f)); 71 | } 72 | 73 | mHeaderImageMatrix.setRotate(angle, mRotationPivotX, mRotationPivotY); 74 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 75 | } 76 | 77 | @Override 78 | protected void refreshingImpl() { 79 | mHeaderImage.startAnimation(mRotateAnimation); 80 | } 81 | 82 | @Override 83 | protected void resetImpl() { 84 | mHeaderImage.clearAnimation(); 85 | resetImageRotation(); 86 | } 87 | 88 | private void resetImageRotation() { 89 | if (null != mHeaderImageMatrix) { 90 | mHeaderImageMatrix.reset(); 91 | mHeaderImage.setImageMatrix(mHeaderImageMatrix); 92 | } 93 | } 94 | 95 | @Override 96 | protected void pullToRefreshImpl() { 97 | // NO-OP 98 | } 99 | 100 | @Override 101 | protected void releaseToRefreshImpl() { 102 | // NO-OP 103 | } 104 | 105 | @Override 106 | protected int getDefaultDrawableResId() { 107 | return R.drawable.default_ptr_rotate; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/Utils.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library.internal; 2 | 3 | import android.util.Log; 4 | 5 | public class Utils { 6 | 7 | static final String LOG_TAG = "PullToRefresh"; 8 | 9 | public static void warnDeprecation(String depreacted, String replacement) { 10 | Log.w(LOG_TAG, "You're using the deprecated " + depreacted + " attr, please switch over to " + replacement); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/ViewCompat.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011, 2012 Chris Banes. 3 | *

4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *

8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *

10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.handmark.pulltorefresh.library.internal; 17 | 18 | import android.annotation.TargetApi; 19 | import android.graphics.drawable.Drawable; 20 | import android.os.Build.VERSION; 21 | import android.os.Build.VERSION_CODES; 22 | import android.view.View; 23 | 24 | @SuppressWarnings("deprecation") 25 | public class ViewCompat { 26 | 27 | public static void postOnAnimation(View view, Runnable runnable) { 28 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { 29 | SDK16.postOnAnimation(view, runnable); 30 | } else { 31 | view.postDelayed(runnable, 16); 32 | } 33 | } 34 | 35 | public static void setBackground(View view, Drawable background) { 36 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { 37 | SDK16.setBackground(view, background); 38 | } else { 39 | view.setBackgroundDrawable(background); 40 | } 41 | } 42 | 43 | public static void setLayerType(View view, int layerType) { 44 | if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) { 45 | SDK11.setLayerType(view, layerType); 46 | } 47 | } 48 | 49 | @TargetApi(11) 50 | static class SDK11 { 51 | 52 | public static void setLayerType(View view, int layerType) { 53 | view.setLayerType(layerType, null); 54 | } 55 | } 56 | 57 | @TargetApi(16) 58 | static class SDK16 { 59 | 60 | public static void postOnAnimation(View view, Runnable runnable) { 61 | view.postOnAnimation(runnable); 62 | } 63 | 64 | public static void setBackground(View view, Drawable background) { 65 | view.setBackground(background); 66 | } 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/ViewHolder.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library.internal; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Paint; 7 | import android.graphics.Typeface; 8 | import android.graphics.drawable.Drawable; 9 | import android.os.Build; 10 | import android.support.v7.widget.RecyclerView; 11 | import android.text.util.Linkify; 12 | import android.util.SparseArray; 13 | import android.view.LayoutInflater; 14 | import android.view.View; 15 | import android.view.ViewGroup; 16 | import android.view.animation.AlphaAnimation; 17 | import android.widget.Checkable; 18 | import android.widget.ImageView; 19 | import android.widget.ProgressBar; 20 | import android.widget.RatingBar; 21 | import android.widget.TextView; 22 | 23 | public class ViewHolder extends RecyclerView.ViewHolder { 24 | private SparseArray mViews; 25 | private View mConvertView; 26 | private Context mContext; 27 | 28 | public ViewHolder(Context context, View itemView) { 29 | super(itemView); 30 | mContext = context; 31 | mConvertView = itemView; 32 | mViews = new SparseArray(); 33 | } 34 | 35 | 36 | public static ViewHolder createViewHolder(Context context, View itemView) { 37 | ViewHolder holder = new ViewHolder(context, itemView); 38 | return holder; 39 | } 40 | 41 | public static ViewHolder createViewHolder(Context context, 42 | ViewGroup parent, int layoutId) { 43 | View itemView = LayoutInflater.from(context).inflate(layoutId, parent, 44 | false); 45 | ViewHolder holder = new ViewHolder(context, itemView); 46 | return holder; 47 | } 48 | 49 | /** 50 | * 通过viewId获取控件 51 | * 52 | * @param viewId 53 | * @return 54 | */ 55 | public T getView(int viewId) { 56 | View view = mViews.get(viewId); 57 | if (view == null) { 58 | view = mConvertView.findViewById(viewId); 59 | mViews.put(viewId, view); 60 | } 61 | return (T) view; 62 | } 63 | 64 | public View getConvertView() { 65 | return mConvertView; 66 | } 67 | 68 | 69 | /****以下为辅助方法*****/ 70 | 71 | /** 72 | * 设置TextView的值 73 | * 74 | * @param viewId 75 | * @param text 76 | * @return 77 | */ 78 | public ViewHolder setText(int viewId, String text) { 79 | TextView tv = getView(viewId); 80 | tv.setText(text); 81 | return this; 82 | } 83 | 84 | public ViewHolder setImageResource(int viewId, int resId) { 85 | ImageView view = getView(viewId); 86 | view.setImageResource(resId); 87 | return this; 88 | } 89 | 90 | public ViewHolder setImageBitmap(int viewId, Bitmap bitmap) { 91 | ImageView view = getView(viewId); 92 | view.setImageBitmap(bitmap); 93 | return this; 94 | } 95 | 96 | public ViewHolder setImageDrawable(int viewId, Drawable drawable) { 97 | ImageView view = getView(viewId); 98 | view.setImageDrawable(drawable); 99 | return this; 100 | } 101 | 102 | public ViewHolder setBackgroundColor(int viewId, int color) { 103 | View view = getView(viewId); 104 | view.setBackgroundColor(color); 105 | return this; 106 | } 107 | 108 | public ViewHolder setBackgroundRes(int viewId, int backgroundRes) { 109 | View view = getView(viewId); 110 | view.setBackgroundResource(backgroundRes); 111 | return this; 112 | } 113 | 114 | public ViewHolder setTextColor(int viewId, int textColor) { 115 | TextView view = getView(viewId); 116 | view.setTextColor(textColor); 117 | return this; 118 | } 119 | 120 | public ViewHolder setTextColorRes(int viewId, int textColorRes) { 121 | TextView view = getView(viewId); 122 | view.setTextColor(mContext.getResources().getColor(textColorRes)); 123 | return this; 124 | } 125 | 126 | @SuppressLint("NewApi") 127 | public ViewHolder setAlpha(int viewId, float value) { 128 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { 129 | getView(viewId).setAlpha(value); 130 | } else { 131 | // Pre-honeycomb hack to set Alpha value 132 | AlphaAnimation alpha = new AlphaAnimation(value, value); 133 | alpha.setDuration(0); 134 | alpha.setFillAfter(true); 135 | getView(viewId).startAnimation(alpha); 136 | } 137 | return this; 138 | } 139 | 140 | public ViewHolder setVisible(int viewId, boolean visible) { 141 | View view = getView(viewId); 142 | view.setVisibility(visible ? View.VISIBLE : View.GONE); 143 | return this; 144 | } 145 | 146 | public ViewHolder linkify(int viewId) { 147 | TextView view = getView(viewId); 148 | Linkify.addLinks(view, Linkify.ALL); 149 | return this; 150 | } 151 | 152 | public ViewHolder setTypeface(Typeface typeface, int... viewIds) { 153 | for (int viewId : viewIds) { 154 | TextView view = getView(viewId); 155 | view.setTypeface(typeface); 156 | view.setPaintFlags(view.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG); 157 | } 158 | return this; 159 | } 160 | 161 | public ViewHolder setProgress(int viewId, int progress) { 162 | ProgressBar view = getView(viewId); 163 | view.setProgress(progress); 164 | return this; 165 | } 166 | 167 | public ViewHolder setProgress(int viewId, int progress, int max) { 168 | ProgressBar view = getView(viewId); 169 | view.setMax(max); 170 | view.setProgress(progress); 171 | return this; 172 | } 173 | 174 | public ViewHolder setMax(int viewId, int max) { 175 | ProgressBar view = getView(viewId); 176 | view.setMax(max); 177 | return this; 178 | } 179 | 180 | public ViewHolder setRating(int viewId, float rating) { 181 | RatingBar view = getView(viewId); 182 | view.setRating(rating); 183 | return this; 184 | } 185 | 186 | public ViewHolder setRating(int viewId, float rating, int max) { 187 | RatingBar view = getView(viewId); 188 | view.setMax(max); 189 | view.setRating(rating); 190 | return this; 191 | } 192 | 193 | public ViewHolder setTag(int viewId, Object tag) { 194 | View view = getView(viewId); 195 | view.setTag(tag); 196 | return this; 197 | } 198 | 199 | public ViewHolder setTag(int viewId, int key, Object tag) { 200 | View view = getView(viewId); 201 | view.setTag(key, tag); 202 | return this; 203 | } 204 | 205 | public ViewHolder setChecked(int viewId, boolean checked) { 206 | Checkable view = (Checkable) getView(viewId); 207 | view.setChecked(checked); 208 | return this; 209 | } 210 | 211 | /** 212 | * 关于事件的 213 | */ 214 | public ViewHolder setOnClickListener(int viewId, 215 | View.OnClickListener listener) { 216 | View view = getView(viewId); 217 | view.setOnClickListener(listener); 218 | return this; 219 | } 220 | 221 | public ViewHolder setOnTouchListener(int viewId, 222 | View.OnTouchListener listener) { 223 | View view = getView(viewId); 224 | view.setOnTouchListener(listener); 225 | return this; 226 | } 227 | 228 | public ViewHolder setOnLongClickListener(int viewId, 229 | View.OnLongClickListener listener) { 230 | View view = getView(viewId); 231 | view.setOnLongClickListener(listener); 232 | return this; 233 | } 234 | 235 | 236 | } -------------------------------------------------------------------------------- /library/src/main/java/com/handmark/pulltorefresh/library/internal/WrapperUtils.java: -------------------------------------------------------------------------------- 1 | package com.handmark.pulltorefresh.library.internal; 2 | 3 | import android.support.v7.widget.GridLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.support.v7.widget.StaggeredGridLayoutManager; 6 | import android.view.ViewGroup; 7 | 8 | public class WrapperUtils { 9 | public interface SpanSizeCallback { 10 | int getSpanSize(GridLayoutManager layoutManager, GridLayoutManager.SpanSizeLookup oldLookup, int position); 11 | } 12 | 13 | public static void onAttachedToRecyclerView(RecyclerView.Adapter innerAdapter, RecyclerView recyclerView, final SpanSizeCallback callback) { 14 | innerAdapter.onAttachedToRecyclerView(recyclerView); 15 | 16 | RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); 17 | if (layoutManager instanceof GridLayoutManager) { 18 | final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager; 19 | final GridLayoutManager.SpanSizeLookup spanSizeLookup = gridLayoutManager.getSpanSizeLookup(); 20 | 21 | gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { 22 | @Override 23 | public int getSpanSize(int position) { 24 | return callback.getSpanSize(gridLayoutManager, spanSizeLookup, position); 25 | } 26 | }); 27 | gridLayoutManager.setSpanCount(gridLayoutManager.getSpanCount()); 28 | } 29 | } 30 | 31 | public static void setFullSpan(RecyclerView.ViewHolder holder) { 32 | ViewGroup.LayoutParams lp = holder.itemView.getLayoutParams(); 33 | 34 | if (lp != null 35 | && lp instanceof StaggeredGridLayoutManager.LayoutParams) { 36 | 37 | StaggeredGridLayoutManager.LayoutParams p = (StaggeredGridLayoutManager.LayoutParams) lp; 38 | 39 | p.setFullSpan(true); 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /library/src/main/res/anim/slide_in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/anim/slide_in_from_top.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/anim/slide_out_to_bottom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/anim/slide_out_to_top.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/default_ptr_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-hdpi/default_ptr_flip.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/default_ptr_rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-hdpi/default_ptr_rotate.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-hdpi/indicator_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-hdpi/indicator_arrow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/default_ptr_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-mdpi/default_ptr_flip.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/default_ptr_rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-mdpi/default_ptr_rotate.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-mdpi/indicator_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-mdpi/indicator_arrow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/default_ptr_flip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-xhdpi/default_ptr_flip.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/default_ptr_rotate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-xhdpi/default_ptr_rotate.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/indicator_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iflove/Android-PullToRefresh/aed1ba8939d81b69f5a4f6bc7919c337ea5c9e31/library/src/main/res/drawable-xhdpi/indicator_arrow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable/indicator_bg_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/indicator_bg_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 17 | 18 | -------------------------------------------------------------------------------- /library/src/main/res/layout/pull_to_refresh_header_horizontal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 18 | 19 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /library/src/main/res/layout/pull_to_refresh_header_vertical.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 17 | 18 | 23 | 24 | 32 | 33 | 34 | 40 | 41 | 48 | 49 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /library/src/main/res/values-ar/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | اسحب للتحديث… 4 | اترك للتحديث… 5 | تحميل… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-cs/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tažením aktualizujete… 4 | Uvolněním aktualizujete… 5 | Načítání… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-de/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Ziehen zum Aktualisieren… 4 | Loslassen zum Aktualisieren… 5 | Laden… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-es/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tirar para actualizar… 4 | Soltar para actualizar… 5 | Cargando… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-fi/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Päivitä vetämällä alas… 5 | Päivitä vapauttamalla… 6 | Päivitetään… 7 | 8 | 9 | Päivitä vetämällä ylös… 10 | @string/pull_to_refresh_release_label 11 | @string/pull_to_refresh_refreshing_label 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/values-fr/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tirez pour rafraîchir… 4 | Relâcher pour rafraîchir… 5 | Chargement… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-he/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | משוך לרענון… 4 | שחרר לרענון… 5 | טוען… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-it/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Tira per aggiornare… 4 | Rilascia per aggionare… 5 | Caricamento… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-iw/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | משוך לרענון… 4 | שחרר לרענון… 5 | טוען… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-ja/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 画面を引っ張って… 4 | 指を離して更新… 5 | 読み込み中… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-ko/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 당겨서 새로 고침… 4 | 놓아서 새로 고침… 5 | 로드 중… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-nl/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sleep om te vernieuwen… 4 | Loslaten om te vernieuwen… 5 | Laden… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-pl/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Pociągnij, aby odświeżyć… 4 | Puść, aby odświeżyć… 5 | Wczytywanie… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-pt-rBR/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Puxe para atualizar… 4 | Libere para atualizar… 5 | Carregando… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-pt/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Puxe para atualizar… 4 | Liberação para atualizar… 5 | A carregar… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-ro/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Trage pentru a reîmprospăta… 4 | Eliberează pentru a reîmprospăta… 5 | Încărcare… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-ru/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Потяните для обновления… 4 | Отпустите для обновления… 5 | Загрузка… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values-zh/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 下拉刷新… 4 | 放开以刷新… 5 | 正在载入… 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 66 | 67 | 68 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /library/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10dp 5 | 12dp 6 | 4dp 7 | 24dp 8 | 12dp 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /library/src/main/res/values/pull_refresh_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Pull to refresh… 5 | Release to refresh… 6 | Loading… 7 | 8 | 9 | @string/pull_to_refresh_pull_label 10 | @string/pull_to_refresh_release_label 11 | @string/pull_to_refresh_refreshing_label 12 | 13 | -------------------------------------------------------------------------------- /library/src/test/java/com/lazy/library/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.lazy.library; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library', 'extras/:pulltorefreshlistfragment', 'extras/:pulltorefreshviewpager' 2 | --------------------------------------------------------------------------------