Last active
September 29, 2016 10:05
-
-
Save abhimuktheeswarar/bd1a7cffcee660d1ff20045ead317ae6 to your computer and use it in GitHub Desktop.
Viewpager to use with bottom bar navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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