Ultra Pull To Refresh
It's a replacement for the deprecated pull to refresh solution. It can contain any view you want.
It's easy to use and more powerful than SwipeRefreshLayout.
It's well designed, you can customize the UI effect you want as easy as adding a headview to ListView.
Support API LEVEL >= 8, all snapshots are taken from Genymotion, 2.3.7.
-
StoreHouse Style first! Thanks to CBStoreHouseRefreshControl.
-
Material Style, added @ 2014-12-09. There is a beautiful shadow which looks terrible in gif snapshot. Please Check out the DEMO.
-
Supports all of the views:
ListView, GridView, ScrollView, FrameLayout, or Even a single TextView. -
Supports all of the refresh types.
-
pull to refresh
-
release to refresh
-
keep header when refresh
-
hide header when refresh
-
auto refresh
-
Usage
Maven Central
This project has been pushed to Maven Central, both in aar
and apklib
.
The latest version: 1.0.11
, has been published to: https://oss.sonatype.org/content/repositories/snapshots, in gradle:
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
The stable version: 1.0.11
, https://oss.sonatype.org/content/repositories/releases, in gradle:
mavenCentral()
pom.xml, latest version:
pom.xml, stable version:
gradle, latest version:
compile 'in.srain.cube:ultra-ptr:1.0.11'
gradle, stable version:
compile 'in.srain.cube:ultra-ptr:1.0.11'
Config
There are 6 properties:
-
Resistence
This is the resistence while you are moving the frame, default is:
1.7f
. -
Ratio of the Height of the Header to Refresh
The ratio of the height of the header to trigger refresh, default is:
1.2f
. -
Duration to Close
The duration for moving from the position you relase the view to the height of header, default is
200ms
. -
Duration to Close Header
The default value is
1000ms
-
Keep Header while Refreshing
The default value is
true
. -
Pull to Refresh / Release to Refresh
The default value is Release to Refresh.
Config in xml
Or config in java code
Other Config
-
setPinContent
. Pin the content, only theHeaderView
will be moved.This's the the performance of material style in support package v19.
StoreHouse Style
- Config using string:
- Config using string array from xml:
And in res/values/arrays.xml
:
Process Refresh
There is a PtrHandler
, by which you can refresh the data.
public interface PtrHandler {
/**
* Check can do refresh or not. For example the content is empty or the first child is in view.
* <p/>
* {@link in.srain.cube.views.ptr.PtrDefaultHandler#checkContentCanBePulledDown}
*/
public boolean checkCanDoRefresh(final PtrFrameLayout frame, final View content, final View header);
/**
* When refresh begin
*
* @param frame
*/
public void onRefreshBegin(final PtrFrameLayout frame);
}
An example:
Customize
You can add a PtrUIHandler
to PtrFrameLayout
to implement any UI effect you want.