Skip to content

Instantly share code, notes, and snippets.

@illarionov
Created January 25, 2015 23:09
Show Gist options
  • Save illarionov/ecb10eacb91d6aa0ddc9 to your computer and use it in GitHub Desktop.
Save illarionov/ecb10eacb91d6aa0ddc9 to your computer and use it in GitHub Desktop.
package com.example.swiperefreshtest;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AbsListView;
public class MySwipeRefreshLayout extends SwipeRefreshLayout
{
public MySwipeRefreshLayout(Context context) {
super(context);
}
public MySwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean canChildScrollUp() {
View target = getChildAt(0);
if (target instanceof AbsListView) {
final AbsListView absListView = (AbsListView) target;
return absListView.getChildCount() > 0
&& (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
.getTop() < absListView.getPaddingTop());
} else {
return target.getScrollY() > 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment