List of usage examples for android.view MotionEvent ACTION_MOVE
int ACTION_MOVE
To view the source code for android.view MotionEvent ACTION_MOVE.
Click Source Link
From source file:com.pursuer.reader.easyrss.VerticalSingleItemView.java
@SuppressLint({ "NewApi", "SimpleDateFormat" }) public VerticalSingleItemView(final DataMgr dataMgr, final Context context, final String uid, final View menu, final VerticalItemViewCtrl itemViewCtrl) { this.dataMgr = dataMgr; this.context = context; this.item = dataMgr.getItemByUid(uid, ITEM_PROJECTION); this.fontSize = new SettingFontSize(dataMgr).getData(); this.theme = new SettingTheme(dataMgr).getData(); this.showTop = false; this.showBottom = false; this.menu = menu; this.itemViewCtrl = itemViewCtrl; this.imageClickTime = 0; final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); this.view = inflater.inflate(R.layout.single_item_view, null); // Disable hardware acceleration on Android 3.0-4.1 devices. if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { view.setLayerType(View.LAYER_TYPE_SOFTWARE, null); }/* w ww .jav a 2 s. co m*/ lastItemView = view.findViewById(R.id.LastItemView); nextItemView = view.findViewById(R.id.NextItemView); itemScrollView = (OverScrollView) view.findViewById(R.id.ItemScrollView); itemScrollView.setTopScrollView(lastItemView); itemScrollView.setBottomScrollView(nextItemView); itemScrollView.setOnScrollChangeListener(this); itemScrollView.setOnTouchListener(this); final View btnShowOriginal = view.findViewById(R.id.BtnShowOriginal); btnShowOriginal.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View view, final MotionEvent event) { boolean ret = false; final TextView txt = (TextView) view.findViewById(R.id.BtnText); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: txt.setTextColor(0xFF787878); ret = true; break; case MotionEvent.ACTION_MOVE: ret = true; break; case MotionEvent.ACTION_CANCEL: txt.setTextColor(0xBB787878); ret = false; break; case MotionEvent.ACTION_UP: txt.setTextColor(0xBB787878); final SettingBrowserChoice setting = new SettingBrowserChoice(dataMgr); if (setting.getData() == SettingBrowserChoice.BROWSER_CHOICE_EXTERNAL) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(item.getHref())); context.startActivity(intent); } else if (VerticalSingleItemView.this.listener != null) { VerticalSingleItemView.this.listener.showWebsitePage(item.getUid(), false); } break; default: } return ret; } }); final View btnShowMobilized = view.findViewById(R.id.BtnShowMobilized); btnShowMobilized.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(final View view, final MotionEvent event) { boolean ret = false; final TextView txt = (TextView) view.findViewById(R.id.BtnText); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: txt.setTextColor(0xFF787878); ret = true; break; case MotionEvent.ACTION_MOVE: ret = true; break; case MotionEvent.ACTION_CANCEL: txt.setTextColor(0xBB787878); ret = false; break; case MotionEvent.ACTION_UP: txt.setTextColor(0xBB787878); if (VerticalSingleItemView.this.listener != null) { VerticalSingleItemView.this.listener.showWebsitePage(item.getUid(), true); } ret = true; break; default: } return ret; } }); { final ListItemItem lastItem = itemViewCtrl.getLastItem(item.getUid()); final TextView txt = (TextView) lastItemView.findViewById(R.id.LastItemTitle); txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize); if (lastItem == null) { lastUid = null; menu.findViewById(R.id.BtnPrevious).setEnabled(false); final ImageView img = (ImageView) lastItemView.findViewById(R.id.LastItemArrow); img.setImageResource(R.drawable.no_more_circle); txt.setText(R.string.TxtNoPreviousItem); } else { lastUid = lastItem.getId(); final View btnLast = menu.findViewById(R.id.BtnPrevious); btnLast.setEnabled(true); btnLast.setOnClickListener(new OnClickListener() { @Override public void onClick(final View view) { if (listener != null) { listener.showLastItem(); } } }); txt.setText(lastItem.getTitle()); } } { final ListItemItem nextItem = itemViewCtrl.getNextItem(item.getUid()); final TextView txt = (TextView) nextItemView.findViewById(R.id.NextItemTitle); txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize); if (nextItem == null) { nextUid = null; menu.findViewById(R.id.BtnNext).setEnabled(false); final ImageView img = (ImageView) nextItemView.findViewById(R.id.NextItemArrow); img.setImageResource(R.drawable.no_more_circle); txt.setText(R.string.TxtNoNextItem); } else { nextUid = nextItem.getId(); final View btnNext = menu.findViewById(R.id.BtnNext); btnNext.setEnabled(true); btnNext.setOnClickListener(new OnClickListener() { @Override public void onClick(final View view) { if (listener != null) { listener.showNextItem(); } } }); txt.setText(nextItem.getTitle()); } } final TextView title = (TextView) view.findViewById(R.id.ItemTitle); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 3); title.setText(item.getTitle()); final TextView info = (TextView) view.findViewById(R.id.ItemInfo); info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 5); final StringBuilder infoText = new StringBuilder(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); sdf.setTimeZone(TimeZone.getDefault()); infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp()))); if (item.getAuthor() != null && item.getAuthor().length() > 0) { infoText.append(" | By "); infoText.append(item.getAuthor()); } if (item.getSourceTitle() != null && item.getSourceTitle().length() > 0) { infoText.append(" ("); infoText.append(item.getSourceTitle()); infoText.append(")"); } info.setText(infoText); webView = (WebView) view.findViewById(R.id.webView); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setBackgroundColor(context.getResources() .getColor(theme == SettingTheme.THEME_NORMAL ? R.color.NormalBackground : R.color.DarkBackground)); webView.setFocusable(false); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(final WebView view, final String url) { if (VerticalSingleItemView.this.imageClickTime > System.currentTimeMillis() - 1000) { return true; } final Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(url)); context.startActivity(intent); return true; } }); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(final WebView view, final String url, final String message, final JsResult result) { if (VerticalSingleItemView.this.listener != null) { if (message.endsWith(".erss")) { VerticalSingleItemView.this.listener .onImageViewRequired(item.getStoragePath() + "/" + message); } else { VerticalSingleItemView.this.listener.onImageViewRequired(message); } } VerticalSingleItemView.this.imageClickTime = System.currentTimeMillis(); result.cancel(); return true; } }); updateButtonStar(); updateButtonSharing(); updateButtonOpenLink(); if (!item.getState().isRead()) { dataMgr.markItemAsReadWithTransactionByUid(uid); NetworkMgr.getInstance().startImmediateItemStateSyncing(); } }
From source file:com.appsummary.luoxf.myappsummary.recyclerView.fastscroll.Views.FastScroller.java
/** * Handles the touch event and determines whether to show the fast scroller (or updates it if * it is already showing).// w w w . ja v a2 s . c om */ public void handleTouchEvent(MotionEvent ev, int downX, int downY, int lastY) { ViewConfiguration config = ViewConfiguration.get(mRecyclerView.getContext()); int action = ev.getAction(); int y = (int) ev.getY(); switch (action) { case MotionEvent.ACTION_DOWN: if (isNearPoint(downX, downY)) { mTouchOffset = downY - mThumbPosition.y; } break; case MotionEvent.ACTION_MOVE: // Check if we should start scrolling if (!mIsDragging && isNearPoint(downX, downY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { mRecyclerView.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; mTouchOffset += (lastY - downY); mPopup.animateVisibility(true); } if (mIsDragging) { // Update the fastscroller section name at this touch position int top = 0; int bottom = mRecyclerView.getHeight() - mThumbHeight; float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset)); String sectionName = mRecyclerView.scrollToPositionAtProgress((boundedY - top) / (bottom - top)); mPopup.setSectionName(sectionName); mPopup.animateVisibility(!sectionName.isEmpty()); mRecyclerView.invalidate(mPopup.updateFastScrollerBounds(mRecyclerView, mThumbPosition.y)); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffset = 0; if (mIsDragging) { mIsDragging = false; mPopup.animateVisibility(false); } break; } }
From source file:com.codingfeel.sm.views.superrecyclerview.swipe.SwipeDismissRecyclerViewTouchListener.java
@SuppressLint("AndroidLintClickableViewAccessibility") @Override// ww w . ja va2 s.c o m public boolean onTouch(View view, MotionEvent motionEvent) { if (mViewWidth < 2) { mViewWidth = mRecyclerView.getWidth(); } switch (MotionEventCompat.getActionMasked(motionEvent)) { case MotionEvent.ACTION_DOWN: { if (mPaused) return false; caseMotionActionDown(motionEvent); return false; } case MotionEvent.ACTION_CANCEL: { if (mVelocityTracker == null) break; caseMotionActionCancel(); break; } case MotionEvent.ACTION_UP: { if (mVelocityTracker == null) break; caseMotionActionUp(motionEvent); break; } case MotionEvent.ACTION_MOVE: { if (mVelocityTracker == null || mPaused) break; caseMotionActionMove(motionEvent); if (mSwiping) return true; break; } } return false; }
From source file:com.android2.calculator3.view.CalculatorPadView.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = MotionEventCompat.getActionMasked(ev); float pos = ev.getRawX(); mInterceptingTouchEvents = false;/*from w w w. j a va2 s . com*/ switch (action) { case MotionEvent.ACTION_DOWN: mInitialMotion = pos; mLastMotion = pos; handleDown(); break; case MotionEvent.ACTION_MOVE: // Reset initial motion if the user drags in a different direction suddenly if ((pos - mInitialMotion) / Math.abs(pos - mInitialMotion) != (pos - mLastMotion) / Math.abs(pos - mLastMotion)) { mInitialMotion = mLastMotion; } float delta = Math.abs(pos - mInitialMotion); if (delta > mTouchSlop) { float dx = pos - mInitialMotion; if (dx < 0) { mInterceptingTouchEvents = getState() == TranslateState.COLLAPSED; } else if (dx > 0) { mInterceptingTouchEvents = getState() == TranslateState.EXPANDED; } } mLastMotion = pos; break; } return mInterceptingTouchEvents; }
From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java
@Override public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getActionMasked(); if (canChildScrollUp()) { // Fail fast if we're not in a state where a swipe is possible return super.onInterceptTouchEvent(ev); }//from w w w.ja v a 2 s. c o m if (action == MotionEvent.ACTION_DOWN) { mVelocityTracker.clear(); } mVelocityTracker.addMovement(ev); switch (action) { case MotionEvent.ACTION_DOWN: { final float x = ev.getX(); final float y = ev.getY(); mInitialTouchX = x; mInitialTouchY = mLastTouchY = y; mOpenOnClick = isListChildUnderClipped(x, y) && mCollapsibleHeight > 0; } break; case MotionEvent.ACTION_MOVE: { final float x = ev.getX(); final float y = ev.getY(); final float dy = y - mInitialTouchY; boolean isSlidingUp = Math.abs(dy) > mTouchSlop && findChildUnder(x, y) != null && mCollapseOffset > 0; boolean isSlidingDown = mCollapseOffset == 0 && dy > mTouchSlop; if (isSlidingUp || isSlidingDown) { mActivePointerId = ev.getPointerId(0); mIsDragging = true; mLastTouchY = Math.max(mLastTouchY - mTouchSlop, Math.min(mLastTouchY + dy, mLastTouchY + mTouchSlop)); } } break; case MotionEvent.ACTION_POINTER_UP: { onSecondaryPointerUp(ev); } break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: { resetTouch(); } break; } if (mIsDragging) { mScroller.abortAnimation(); } return mIsDragging || mOpenOnClick; }
From source file:com.base.app.widget.indicatorview.UnderlinePageIndicator.java
public boolean onTouchEvent(MotionEvent ev) { if (super.onTouchEvent(ev)) { return true; }/* w w w.j a va 2 s.com*/ if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) { return false; } final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mLastMotionX = ev.getX(); break; case MotionEvent.ACTION_MOVE: { final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float x = MotionEventCompat.getX(ev, activePointerIndex); final float deltaX = x - mLastMotionX; if (!mIsDragging) { if (Math.abs(deltaX) > mTouchSlop) { mIsDragging = true; } } if (mIsDragging) { mLastMotionX = x; if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) { mViewPager.fakeDragBy(deltaX); } } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: if (!mIsDragging) { final int count = mViewPager.getAdapter().getCount(); final int width = getWidth(); final float halfWidth = width / 2f; final float sixthWidth = width / 6f; if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage - 1); } return true; } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage + 1); } return true; } } mIsDragging = false; mActivePointerId = INVALID_POINTER; if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag(); break; case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); mLastMotionX = MotionEventCompat.getX(ev, index); mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: final int pointerIndex = MotionEventCompat.getActionIndex(ev); final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); if (pointerId == mActivePointerId) { final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); } mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId)); break; } return true; }
From source file:circleplus.app.LocationFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { mMapView.onRestoreInstanceState(savedInstanceState); }/*from ww w.jav a 2s . c om*/ // Register click listeners mSearchButton.setOnClickListener(this); mGetLocationButton.setOnClickListener(this); mGetLocationButton.setText("Locate"); mCurBtnType = ButtonType.LOC; mMapController.setZoom(LocationUtils.DEFAULT_ZOOM); mMapController.enableClick(LocationUtils.ENABLE_MAP_CLICK); mMapView.setBuiltInZoomControls(LocationUtils.ENABLE_BUILT_IN_ZOOM_CONTROLS); mMapView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_MOVE: // Transfer from FOLLOW to LOCATE (NORMAL) when moving if (mCurBtnType == ButtonType.FOLLOW) { mLocationOverlay.setLocationMode(MyLocationOverlay.LocationMode.NORMAL); } mGetLocationButton.setText("Locate"); mCurBtnType = ButtonType.LOC; break; } return false; } }); // Initialize locating mHasLocationData = false; mLocationClient = new LocationClient(getActivity().getApplicationContext()); mLocationData = new LocationData(); mLocationClient.registerLocationListener(mLocationListener); LocationClientOption option = new LocationClientOption(); option.setLocationMode(LocationClientOption.LocationMode.Battery_Saving); option.setOpenGps(LocationUtils.OPEN_GPS); option.setCoorType(LocationUtils.COORDINATE_TYPE); option.setScanSpan(LocationUtils.SCAN_SPAN); option.setIsNeedAddress(LocationUtils.NEED_ADDRESS); mLocationClient.setLocOption(option); mLocationClient.start(); // Initialize location overlay mLocationOverlay.setLocationMode(MyLocationOverlay.LocationMode.NORMAL); mLocationOverlay.setData(mLocationData); // Add location overlay to map view mMapView.getOverlays().add(mLocationOverlay); mLocationOverlay.enableCompass(); // Refresh on setting location data mMapView.refresh(); // Initialize search mSearch = new MKSearch(); CirclePlusApp app = (CirclePlusApp) getActivity().getApplicationContext(); mFragSearchListener = new FragSearchListener(); mSearch.init(app.mBMapManager, mFragSearchListener); mSuggestAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line); mSearchText.setAdapter(mSuggestAdapter); mSearchText.addTextChangedListener(new SearchTextWatcher()); }
From source file:com.benefit.buy.library.viewpagerindicator.UnderlinePageIndicator.java
@Override public boolean onTouchEvent(MotionEvent ev) { if (super.onTouchEvent(ev)) { return true; }/*from w ww . j a v a 2s. co m*/ if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) { return false; } final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mLastMotionX = ev.getX(); break; case MotionEvent.ACTION_MOVE: { final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float x = MotionEventCompat.getX(ev, activePointerIndex); final float deltaX = x - mLastMotionX; if (!mIsDragging) { if (Math.abs(deltaX) > mTouchSlop) { mIsDragging = true; } } if (mIsDragging) { mLastMotionX = x; if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) { mViewPager.fakeDragBy(deltaX); } } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: if (!mIsDragging) { final int count = mViewPager.getAdapter().getCount(); final int width = getWidth(); final float halfWidth = width / 2f; final float sixthWidth = width / 6f; if ((mCurrentPage > 0) && (ev.getX() < (halfWidth - sixthWidth))) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage - 1); } return true; } else if ((mCurrentPage < (count - 1)) && (ev.getX() > (halfWidth + sixthWidth))) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage + 1); } return true; } } mIsDragging = false; mActivePointerId = INVALID_POINTER; if (mViewPager.isFakeDragging()) { mViewPager.endFakeDrag(); } break; case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); mLastMotionX = MotionEventCompat.getX(ev, index); mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: final int pointerIndex = MotionEventCompat.getActionIndex(ev); final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); if (pointerId == mActivePointerId) { final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); } mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId)); break; } return true; }
From source file:com.nextgis.maplibui.formcontrol.Sign.java
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (!mNotInitialized) touchStart(x, y);/*from w w w . j av a 2 s .co m*/ break; case MotionEvent.ACTION_MOVE: if (!mNotInitialized) { touchMove(x, y); postInvalidate(); } break; case MotionEvent.ACTION_UP: int posX = getWidth() - mClearImageSize - mClearBuff; //Log.d(Constants.TAG, "x: " + event.getX() + " y: " + event.getY() + " posX: " + posX + " posY: " + mClearBuff); if (event.getX() > posX && event.getY() < mClearImageSize + mClearBuff) { onClearSign(); } else if (!mNotInitialized) { touchUp(); invalidate(); } break; default: break; } return true; }
From source file:com.aosijia.dragonbutler.ui.widget.UnderlinePageIndicator.java
@SuppressLint("ClickableViewAccessibility") public boolean onTouchEvent(MotionEvent ev) { if (super.onTouchEvent(ev)) { return true; }/*from ww w .ja v a 2 s.c o m*/ if ((mViewPager == null) || (mViewPager.getAdapter().getCount() == 0)) { return false; } final int action = ev.getAction() & MotionEventCompat.ACTION_MASK; switch (action) { case MotionEvent.ACTION_DOWN: mActivePointerId = MotionEventCompat.getPointerId(ev, 0); mLastMotionX = ev.getX(); break; case MotionEvent.ACTION_MOVE: { final int activePointerIndex = MotionEventCompat.findPointerIndex(ev, mActivePointerId); final float x = MotionEventCompat.getX(ev, activePointerIndex); final float deltaX = x - mLastMotionX; if (!mIsDragging) { if (Math.abs(deltaX) > mTouchSlop) { mIsDragging = true; } } if (mIsDragging) { mLastMotionX = x; if (mViewPager.isFakeDragging() || mViewPager.beginFakeDrag()) { mViewPager.fakeDragBy(deltaX); } } break; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: if (!mIsDragging) { final int count = mViewPager.getAdapter().getCount(); final int width = getWidth(); final float halfWidth = width / 2f; final float sixthWidth = width / 6f; if ((mCurrentPage > 0) && (ev.getX() < halfWidth - sixthWidth)) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage - 1); } return true; } else if ((mCurrentPage < count - 1) && (ev.getX() > halfWidth + sixthWidth)) { if (action != MotionEvent.ACTION_CANCEL) { mViewPager.setCurrentItem(mCurrentPage + 1); } return true; } } mIsDragging = false; mActivePointerId = INVALID_POINTER; if (mViewPager.isFakeDragging()) mViewPager.endFakeDrag(); break; case MotionEventCompat.ACTION_POINTER_DOWN: { final int index = MotionEventCompat.getActionIndex(ev); mLastMotionX = MotionEventCompat.getX(ev, index); mActivePointerId = MotionEventCompat.getPointerId(ev, index); break; } case MotionEventCompat.ACTION_POINTER_UP: final int pointerIndex = MotionEventCompat.getActionIndex(ev); final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex); if (pointerId == mActivePointerId) { final int newPointerIndex = pointerIndex == 0 ? 1 : 0; mActivePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex); } mLastMotionX = MotionEventCompat.getX(ev, MotionEventCompat.findPointerIndex(ev, mActivePointerId)); break; } return true; }