Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzgreen/e8fe9a00dd9e8b93b6cc to your computer and use it in GitHub Desktop.
Save mzgreen/e8fe9a00dd9e8b93b6cc to your computer and use it in GitHub Desktop.
ScrollingSwipeRefreshLayoutBehavior
public class ScrollingSwipeRefreshLayoutBehavior extends AppBarLayout.ScrollingViewBehavior {
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return super.layoutDependsOn(parent, child, dependency) || (dependency instanceof AppBarLayout);
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
boolean returnValue = super.onDependentViewChanged(parent, child, dependency);
if (dependency instanceof AppBarLayout) {
child.setEnabled(dependency.getY()==0);
}
return returnValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment