package ml.puredark.hviewer.ui.customs; import android.content.Context; import android.support.annotation.NonNull; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.MotionEvent; public class MultiTouchViewPager extends ViewPager { private boolean mIsDisallowIntercept = false; public MultiTouchViewPager(Context context) { super(context); } public MultiTouchViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) { mIsDisallowIntercept = disallowIntercept; super.requestDisallowInterceptTouchEvent(disallowIntercept); } @Override public boolean dispatchTouchEvent(@NonNull MotionEvent ev) { if (ev.getPointerCount() > 1 && mIsDisallowIntercept) { requestDisallowInterceptTouchEvent(false); boolean handled = super.dispatchTouchEvent(ev); requestDisallowInterceptTouchEvent(true); return handled; } else { return super.dispatchTouchEvent(ev); } } }