Skip to content

Instantly share code, notes, and snippets.

@gnardini
Created August 17, 2016 17:21
Show Gist options
  • Save gnardini/d82f8fab8b8c79c9b7a80c7283ce62b0 to your computer and use it in GitHub Desktop.
Save gnardini/d82f8fab8b8c79c9b7a80c7283ce62b0 to your computer and use it in GitHub Desktop.
public class FixedSwipeRefreshLayout extends SwipeRefreshLayout {
private boolean mHandleTouch = true;
public FixedSwipeRefreshLayout(Context context) {
super(context);
}
public FixedSwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
int action = MotionEventCompat.getActionMasked(ev);
switch (action) {
case MotionEvent.ACTION_DOWN:
mHandleTouch = false;
break;
default:
if (mHandleTouch) {
return super.onTouchEvent(ev);
}
mHandleTouch = onInterceptTouchEvent(ev);
switch (action) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mHandleTouch = true;
break;
}
break;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment