Android-8
/*** Pass the touch screen motion event to the target view, or this * view if it is the target. * * @paramEvent The motion event to being dispatched. * @returnTrue If the event is handled by the view, false otherwise. */ Public Booleandispatchtouchevent (Motionevent event) {if(Montouchlistener! =NULL&& (Mviewflags & enabled_mask) = = ENABLED &&Montouchlistener.ontouch ( This, event)) { return true; } returnontouchevent (event); }
Android-14, Android-15, android-16, ANDROID-17, android-18, android-19, android-20
/*** Pass the touch screen motion event to the target view, or this * view if it is the target. * * @paramEvent The motion event to being dispatched. * @returnTrue If the event is handled by the view, false otherwise. */ Public Booleandispatchtouchevent (Motionevent event) {if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.ontouchevent (event,0); } if(Onfiltertoucheventforsecurity (event)) {//noinspection simplifiableifstatement if(Montouchlistener! =NULL&& (Mviewflags & enabled_mask) = = ENABLED &&Montouchlistener.ontouch ( This, event)) { return true; } if(Ontouchevent (event)) {return true; } } if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.onunhandledevent (event,0); } return false; }
Android-21
/*** Pass the touch screen motion event to the target view, or this * view if it is the target. * * @paramEvent The motion event to being dispatched. * @returnTrue If the event is handled by the view, false otherwise. */ Public Booleandispatchtouchevent (Motionevent event) {Booleanresult =false; if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.ontouchevent (event,0); } Final intactionmasked =event.getactionmasked (); if(actionmasked = =Motionevent.action_down) { //defensive Cleanup for new gestureStopnestedscroll (); } if(Onfiltertoucheventforsecurity (event)) {//noinspection simplifiableifstatementListenerinfo 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); } //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 (); } returnresult; }
Android-22, android-23
/*** Pass the touch screen motion event to the target view, or this * view if it is the target. * * @paramEvent The motion event to being dispatched. * @returnTrue If the event is handled by the view, false otherwise. */ Public Booleandispatchtouchevent (Motionevent event) {//If The event should is handled by accessibility focus first. if(Event.istargetaccessibilityfocus ()) {//We don't have a focus or no virtual descendant has it, does not handle the event. if(!Isaccessibilityfocusedvieworhost ()) { return false; } //We have a focus and got the event, then use Normal event dispatch.Event.settargetaccessibilityfocus (false); } Booleanresult =false; if(Minputeventconsistencyverifier! =NULL) {minputeventconsistencyverifier.ontouchevent (event,0); } Final intactionmasked =event.getactionmasked (); if(actionmasked = =Motionevent.action_down) { //defensive Cleanup for new gestureStopnestedscroll (); } if(Onfiltertoucheventforsecurity (event)) {//noinspection simplifiableifstatementListenerinfo 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); } //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 (); } returnresult; }
android-8~23 View.java-dispatchtouchevent Source