android-23 View.java - dispatchTouchEvent源码
2016-10-13 16:30
453 查看
public class View implements Drawable.Callback, KeyEvent.Callback, AccessibilityEventSource { /** * Pass the touch screen motion event down to the target view, or this * view if it is the target. * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. */ public boolean dispatchTouchEvent(MotionEvent event) { // If the event should be handled by accessibility focus first. if (event.isTargetAccessibilityFocus()) { // We don't have focus or no virtual descendant has it, do not handle the event. if (!isAccessibilityFocusedViewOrHost()) { return false; } // We have focus and got the event, then use normal event dispatch. event.setTargetAccessibilityFocus(false); } boolean result = false; if (mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onTouchEvent(event, 0); } final int actionMasked = event.getActionMasked(); if (actionMasked == MotionEvent.ACTION_DOWN) { // Defensive cleanup for new gesture stopNestedScroll(); } if (onFilterTouchEventForSecurity(event)) { //noinspection SimplifiableIfStatement ListenerInfo li = mListenerInfo; if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED && li.mOnTouchListener.onTouch(this, event)) { result = true; } if (!result && onTouchEvent(event)) { result = true; } } if (!result && mInputEventConsistencyVerifier != null) { mInputEventConsistencyVerifier.onUnhandledEvent(event, 0); } // Clean up after nested scrolls if this is the end of a gesture; // also cancel it if we tried an ACTION_DOWN but we didn't want the rest // of the gesture. if (actionMasked == MotionEvent.ACTION_UP || actionMasked == MotionEvent.ACTION_CANCEL || (actionMasked == MotionEvent.ACTION_DOWN && !result)) { stopNestedScroll(); } return result; } }
相关文章推荐
- android-8~23 View.java - dispatchTouchEvent源码
- Android java.lang.IllegalArgumentException: parameter must be a descendant of this view
- Android 中文 API (23) —— MultiAutoCompleteTextView.Tokenizer
- java.lang.ClassCastException: android.widget.ImageView
- android动态布局:用java代码实现LinearLayout以及TextView
- android webview中js与java互相调用
- android中调用findViewById时出现:java.lang.NullPointerException
- java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.L
- Android 中 java 与 webview 的交互
- java.lang.ClassCastException: android.widget.ImageView
- Android的Webview中,javascript如何调用java方法
- Android---Java与WebView的交互之Goolge翻译
- android webView中的html页面通过javascript访问java代码
- Android中WebView载入本地HTML代码并实现Java与JavaScript交互
- Android中WebView实现Javascript调用Java类方法
- Android 中文 API (23) —— MultiAutoCompleteTextView.Tokenizer
- android:如何在java代码中覆盖webview中的javascript事件
- Android入门之AutoCompleteTextView(纯java)
- Android中WebView实现Javascript调用Java类方法
- android webview用法小结2 java与javascript的交互