Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Tap to Refresh" For Short List #63

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DavidTPate
Copy link

Here's my fix to the "Tap to Refresh" removal. It's not using any of the odd adding of views to make it longer or anything like that, instead it simply manipulates the visibility of the header as needed and also includes a bug fix for scrolling where it was "jumpy".

This addresses #40, #24, #51, #59, and #61.

I removed the "Tap to Refresh" functionality. Instead the Text View is removed from the view when not being used and shown again when needed. Also, fixed an issue where the lastMotionY was not being reset in resetHeader() which was causing the menu to be "jumpy" when swiping near the bottom.
@anguyenqd
Copy link

Thank you very much 💃

angel9484 and others added 2 commits December 4, 2013 10:54
When the list has few items, the pulltorefresh shows a little space. With this change the space is not being shown anymore.
Removed paddintTop and paddingBottom from relative layout. Thanks @angel9484!
@LaSprezz
Copy link

Hi,
I took the changes, but it seems to remove the functionality to refresh the list completely as I still can't pull my list.
Therefore nothing happens...

@DavidTPate
Copy link
Author

@LaSprezz Can you please provide some code samples of what you are doing? I currently use this in a couple Production applications and have no issues.

@LaSprezz
Copy link

@DavidTPate Thanks for your quick feedback.
I'm quite new here, therefore I'm not exactly sure on which sample I should provide nor how; here is what I think should do :

My listView (@ style containing a background image) :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/generic"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <com.markupartist.android.widget.PullToRefreshListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>

I then use another .xml to format each line of my list, but I don't think that matter.

Then on my Activity (extends SherlockActivity) I just do :

listview = (ListView) findViewById(R.id.listview);
// pull-to-refresh
((PullToRefreshListView) listview)
    .setOnRefreshListener(new OnRefreshListener() {
        @ Override
        public void onRefresh() {
                // Do work to refresh the list here.
                new RefreshDataTask().execute();
        }
    });

Then I pass my datas through a custom adapter.

Sorry if anything sounds dumb, I may have missed something somewhere...

@DavidTPate
Copy link
Author

Well, welcome to GitHub!

A couple notes, I'd definitely take a look at the "GitHub Flavored Markdown" to learn some of the tags and such. For example, using an accent (`) three times above and below code will create a code block, like so:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/generic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<com.markupartist.android.widget.PullToRefreshListView
    android:id="@+id/listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</RelativeLayout>
listview = (ListView) findViewById(R.id.listview);
// pull-to-refresh
((PullToRefreshListView) listview)
.setOnRefreshListener(new OnRefreshListener() {
@ Override
public void onRefresh() {
// Do work to refresh the list here.
new RefreshDataTask().execute();
}
});

@DavidTPate
Copy link
Author

@LaSprezz From the looks of it what you are doing is correct and should work without issue. Does your list have at least one item in it? I would also suggest modifying your Java code slightly so you aren't having to cast once more to PullToRefreshListView, so it would like the following:

listview = (PullToRefreshListView) findViewById(R.id.listview);
listview.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
// Do work to refresh the list here.
new RefreshDataTask().execute();
}
});

Which version of the project are you using? Are you using the one from my branch or the main project? How many items does your list have? Can you post a screenshot of what you are seeing?

@LaSprezz
Copy link

@DavidTPate Thanks for the insights. I'll take notes and modify.

I use the master branch and tried to substitute the 2 files that can be found on top on this discussion (your modifications, if my understanding's right).
I tested with 4 elements in the list (approximately half the size of the screen), and I can’t pull my screen down so nothing happen, as if nothing was implemented. With 11 elements the scroll bar appears and it works.

@DavidTPate
Copy link
Author

I would suggest grabbing all of the files from my branch https://github.com/DavidTPate/android-pulltorefresh-1 and giving it a quick try.

@LaSprezz
Copy link

@DavidTPate Sorry for the late feedback, I was working on the migration from ABS to ActionBarCompat.
Once done, I did as you said -which is grabbing all from your branch- and it works. Thanks.

@DavidTPate
Copy link
Author

Glad to help!

@suarkadipa
Copy link

it works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants