Coder Social home page Coder Social logo

android-pulltorefresh's Introduction

Pull To Refresh for Android

Note This library is deprecated, a swipe refresh layout is available in the v4 support library.


This project aims to provide a reusable pull to refresh widget for Android.

Screenshot

Repository at https://github.com/johannilsson/android-pulltorefresh.

Usage

Layout

<!--
  The PullToRefreshListView replaces a standard ListView widget.
-->
<com.markupartist.android.widget.PullToRefreshListView
    android:id="@+id/android:list"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    />

Activity

// Set a listener to be invoked when the list should be refreshed.
((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Do work to refresh the list here.
        new GetDataTask().execute();
    }
});

private class GetDataTask extends AsyncTask<Void, Void, String[]> {
    ...
    @Override
    protected void onPostExecute(String[] result) {
        mListItems.addFirst("Added after refresh...");
        // Call onRefreshComplete when the list has been refreshed.
        ((PullToRefreshListView) getListView()).onRefreshComplete();
        super.onPostExecute(result);
    }
}

Last Updated

It's possible to add a last updated time using the method setLastUpdated and onRefreshComplete. The text provided to these methods will be set below the Release to refresh text. Note that the time representation is not validated replaces the previous text, which means that it's possible and recommended to add a text similar to "Last Update: 15:23". This might be changed in future versions.

1.5 Support

To use the widget on 1.5 the necessary drawables needs to be copied to that projects drawable folder. The drawables needed by the widget can be found in the drawable-hdpi folder in the library project.

Contributors

Are you using this widget?

If you are using this widget please feel free to add your app to the wiki.

License

Copyright (c) 2011 Johan Nilsson

Licensed under the Apache License, Version 2.0

android-pulltorefresh's People

Contributors

aheuermann avatar chdorner avatar dregre avatar eddieringle avatar emidander avatar johannilsson avatar keverets avatar kidfolk avatar letz avatar loopj avatar quiffman avatar ru-alxr avatar timimahoney avatar wkbae 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-pulltorefresh's Issues

Expendable listview

I changed the implementation to support expendable listview but even though it compiles it doesn't work. It displays the control and the pull to refresh function does get called but the animations do not work. I tried it on 1.6 and 2.3.4.

I hope you can get it work on expendable listviews as well. Would be very useful.

Header Padding Lag

The current way header padding is added, that is, on every move event, is terribly slow and causes lag. The way it works on most other implementations (including the official Android overscroll implementation) is that a header view is added with an extremely large height or padding value, like 10000px. Then, when calculations are done, that value is simply subtracted.

I believe this would be a much better method, rather than calculating and adjusting the required padding on every move event.

first into listview tap screen found a bug?

I use pulltorefresh on the listview, when the first into listview, I load data, not pull to refresh.., at this time , I touch the listview, the header TAP_TO_REFRESH Inexplicably appear๏ผŸ
but๏ผŒif into the listview the first ,I pull to refresh. and touch screen .the problem is not exist....
can you help me?

Cannot Cast From ListView to PullToRefreshListView

I pulled the exact same sample code that you have and it seems as though using the following does not work...

((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
@OverRide
public void onRefresh() {
// Do work to refresh the list here.
new GetDataTask().execute();
}
});

Is this a known issue already? Using findViewById() seems to be the only workaround.

Can we make pulltorefresh from bottom instead top?

It sounds weird, but I want to pull up to refresh. It means after scrolling to bottom of Listview, now I will pull up and release to perform pulltorefresh.

Can we do it?

P/S: it's not an issue but just a suggestion.

Thanks.
anticafe

The refresh view remains

If we scroll fast once from the bottom and it stops on the top, the refresh view remain and nothing will happen.

Needs to handle other OnScrollListener objects

If anyone calls setOnScrollListener(), this implementation stops working.

Here's the reasoning and the fix (tested in my own implementation).

PullToRefreshlistView.java contains

setOnScrollListener(this);

If anyone calls setOnScrollListener() from outside, the functionality in our own listener gets bypassed, leaving the list with the tap-to-refresh functionality and disabling the whole pulling magic.

To fix:

private OnScrollListener mScrollListener;

@Override
public void setOnScrollListener(OnScrollListener listener) {
    if (!this.equals(listener)) {
        mScrollListener = listener;
    }
    else {
        super.setOnScrollListener(listener);
    }
}

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    ...
    if (mScrollListener != null) {
        mScrollListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
    }
}

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
    ...
    if (mScrollListener != null) {
        mScrollListener.onScrollStateChanged(view, scrollState);
    }
}

It looks like on-scroll is the only listener being set from inside, so this should be the only instance of this type of problem.

IllegalArgumentException: historyPos out of range

On android 3.2 - both Galaxy 10.1 and Acer A100, I see this behaviour when pulling to refresh:

E/AndroidRuntime(14918): FATAL EXCEPTION: main
E/AndroidRuntime(14918): java.lang.IllegalArgumentException: historyPos out of range
E/AndroidRuntime(14918):    at android.view.MotionEvent.nativeGetAxisValue(Native Method)
E/AndroidRuntime(14918):    at android.view.MotionEvent.getHistoricalY(MotionEvent.java:1828)
E/AndroidRuntime(14918):    at com.markupartist.android.widget.PullToRefreshListView.applyHeaderPadding(PullToRefreshListView.java:224)
E/AndroidRuntime(14918):    at com.markupartist.android.widget.PullToRefreshListView.onTouchEvent(PullToRefreshListView.java:195)
E/AndroidRuntime(14918):    at android.view.View.dispatchTouchEvent(View.java:4609)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1554)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1320)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
E/AndroidRuntime(14918):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
E/AndroidRuntime(14918):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1732)
E/AndroidRuntime(14918):    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1267)
E/AndroidRuntime(14918):    at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
E/AndroidRuntime(14918):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1705)
E/AndroidRuntime(14918):    at android.view.View.dispatchPointerEvent(View.java:4677)
E/AndroidRuntime(14918):    at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
E/AndroidRuntime(14918):    at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
E/AndroidRuntime(14918):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(14918):    at android.os.Looper.loop(Looper.java:132)
E/AndroidRuntime(14918):    at android.app.ActivityThread.main(ActivityThread.java:4123)
E/AndroidRuntime(14918):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(14918):    at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(14918):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime(14918):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime(14918):    at dalvik.system.NativeStart.main(Native Method)

PTR header disapear when should display "Release to refresh"

First I would like to thank you guys for this great widget. just import it and it work great (mostly - except of this issue).
The issue I have is that sometimes, I still can't tell why, when I pull down, on the stage where it turns from "pull down to refresh" to "release to refresh" the PTR header just jumps back up and disappear. if I pull down enough then the "refreshing" stage does display OK, it's just happen with the "release to.." stage.
The issue doesn't happen all the time, sometimes it works fine but when it starts the only why to dismiss this issue is to start the activity again.
Please advice. Thanks!

Tap to refresh flashes

Hey there,
first of all: i can reproduce this with the example app!
Tested OS: Android 2.2, 2.3.3 and 2.3.4 - Emulator and Nexus One!

This is what happens:
You need to extend the example app by an onItemClickListener and a second activity!
When you start the app, and click an item (NOT the first), the tap to refresh button appears on the top of the list, then of course, the second activity starts.
When you return (by pressing the back key), the "Tap to refresh" stays on top, although the list has enough items.

I use this onListItemClick Listener:
@OverRide
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, Second.class);
startActivity(i);
}

Really easy to reproduce. Any chance this could be fixed?

Best regards

chris

EDIT: Dont scroll the list before! this fixes the problem temporarily. You must click one of the items you can see, as I said, not the first! ;)

Fail to show refresh view most times on Samsung i9100

Samsung i9100's ListView support over-scroll by default.
After apply this pull-to-refresh-ListView, refresh view will show when user scroll to top, but padding won't be added to refresh view's top, so the behavior is also not right most times.

Loading Progress view does not show if refresh started before the list is visible

I'm using the listview in a ViewPager and I'm in the situation where the refresh starts before the listview is visible, so while it is refreshing the Loading progress view isn't shown. It would be nice if the view when shown would detect that it was currently refreshing and would show the Loading progress.

My workaround is to just manually start a refresh and just call setselection(0).

Can't get setSelection to work

When I try to scroll to a specific position in the list and use setSelection() nothing happens.. no error, just nothing... smoothScrollBy works fine though.

Click twice to trigger OnItemClickListener

Sorry for my English.
I test the example in the source code, and I found a problem.
Step:
1 Scroll Up until the first item is visible (Do not show the refreshView)
2 Click any list item, nothing happens (could not trigger OnItemClickListener), until you click it again.

I hope you understand what i said.
Thank you.

GridView support

Hi, this is fantastic but it only works for ListView... Would it be possible to adapt it for a GridView?
Thanks! :)

dividers are not displayed for rows disabled with isEnabled() method in adapter.

If normal ListView is replaced with PullToRefreshListView dividers for disabled cells will not be drawn. As it described in this answer:
http://stackoverflow.com/questions/1873020/android-listview-non-enabled-items-draw-invisible-divider/9197037#9197037
the solution is to use areAllItemsEnabled() and isEnabled() simultaneously. It works for normal ListView, but doesn't work for PullToRefreshListView, because areAllItemsEnabled() adapter method is never called.

PullToRefreshListView Coming Up As Null On 3.1 Honeycomb Devices

Hey there,

I'm using sections_list = (PullToRefreshListView)findViewById(android.R.id.list);

which is working perfectly on all devices I've tested it on with 2.1, 2.2, 2.3.x but I've just noticed that on devices running 3.x when trying to find the same id its returning null which is then crashing the app as there is no list to set the adapter too.

Is there another way to find this element? I've tried renaming it differently and it still returns null.

The XML looks like this for the element (and as I said it works fine on the other versions of android)

com.evolusent.lifestyler2.pulltorefresh.PullToRefreshListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="0px"
android:layout_below="@id/contents_header"
android:scrollbars="none"
/>

Crash on 10.1 Tablet

10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1333)
10-31 12:23:31.100: E/AndroidRuntime(2626): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1863)
10-31 12:23:31.100: E/AndroidRuntime(2626): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1287)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.app.Activity.dispatchTouchEvent(Activity.java:2309)
10-31 12:23:31.100: E/AndroidRuntime(2626): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1836)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.View.dispatchPointerEvent(View.java:4689)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2365)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.view.ViewRoot.handleMessage(ViewRoot.java:2034)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.os.Looper.loop(Looper.java:132)
10-31 12:23:31.100: E/AndroidRuntime(2626): at android.app.ActivityThread.main(ActivityThread.java:4028)
10-31 12:23:31.100: E/AndroidRuntime(2626): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 12:23:31.100: E/AndroidRuntime(2626): at java.lang.reflect.Method.invoke(Method.java:491)
10-31 12:23:31.100: E/AndroidRuntime(2626): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
10-31 12:23:31.100: E/AndroidRuntime(2626): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
10-31 12:23:31.100: E/AndroidRuntime(2626): at dalvik.system.NativeStart.main(Native Method)
10-31 12:23:31.100: W/ActivityManager(288): Force finishing activity com.shopamani.shpmn/.activities.TumKampanyalarActivity

Bouncing when flinging upwards to the top.

If you are somewhere in the list, then fling up to the top, the list bounces after a short delay.

Not sure why this is, and I haven't been able to fix it. It seems to happen right before the scroll state is set to idle. Any suggestions?

Weird comportement in android 2.2

The list comports itself weirdly the first time it is loaded.
Without scrolling, I tapped anywhere in the list and some elements kinda dissapeared and reappeared, so do the header. I scrolled a little the list and everything went back to normal.

How I fix it ? It took me hours but I have finally sorted it out : I removed the onAttachedToWindow method in the PullToRefreshListView class.

Is it the same in other android version ? I don't know, I haven't push my investigation any further.

Crash at startup

I have implemented PullToRefreshView in my project but sometimes at startup the app crashes with the following log:

10-24 13:16:29.067: E/AndroidRuntime(3667): FATAL EXCEPTION: main
10-24 13:16:29.067: E/AndroidRuntime(3667): java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
10-24 13:16:29.067: E/AndroidRuntime(3667):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at java.util.ArrayList.get(ArrayList.java:311)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.widget.HeaderViewListAdapter.isEnabled(HeaderViewListAdapter.java:164)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.widget.ListView.dispatchDraw(ListView.java:3061)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.View.draw(View.java:7003)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.widget.AbsListView.draw(AbsListView.java:2641)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.View.draw(View.java:6900)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1908)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewRoot.draw(ViewRoot.java:1527)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1263)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.os.Looper.loop(Looper.java:130)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at android.app.ActivityThread.main(ActivityThread.java:3835)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at java.lang.reflect.Method.invokeNative(Native Method)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at java.lang.reflect.Method.invoke(Method.java:507)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
10-24 13:16:29.067: E/AndroidRuntime(3667):     at dalvik.system.NativeStart.main(Native Method)

Is there someting I am doing wrong? I have added the widget in my xml and set adapter in onCreate...

scrollfix_for_short_list : freeze when the list contains many items

Hi,

I made some tests on my app (which is already using with success the original pull-to-refresh solution) and it's catastrophic when the list is a little longer (> 60 items).
It freezed the app when i dynamically changed the list content (due to the DataSetObserver that made undoubtedly the refresh slower).

With more than 60 items, this code snippet execution takes like forever :

        adapter.clear();
        for (Item i : items)
        {
            adapter.add(i);
        }
        adapter.notifyDataSetChanged();

pulltorefreshexample : sharing my solution to fixing a crash

First, thank you very much for this awesome library. I'm new to Android SDK and it took me no time to use thanks to the example.
There is a bug crashing the app in the example project, I'm pretty sure it's thread related...
This crash can happen anytime while touching the list, but it is easy to reproduce by spamming the drag down gesture while "loading".
To fix it I changed the PullToRefreshActivity.java file like this

@Override
protected void onPostExecute(final String[] result) {
//previous code
// mListItems.addFirst("Added after refresh...");
//replacement code
((ArrayAdapter) getListAdapter()).insert("Added after refresh...", 0);

I presume the reason of the crash was that the ArrayAdapter was iterating mListItems while it was modified, not sure, but anyway this modification seems to work for me.

Feel free to share any comment :)

Tap to refresh is executed on normal list items

Issue found on Andorid 2.2

Situation:
My list is a checkable multi select list.
I had just a few items in the list, so that the tap to refresh label is shown on top of the list.
When I click on one of the items to check it, a refresh is executed.

Problem:
In the method "onTouchEvent" are missing two brackets at this part of the code:

"if (mRefreshView.getHeight() > mRefreshViewHeight || mRefreshView.getTop() >= 0 && mRefreshState == RELEASE_TO_REFRESH)"

Even if mRefreshState is not equal to RELEASE_TO_REFRESH, the condition is true.
The trigger is that "mRefreshView.getHeight() > mRefreshViewHeight" is true and linked with an OR to all the other conditions.

Fix:
Suround the OR-condition with brackets, hence there is no refresh executed when mRefreshState has a wrong value.

Like this:
"if ((mRefreshView.getHeight() > mRefreshViewHeight || mRefreshView.getTop()) >= 0 && mRefreshState == RELEASE_TO_REFRESH)"

Regards,
Daniel

first into listview pull to refresh found a bug?

I use pulltorefresh on the listview, when the first into listview, when i Sliding down screen slowly ,appear pull to reresh and then the refreshimage perform a animation then
the scrren can not sliding

Tried to build with Eclipse, getting errors?

Description Resource Path Location Type
The method onClick(View) of type PullToRefreshListView.OnClickRefreshListener must override a superclass method PullToRefreshListView.java /pulltorefresh/src/com/markupartist/android/widget line 388 Java Problem
The method onScroll(AbsListView, int, int, int) of type PullToRefreshListView must override a superclass method PullToRefreshListView.java /pulltorefresh/src/com/markupartist/android/widget line 277 Java Problem
The method onScrollStateChanged(AbsListView, int) of type PullToRefreshListView must override a superclass method PullToRefreshListView.java /pulltorefresh/src/com/markupartist/android/widget line 321 Java Problem

how to change pullToRefresh Sub header Text Color

Hello Using this way i am change string text of pull to refersh

PullToRefreshScrollView mPullRefreshScrollView;

mPullRefreshScrollView = (PullToRefreshScrollView)findViewById(R.id.pull_refresh_scrollview);

vRefresh = mPullRefreshScrollView.getLoadingLayoutProxy();

vRefresh.setPullLabel(getResources().getString(R.string.pull_to_refresh_pull_label_text));
vRefresh.setRefreshingLabel(getResources().getString(R.string.pull_to_refresh_refreshing_label_text));
vRefresh.setReleaseLabel(getResources().getString(R.string.pull_to_refresh_release_label_text));

but when i try to change text color using this

View rView,rView1;

rView = mPullRefreshScrollView.getRefreshableView();

rView1 = mPullRefreshScrollView.getRefreshableView();

TextView tViewMainText = (TextView)rView.findViewById(R.id.pull_to_refresh_text);
tViewMainText.setTextColor(Color.BLACK);

TextView tViewSubText = (TextView)rView1.findViewById(R.id.pull_to_refresh_sub_text);
tViewSubText.setTextColor(Color.BLACK);

only change color of pull_to_refresh_text but not change color of (sub text)pull_to_refresh_sub_text how to change color of sub text.

Thanks
sahir saiyed

headerview show half problem

when listview' scrollHeight - listview's visibleHeight < headerview' height, setSelection(1) will cause the headerview show half

IllegalArgumentException: The observer is null

Hi im facing with this issue, when i try to clear/remove all elements from a layout by programmatically. Mean i have a "container layout" and im inflating different layouts into that container. First i tried with regular list, all working good, but when i try with the pulltorefresh listview, when i try ot remove the elements from the container i`ve got this exception at removeAllViews() command.

Maybe i`m doing something wrong, or it can be an issue.

Note: I`m using Honeycomb 3.0, and the pulltorefresh list is in a fragment.
Note 2: Meantime i noticed while the data is loading i can navigate without any issue, but after the list is loaded i got this exception when i try to change the content of the "container layout" (mean remove the fragment, and replace with an other layout)

Thanks
Alex

06-14 11:21:39.890: ERROR/AndroidRuntime(27387): FATAL EXCEPTION: main
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): java.lang.IllegalArgumentException: The observer is null.
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.database.Observable.unregisterObserver(Observable.java:59)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.widget.BaseAdapter.unregisterDataSetObserver(BaseAdapter.java:42)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.widget.HeaderViewListAdapter.unregisterDataSetObserver(HeaderViewListAdapter.java:256)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.widget.AbsListView.onDetachedFromWindow(AbsListView.java:2307)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.View.dispatchDetachedFromWindow(View.java:7994)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1902)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1900)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1900)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.ViewGroup.removeAllViewsInLayout(ViewGroup.java:3319)
06-14 11:21:39.890: ERROR/AndroidRuntime(27387): at android.view.ViewGroup.removeAllViews(ViewGroup.java:3272)

last listview item not completely displayed

I am using a listview that partially occupies the screen. Now when my items exceed the rows shown by default, the last item when finger scrolled is only shown half and not the full cell row. It just stop at the half of the cell. Im using match_parent for height. If using default ListView (without pull to refresh) it is shown in full (the last cell item).

Pull To refersh view has padding at top

When I use the PullToRefreshListView there is padding at the top of the listview, how would I remove this?
When using the PullToRefreshListView
screenshot from 2013-08-22 20 46 12

When just using a ListView
screenshot from 2013-08-22 20 48 49

Trying to include in a project targeted for API 8

Any clue how to fix this in my project setup?

Description Resource Path Location Type
The method onClick(View) of type PullToRefreshListView.OnClickRefreshListener must override a superclass method PullToRefreshListView.java /OurHistree Test/com_markupartist_android_widget_pulltorefresh_src/com/markupartist/android/widget line 413 Java Problem
The method onScroll(AbsListView, int, int, int) of type PullToRefreshListView must override a superclass method PullToRefreshListView.java /OurHistree Test/com_markupartist_android_widget_pulltorefresh_src/com/markupartist/android/widget line 309 Java Problem
The method onScrollStateChanged(AbsListView, int) of type PullToRefreshListView must override a superclass method PullToRefreshListView.java /OurHistree Test/com_markupartist_android_widget_pulltorefresh_src/com/markupartist/android/widget line 350 Java Problem

Does not work on Android 2.1 Update1.

Not sure if you are totally supporting 2.1, but considering it still makes up a good percentage of the market thought you might want to be aware, when scrolling in 2.1 the list slowly disappears, this appears to be an issue with your ScrollListBy. I have confirmed this in both the AVD, and a Device.

android.view.InflateException: Binary XML file line #10: Error inflating class

I cloned the master branch and run it, but get an inflation exception as below. Running it on 2.2:

05-17 18:14:26.604: ERROR/AndroidRuntime(361): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.markupartist.android.example.pulltorefresh/com.markupartist.android.example.pulltorefresh.PullToRefreshActivity}: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class com.markupartist.android.widget.PullToRefreshListView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
at android.app.Activity.setContentView(Activity.java:1647)
at com.markupartist.android.example.pulltorefresh.PullToRefreshActivity.onCreate(PullToRefreshActivity.java:21)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at com.markupartist.android.widget.PullToRefreshListView.(PullToRefreshListView.java:54)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
at android.view.LayoutInflater.createView(LayoutInflater.java:500)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
at android.content.res.Resources.getValue(Resources.java:892)
at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
at android.content.res.Resources.getLayout(Resources.java:731)
at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
at com.markupartist.android.widget.PullToRefreshListView.init(PullToRefreshListView.java:80)
... 25 more

PullToRefreshArrow flip animation improvement

This is more of an improvement request than a bug/issue.

I noticed since the last commit that the ic_pulltorefresh_arrow.png is flipped only when then top of the list reaches the top of the actual image. It would be nice if it flipped when the top of the list is roughly 10dip above the image. For an example, look at when the arrow is flipped in official Twitter app. I believe up until this point the arrow would flip when the top of the list was a few dip above the image as well.

Sorry, I didn't have time to look into a solution but hopefully if you all agree, this is a simple fix.

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.