/** * Handles Touch event * * @param event * the motion event * @return */ public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: lastTouchedY = event.getY(); scroller.forceFinished(true); clearMessages(); break; case MotionEvent.ACTION_MOVE: // perform scrolling int distanceY = (int) (event.getY() - lastTouchedY); if (distanceY != 0) { startScrolling(); listener.onScroll(distanceY); lastTouchedY = event.getY(); } break; } if (!gestureDetector.onTouchEvent(event) && event.getAction() == MotionEvent.ACTION_UP) { justify(); } return true; }
/** * Handles Touch event * @param event the motion event * @return */ public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: lastTouchedY = event.getY(); scroller.forceFinished(true); clearMessages(); break; case MotionEvent.ACTION_MOVE: // perform scrolling int distanceY = (int)(event.getY() - lastTouchedY); if (distanceY != 0) { startScrolling(); listener.onScroll(distanceY); lastTouchedY = event.getY(); } break; } if (!gestureDetector.onTouchEvent(event) && event.getAction() == MotionEvent.ACTION_UP) { justify(); } return true; }
public void handleMessage(Message msg) { scroller.computeScrollOffset(); int currY = scroller.getCurrY(); int delta = lastScrollY - currY; lastScrollY = currY; if (delta != 0) { listener.onScroll(delta); } // scrolling is not finished when it comes to final Y // so, finish it manually if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) { currY = scroller.getFinalY(); scroller.forceFinished(true); } if (!scroller.isFinished()) { animationHandler.sendEmptyMessage(msg.what); } else if (msg.what == MESSAGE_SCROLL) { justify(); } else { finishScrolling(); } } };
public void handleMessage(Message msg) { scroller.computeScrollOffset(); int currY = scroller.getCurrY(); int delta = lastScrollY - currY; lastScrollY = currY; if (delta != 0) { listener.onScroll(delta); } // scrolling is not finished when it comes to final Y // so, finish it manually if (Math.abs(currY - scroller.getFinalY()) < MIN_DELTA_FOR_SCROLLING) { currY = scroller.getFinalY(); scroller.forceFinished(true); } if (!scroller.isFinished()) { animationHandler.sendEmptyMessage(msg.what); } else if (msg.what == MESSAGE_SCROLL) { justify(); } else { finishScrolling(); } } };
/** * Finishes scrolling */ void finishScrolling() { if (isScrollingPerformed) { listener.onFinished(); isScrollingPerformed = false; } } }
/** * Starts scrolling */ private void startScrolling() { if (!isScrollingPerformed) { isScrollingPerformed = true; listener.onStarted(); } }
/** * Finishes scrolling */ void finishScrolling() { if (isScrollingPerformed) { listener.onFinished(); isScrollingPerformed = false; } } }
/** * Starts scrolling */ private void startScrolling() { if (!isScrollingPerformed) { isScrollingPerformed = true; listener.onStarted(); } }
/** * Justifies wheel */ private void justify() { listener.onJustify(); setNextMessage(MESSAGE_JUSTIFY); }
/** * Justifies wheel */ private void justify() { listener.onJustify(); setNextMessage(MESSAGE_JUSTIFY); }