felipecsl/QuickReturn

How Support swiperefreshlayout ?

Closed this issue · 1 comments

Hi,

i try your component and seems that is not compatible with swiperefreshlayout when we have top view. Because top view is "front of" listView, the view of swiperefreshlayout isn't displayed (it's behind "top view"...)

Have you a suggest to have this 2 components together ?

Solution are to have a FrameLayout which contain top bar and listView in a Custom SwipeRefreshLayout which override "canChildScrollUp" like

public class SwipeListViewRefreshLayout extends SwipeRefreshLayout {

public SwipeListViewRefreshLayout(Context context) {
    super(context);
}

public SwipeListViewRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
}

private ListView mListView;

public void setListView(ListView stickyListHeadersListView) {
    mListView = stickyListHeadersListView;
}

@Override
public boolean canChildScrollUp() {
    if (mListView != null) {
        // In order to scroll a StickyListHeadersListView up:
        // Firstly, the wrapped ListView must have at least one item
        return (mListView.getChildCount() > 0) &&
        // And then, the first visible item must not be the first item
                ((mListView.getFirstVisiblePosition() > 0) ||
                // If the first visible item is the first item,
                // (we've reached the first item)
                // make sure that its top must not cross over the padding
                // top of the wrapped ListView
                (mListView.getChildAt(0).getTop() < 0));

        // If the wrapped ListView is empty or,
        // the first item is located below the padding top of the wrapped
        // ListView,
        // we can allow performing refreshing now
    } else {
        // Fall back to default implementation
        return super.canChildScrollUp();
    }
}

}

and associate listView with SwipeRefreshLayout.
With this trick SwipeRefreshLayout will add loading bar at top of quick return bar :)