Skip to content

Instantly share code, notes, and snippets.

@abhimuktheeswarar
Last active September 29, 2016 10:05
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 abhimuktheeswarar/bd1a7cffcee660d1ff20045ead317ae6 to your computer and use it in GitHub Desktop.
Save abhimuktheeswarar/bd1a7cffcee660d1ff20045ead317ae6 to your computer and use it in GitHub Desktop.
Viewpager to use with bottom bar navigation
public class LockableViewPager extends ViewPager {
private boolean swipeLocked;
public LockableViewPager(Context context) {
super(context);
}
public LockableViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
public boolean getSwipeLocked() {
return swipeLocked;
}
public void setSwipeLocked(boolean swipeLocked) {
this.swipeLocked = swipeLocked;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return !swipeLocked && super.onTouchEvent(event);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return !swipeLocked && super.onInterceptTouchEvent(event);
}
@Override
public boolean canScrollHorizontally(int direction) {
return !swipeLocked && super.canScrollHorizontally(direction);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment