2018-01-18 23:12:45 +00:00
|
|
|
package cy.agorise.crystalwallet.util;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.support.v4.view.ViewPager;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.MotionEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by xd on 1/18/18.
|
2018-01-21 20:57:09 +00:00
|
|
|
* This ViewPager is intended to be used inside another ViewPager therefore it has the
|
|
|
|
* setSwipeLocked which disables or enables the swipe gesture.
|
2018-01-18 23:12:45 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public class ChildViewPager extends ViewPager {
|
|
|
|
|
|
|
|
private boolean swipeLocked;
|
|
|
|
|
|
|
|
public ChildViewPager(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ChildViewPager(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);
|
|
|
|
}
|
|
|
|
}
|