Giter VIP home page Giter VIP logo

android-ultra-pull-to-refresh's Introduction

Welcome to follow me on GitHub or Twitter

GitHub: https://github.com/liaohuqiu

Twitter: https://twitter.com/liaohuqiu


Build Status Android Arsenal

Wanna auto-load-more? This will be what you want: https://github.com/liaohuqiu/android-cube-app

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.

Download APK

  • 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:

<dependency>
    <groupId>in.srain.cube</groupId>
    <artifactId>ultra-ptr</artifactId>
    <type>aar</type>
    <!-- or apklib format, if you want -->
    <!-- <type>apklib</type> -->
    <version>1.0.11</version>
</dependency>

pom.xml, stable version:

<dependency>
    <groupId>in.srain.cube</groupId>
    <artifactId>ultra-ptr</artifactId>
    <type>aar</type>
    <!-- or apklib format, if you want -->
    <!-- <type>apklib</type> -->
    <version>1.0.11</version>
</dependency>

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
<in.srain.cube.views.ptr.PtrFrameLayout
    android:id="@+id/store_house_ptr_frame"
    xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    cube_ptr:ptr_resistance="1.7"
    cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
    cube_ptr:ptr_duration_to_close="300"
    cube_ptr:ptr_duration_to_close_header="2000"
    cube_ptr:ptr_keep_header_when_refresh="true"
    cube_ptr:ptr_pull_to_fresh="false" >

    <LinearLayout
        android:id="@+id/store_house_ptr_image_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/cube_mints_333333"
        android:clickable="true"
        android:padding="10dp">

        <in.srain.cube.image.CubeImageView
            android:id="@+id/store_house_ptr_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>

</in.srain.cube.views.ptr.PtrFrameLayout>

Or config in java code

// the following are default settings
mPtrFrame.setResistance(1.7f);
mPtrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
mPtrFrame.setDurationToClose(200);
mPtrFrame.setDurationToCloseHeader(1000);
// default is false
mPtrFrame.setPullToRefresh(false);
// default is true
mPtrFrame.setKeepHeaderWhenRefresh(true);

Other Config

  • setPinContent. Pin the content, only the HeaderView will be moved.

    This's the the performance of material style in support package v19.

StoreHouse Style

  • Config using string:
// header
final StoreHouseHeader header = new StoreHouseHeader(getContext());
header.setPadding(0, LocalDisplay.dp2px(15), 0, 0);

/**
 * using a string, support: A-Z 0-9 - .
 * you can add more letters by {@link in.srain.cube.views.ptr.header.StoreHousePath#addChar}
 */
header.initWithString('Alibaba');
  • Config using string array from xml:
header.initWithStringArray(R.array.storehouse);

And in res/values/arrays.xml:

<resources>
    <string-array name="storehouse">
        <item>0,35,12,42,</item>
        <item>12,42,24,35,</item>
        <item>24,35,12,28,</item>
        <item>0,35,12,28,</item>
        <item>0,21,12,28,</item>
        <item>12,28,24,21,</item>
        <item>24,35,24,21,</item>
        <item>24,21,12,14,</item>
        <item>0,21,12,14,</item>
        <item>0,21,0,7,</item>
        <item>12,14,0,7,</item>
        <item>12,14,24,7,</item>
        <item>24,7,12,0,</item>
        <item>0,7,12,0,</item>
    </string-array>
</resources>

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:

ptrFrame.setPtrHandler(new PtrHandler() {
    @Override
    public void onRefreshBegin(PtrFrameLayout frame) {
        frame.postDelayed(new Runnable() {
            @Override
            public void run() {
                ptrFrame.refreshComplete();
            }
        }, 1800);
    }

    @Override
    public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
        return PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
    }
});

Customize

You can add a PtrUIHandler to PtrFrameLayout to implement any UI effect you want.

public interface PtrUIHandler {

    /**
     * When the content view has reached top and refresh has been completed, view will be reset.
     *
     * @param frame
     */
    public void onUIReset(PtrFrameLayout frame);

    /**
     * prepare for loading
     *
     * @param frame
     */
    public void onUIRefreshPrepare(PtrFrameLayout frame);

    /**
     * perform refreshing UI
     */
    public void onUIRefreshBegin(PtrFrameLayout frame);

    /**
     * perform UI after refresh
     */
    public void onUIRefreshComplete(PtrFrameLayout frame);

    public void onUIPositionChange(PtrFrameLayout frame, boolean isUnderTouch, byte status, int oldPosition, int currentPosition, float oldPercent, float currentPercent);
}

Q & A

  • work with ViewPager: disableWhenHorizontalMove()

  • work with LongPressed, setInterceptEventWhileWorking()

Contact & Help

Please fell free to contact me if there is any problem when using the library.

android-ultra-pull-to-refresh's People

Contributors

ackywow avatar avenwu avatar comtu avatar defipanda avatar funorpain avatar liaohuqiu avatar uknownothingsnow avatar xuxucode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-ultra-pull-to-refresh's Issues

加入多点触控

具体参照QQ的下拉刷新,这是目前流行的,很多操作系统也是,例如miui,魅族ui,这样设计很人性化,这就是细节,做好细节才能立于不败之地,如果只是做成现在的样子,那么随便那一个过来都差不多。另外希望加入自动加载更多,没有更多数据显示已经加载全部数据,加入几个接口,用户自己控制就可以了,比如,setHasMoreData(false);//是否有更多数据,setAutoLoadMoreData();//是否自动加载更多数据。

First element of the list get cropped while pulling to refresh for api <11

Using listview or gridview into a PtrClassicFrameLayout has a bug for device < 11.
When pressing and pulling to refresh, make sure to keep pressing and go up and down, you should notice that the first element for the list get cropped. It is like the pull to refresh (PtrClassicFrameLayout) get triggered before the top of the list.
Please check the .gif using the current app of this demo on Genymotion 2.3.7

bug_less_11

it can't be compatible with android's fragment. there is always a zero variable

java.lang.IllegalArgumentException: n <= 0: 0
at java.util.Random.nextInt(Random.java:175)
at in.srain.cube.views.ptr.header.StoreHouseBarItem.resetPosition(StoreHouseBarItem.java:50)
at in.srain.cube.views.ptr.header.StoreHouseHeader.initWithPointList(StoreHouseHeader.java:166)
at in.srain.cube.views.ptr.header.StoreHouseHeader.initWithString(StoreHouseHeader.java:123)
at in.srain.cube.views.ptr.header.StoreHouseHeader.initWithString(StoreHouseHeader.java:118)
at com.hiroz.myapp.MainFragment.onCreateView(MainFragment.java:62)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1504)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:942)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:482)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
at android.view.View.measure(View.java:16497)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
at android.view.View.measure(View.java:16497)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

还是搞不定啊

一个Viewpager 里面全是Fragment的,framgent 里面是Listview,现在的情况是,把listview往下滑,只要滑动超过一个item的高度,在往上拉的过程中,就会出现刷新按钮。~~~~~~~~~~~~~~~~~~~~
试着用listview firstVisbleItem 去判断, 依然不好使~

我这种情况应该很多见吧,望大神解答·~

在ObservableListView中下拉刷新不能正常工作

hi
我使用https://github.com/ksoichiro/Android-ObservableScrollView 和android-Ultra-Pull-To-Refresh,一起使用的时候下拉刷新就不能正常工作了,希望能得到你得帮助或一些建议。谢谢

我使用的类似这个https://github.com/ksoichiro/Android-ObservableScrollView/blob/master/observablescrollview-samples/src/main/java/com/github/ksoichiro/android/observablescrollview/samples/ViewPagerTabListViewActivity.java

android-Ultra-Pull-To-Refresh也是按照正常配置的,但在下拉时好像是不能正常计算了,上滑后,只要下拉就会响应,不管listview是否在position 0的位置。不知道我还需要做些什么,感谢。

CLog is not included

CLog is not being packaged with the AAR, and is not listed as a dependency. This forces users of this library to include Clog separately, if log output is needed (not sure if this is intentional).

E/AndroidRuntime(12522): FATAL EXCEPTION: main
E/AndroidRuntime(12522): Process: com.snapchat.android.flavortest, PID: 12522
E/AndroidRuntime(12522): java.lang.NoClassDefFoundError: Failed resolution of: Lin/srain/cube/util/CLog;
E/AndroidRuntime(12522):    at in.srain.cube.views.ptr.PtrFrameLayout.onMeasure(PtrFrameLayout.java:166)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
E/AndroidRuntime(12522):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1456)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
E/AndroidRuntime(12522):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
E/AndroidRuntime(12522):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5135)
E/AndroidRuntime(12522):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
E/AndroidRuntime(12522):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
E/AndroidRuntime(12522):    at android.view.View.measure(View.java:16537)
E/AndroidRuntime(12522):    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1947)
E/AndroidRuntime(12522):    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1137)
E/AndroidRuntime(12522):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1326)
E/AndroidRuntime(12522):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1024)
E/AndroidRuntime(12522):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5796)
E/AndroidRuntime(12522):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
E/AndroidRuntime(12522):    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
E/AndroidRuntime(12522):    at android.view.Choreographer.doFrame(Choreographer.java:544)
E/AndroidRuntime(12522):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
E/AndroidRuntime(12522):    at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime(12522):    at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(12522):    at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(12522):    at android.app.ActivityThread.main(ActivityThread.java:5102)
E/AndroidRuntime(12522):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(12522):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
E/AndroidRuntime(12522):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
E/AndroidRuntime(12522): Caused by: java.lang.ClassNotFoundException: Didn't find class "in.srain.cube.util.CLog" on path: DexPathList[[zip file "/data/app/com.snapchat.android.flavortest-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.snapchat.android.flavortest-1, /vendor/lib, /system/lib]]
E/AndroidRuntime(12522):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(12522):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(12522):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(12522):    ... 44 more
E/AndroidRuntime(12522):    Suppressed: java.lang.ClassNotFoundException: in.srain.cube.util.CLog
E/AndroidRuntime(12522):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(12522):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(12522):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(12522):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(12522):        ... 45 more
E/AndroidRuntime(12522):    Caused by: java.lang.NoClassDefFoundError: Class "Lin/srain/cube/util/CLog;" not found
E/AndroidRuntime(12522):        ... 49 more

aar R issue

When packaged as aar, R can not be found when import to project.

your apk link is dead

I would like to mention that your APK link is dead. I am trying to see the demo on the pull refresh thing.

thank you so much.

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find com.google.android:support-v4:r18.
     Searched in the following locations:
         https://jcenter.bintray.com/com/google/android/support-v4/r18/support-v4-r18.pom
         https://jcenter.bintray.com/com/google/android/support-v4/r18/support-v4-r18.jar
         file:/Users/hesk/Library/Android/sdk/extras/android/m2repository/com/google/android/support-v4/r18/support-v4-r18.pom
         file:/Users/hesk/Library/Android/sdk/extras/android/m2repository/com/google/android/support-v4/r18/support-v4-r18.jar
         file:/Users/hesk/Library/Android/sdk/extras/google/m2repository/com/google/android/support-v4/r18/support-v4-r18.pom
         file:/Users/hesk/Library/Android/sdk/extras/google/m2repository/com/google/android/support-v4/r18/support-v4-r18.jar
     Required by:
         UltraPullRefresh:app:unspecified > in.srain.cube:cube-sdk:1.0.22

如何实现content view区域上的背景

能不能请教下大神demo里content view区域上面的所有部分的背景是灰色的是怎么实现的呢(也就是说那个背景的区域和header不是一个layout)?多谢了!

header setMargins is not working

I set header margins like this:

FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(20, 20, 20, 20);
mPtrClassicHeader.setLayoutParams(lp);
mPtrClassicHeader.setBackgroundColor(Color.BLUE);
setHeaderView(mPtrClassicHeader);

but header leftMargin, rightMargin is still =0
Image

Not working in my case

I have this in my layout file

<in.srain.cube.views.ptr.PtrFrameLayout
        xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/ptr_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        cube_ptr:ptr_resistance="1.7"
        cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
        cube_ptr:ptr_duration_to_close="300"
        cube_ptr:ptr_duration_to_close_header="2000"
        cube_ptr:ptr_keep_header_when_refresh="true"
        cube_ptr:ptr_pull_to_fresh="false" >
        <ListView
            android:id="@+id/home_list_view"
            style="@style/hashtag_listview"/>
</in.srain.cube.views.ptr.PtrFrameLayout>

And this in my Java code

ptrFrame.setPtrHandler(new PtrDefaultHandler() {
            @Override
            public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
                L.l("refresh begins");
            }
});

But it does not work at all. When I pull on the ListView, nothing happens. there is no view scrolling down from the top, as if i wasn't doing anything.
I'm using the latest version:
compile 'in.srain.cube:ultra-ptr:1.0.8@aar'

How do I add listview with emptyview? the PtrFrameLayout only can host 2 elements

<in.srain.cube.views.ptr.PtrClassicFrameLayout
    android:id="@+id/rotate_header_list_view_frame"
    xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    cube_ptr:ptr_duration_to_close="200"
    cube_ptr:ptr_duration_to_close_header="1000"
    cube_ptr:ptr_keep_header_when_refresh="true"
    cube_ptr:ptr_pull_to_fresh="false"
    cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
    cube_ptr:ptr_resistance="1.7">

    <ListView
        android:id="@+id/rotate_header_list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/primary"
        android:divider="@null"
        android:fadingEdge="none"
        android:listSelector="@android:color/transparent"
        android:paddingLeft="12dp"
        android:paddingRight="12dp"
        android:scrollbarStyle="outsideOverlay"
        android:choiceMode="singleChoice" />

    <TextView
        android:id="@+id/empty"
        android:text="empty view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</in.srain.cube.views.ptr.PtrClassicFrameLayout>

the above code is wrong, because PtrFrameLayout only can host 2 elements? what can i do?

Scroll error in header

Hi, I have the following problem when I pull to refresh, the header begins to go down , like if I were scrolling a ListView. I attach an image to show you the problem.
screenshot_2014-12-09-14-59-18_1024

Publish to MavenCentral with gradle

Invalid POM: /in/srain/cube/ultra-ptr/1.0.3/ultra-ptr-1.0.3.pom: 
Invalid version for Dependency 
{groupId=com.android.support, artifactId=support-v4, version=20.+, type=jar} - uses invalid dynamic 
version syntax. 
Replace with a fixed version or standard mathematical notation e.g., [1.5,) for version 1.5 
and higher.

Key files in shortage.

Files like dimens.xml or styles.xml lacks. Meanwhile, in.srain.cube.Cube or something like that, is in shortage, too.
Then, I can't run ptr-demo at all.

android studio cannot render a preview

AS cannot render a preview when I wrap a view with ultra-ptr it just show this exception:

java.lang.NullPointerException
at in.srain.cube.views.ptr.PtrClassicDefaultHeader.hideRotateView(PtrClassicDefaultHeader.java:114)
at in.srain.cube.views.ptr.PtrClassicDefaultHeader.resetView(PtrClassicDefaultHeader.java:109)
at in.srain.cube.views.ptr.PtrClassicDefaultHeader.initViews(PtrClassicDefaultHeader.java:64)
at in.srain.cube.views.ptr.PtrClassicDefaultHeader.(PtrClassicDefaultHeader.java:37)
at in.srain.cube.views.ptr.PtrClassicFrameLayout.initViews(PtrClassicFrameLayout.java:30)
at in.srain.cube.views.ptr.PtrClassicFrameLayout.(PtrClassicFrameLayout.java:21)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:379)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:99)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:401)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:333)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:674)
at com.android.tools.idea.rendering.RenderService$5.compute(RenderService.java:663)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:663)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:790)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:611)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:81)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:553)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:548)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

ListView + MaterialStyle

Hi,

Great component! 👍

I tried implementing the material style with listview. Got it working. However I can scroll down but not scroll up the list. The list would refresh instead of showing previous row.

Here's my code

<in.srain.cube.views.ptr.PtrFrameLayout
        android:id="@+id/material_style_ptr_frame"
        xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        cube_ptr:ptr_duration_to_close="300"
        cube_ptr:ptr_duration_to_close_header="2000"
        cube_ptr:ptr_keep_header_when_refresh="true"
        cube_ptr:ptr_pull_to_fresh="false"
        cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
        cube_ptr:ptr_resistance="1.7">
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@android:id/list"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:background="@android:color/white"
            android:clickable="true"
            android:choiceMode="singleChoice"
            android:smoothScrollbar="true"
            android:clipToPadding="false"/>
    </in.srain.cube.views.ptr.PtrFrameLayout>

onRefreshBegin never invoked

Hi!
onRefreshBegin as well as checkCanDoRefresh are never invoked and thus the refresh action is never actually triggered.
I've tested whether the PtrFrameLayout is visible and at the right place in the GUI by setting its background color to green and this way I verified that it is in fact visible. Also I've verified that the corresponding part of my code which sets up the PtrDefaultHandler is invoked correctly, also fine.
Here my code, where as the code within the PtrDefaultHandler is never called.

Log.d("setting up comment closer");
pullToRefreshLayout.setPtrHandler(new PtrDefaultHandler() {
            @Override
            public void onRefreshBegin(PtrFrameLayout frame) {
                Log.d("onRefreshBegin");
                if (slidingLayout != null && slidingLayout.isPanelExpanded()) {
                    slidingLayout.collapsePanel();
                }
                pullToRefreshLayout.refreshComplete();
            }

            @Override
            public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
                Log.d("checkCanDoRefresh");
                return true;
            }
        });

Again, none of the log messages except for the first which verifies that the handler is setup, is ever printed.

资源文件缺少

color.xml 文件缺少。Error:(31, 37) No resource found that matches the given name (at 'background' with value '@color/cube_mints_4d90fe').

PtrDefaultHandler issue

在PtrDefaultHandler 类中

if (viewGroup instanceof AbsListView) {
AbsListView listView = (AbsListView) viewGroup;
if (listView.getFirstVisiblePosition() > 0) {
return false;
}
}

判断是否可以下拉中 listView.getFirstVisiblePosition() > 0 是不是存在一些问题,如果ListView惯性滑动没问题,如果一点点往下拉,就会出现当ListView第0个位置的item出现一点点 这时候 listView.getFirstVisiblePosition()就等于0了..就满足了下拉条件..实际上listView这时候并没有完全让第一条item显示完全 ...不知这算不算个问题
感谢大神提供这个很酷的开源组件.

Missing application tag in androidmanifest causes robolectric failures

Hello

Robolectric tests are failing because when I import your library the androidmanifest does not contain an application tag. If you don't need one then you still need to include an empty one:

<application/> 

This is the exception.

WARNING: no system properties value for ro.build.date.utc
java.lang.IllegalArgumentException: Missing required <application/> element in .\gen-external-apklibs\in.srain.cube_ultra-ptr_1.0.7\AndroidManifest.xml
    at org.robolectric.AndroidManifest.parseAndroidManifest(AndroidManifest.java:155)
    at org.robolectric.AndroidManifest.getPackageName(AndroidManifest.java:474)
    at org.robolectric.AndroidManifest.getResourcePath(AndroidManifest.java:517)
    at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:522)
    at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:524)
    at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:635)
    at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:627)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:67)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:440)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:222)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:158)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)

java.lang.RuntimeException: java.lang.IllegalArgumentException: Missing required <application/> element in .\gen-external-apklibs\in.srain.cube_ultra-ptr_1.0.7\AndroidManifest.xml
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:226)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:158)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.IllegalArgumentException: Missing required <application/> element in .\gen-external-apklibs\in.srain.cube_ultra-ptr_1.0.7\AndroidManifest.xml
    at org.robolectric.AndroidManifest.parseAndroidManifest(AndroidManifest.java:155)
    at org.robolectric.AndroidManifest.getPackageName(AndroidManifest.java:474)
    at org.robolectric.AndroidManifest.getResourcePath(AndroidManifest.java:517)
    at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:522)
    at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:524)
    at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:635)
    at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:627)
    at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:67)
    at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:440)
    at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:222)
    ... 19 more


Process finished with exit code -1

ScrollChecker.finish will be triggered twice.

qq 20150206105144

Mr.Monkey(5748295)  10:39:06 AM

还有这个地方,用的是||,我之前项目里面有时候刷新之后弹不上去

我这边改成&&了,反馈一下
ec的是我之前项目环境自己迁的

廖祜秋(99950656)  10:40:02 AM
abortIfWorking 会强制停止。所以要 ||
你什么时候fork的,最初的version是有无法弹回的情况,在release 1.0.1 之前的

Mr.Monkey(5748295)  10:42:25 AM
用||,我在项目里遇到过无法弹回的现象,我看了一下,应该是现在版本也会有的,等再遇到这个问题,我跟你反馈好了。之前这个问题是,我debug得出的结论是,用||的话,会两次触发finish,是一个偶发性的bug
只触发一次finishi的时候能弹回,
触发两次就无法弹回了。然后我就改成&&

希望增加固定头部的配置

即头部不是下拉而出现的,而是一直存在。我们下拉只是获得回调,并改变头部状态,但是并不会改变头部的位置。
形象一点,就是我想实现swiperefreshlayout早期的那种样式。

172338022242315

can author give a demo with viewpager? thx

within a viewpager, i see this in PtrFrameLayout, but i also can not solve the conflict simply. thanks!

public void disableWhenHorizontalMove(boolean disable) {
    mDisableWhenHorizontalMove = disable;
}

PRESSED_STATE do not release after pulltorefresh begin loading.

I implemented PtrClassicFrameLayout in my listview.
My listview has custom selector by set background as an selector drawable to child layout

this is this selector drawable

<item android:drawable="@color/list_view_selected" android:state_pressed="true"></item>
<item android:drawable="@color/list_view_selected" android:state_selected="true"></item>
<item android:drawable="@android:color/white"></item>

My issue is PRESSED_STATE do not release after pulltorefresh begin loading.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.