在startScrolling方法里面有287行的notifyScrollingListenersAboutStart函数。
再看clearMessages()、setMessageNext()
- private void setNextMessage(int message) {
- clearMessages();
- animationHandler.sendEmptyMessage(message);
- }
- /**
- * Clears messages from queue
- */
- private void clearMessages() {
- animationHandler.removeMessages(MESSAGE_SCROLL);
- animationHandler.removeMessages(MESSAGE_JUSTIFY);
- }
里面使用到了animationHandler,用来传递动画有段的操作:
- // animation handler
- private Handler animationHandler = new Handler() {
- public void handleMessage(Message msg) {
- scroller.computeScrollOffset();
- int currY = scroller.getCurrY();
- int delta = lastScrollY - currY;
- lastScrollY = currY;
- if (delta != 0) {
- doScroll(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();
- }
- }
- };
里面调用了finishScrolling()
- /**
- * Finishes scrolling
- */
- void finishScrolling() {
完
ps:说明较少,如有问题,敬请留言探讨,很多不足之处,望多多指教。
