android touch the flow of events.

 

One. Own summary. 
From big to say, in fact, a recursion. 
When the signal is down when the tree from top to bottom, each touch event check points to which sub-group or sub-View, the aim is to progressively precise, the beginning of which is determined group, the group is then followed by a a gruop, until the most accurate view. 
Detail is 
1 . To see whether the current layer is cut, not cut, then, to find the touch point of view or the corresponding sub-sub-groupview. So progressive. 
   Cut off, and could not find touch ivew, directly into the current view of dte empty parameter functions. That is, the consumer calls the process 2. 2 .
2 . When the progression to view, is essentially a process to determine whether the consumer, whether the consumer returns.
3 . When the group is no longer progressive progressive return to the default value of false. Get the upper false.
4 . After the progressive normalization is recursive. Only two cases, the consumer has a view, no view of consumption. The return value and mFirstTouchTarget can know the result. 
If there is no view of consumption. More precise description of the lower layer is not actually processed, the range accuracy is more ambiguous whether they need to look at the current layer processing, the base class performs group (view) of dispatchtoucheven method, in fact, the method of the view. It is essentially a process to determine whether the consumer. 
If you have a view of consumption. So after the process will be skipped because the consumer has already passed.

Summary: When dealing with down completion signal, and each group has its own mFirstTouchTarget, they are not the same, this is a successive approximation process mFirstTouchTarget objective view of the last layer is the group of mFirstTouchTarget, such as buttons. 
Of course, when cut, will only deal to cut off that layer. Then no further processing, each mFirstTouchTarget is null, the processing directly to the activity. 

When not down signal. Tree from bottom to top, each variable mFirstTouchTarget see their presence or absence. (Because the performance relationship between you, the code does not write the truncated field, but firsttouche is empty, it indicates truncation is true. Fucking) 
1 . If there is, to explain their view or sub-sub-sub-view deal down. Find the child view, this recursive function. Up to the last level of recursion of view or group. view direct consumption process, group of words, passing a null. Has triggered a 2. 2 
2 . If not, (this function is the most messed up, for performance, readability is essentially 0.)
    2 .1 Description nobody handle, then I look at the process, there should be no such case, because there will be activity processing ah, if it occurs, it is no treatment, because the first layer dector will deal with, and is the default listener is null. So it should be no deal.
                        2 .2 The most common process is described in a group, when the final layer parameters over the last pass a null. That process execution group consumer base class of
                         2.3 or cut event, because the child did not go to ivew touched. Of course mFirstTouchTarget also is null, otherwise, it will not enter this layer, the upper layer on the return. Cut off the flow directly into the consumer base class. 

ps consumption process: is the view of dispath, in fact, listenter + . oneventtouch (the Click ON) 
     current layer if truncation is a function onInterceptTouchEvent 
     because the source code is not readable, is a compressed version of the code, so forget the process, then, first see the process here, and then look for the code confirmation. 
two. FIG unfinished code simplified. Because the code is the performance version. So is a fucking code! ! ! ! ! Not to be understood version. He is the younger brother of the code.

 

 
 

 

Three . Simplify the code about the process. 
>> << android development of artistic exploration and book online process is the same. Just look that strange. After reading the code yourself, found to be wrong, this is also imprudent it. 

public Boolean dispatchTouchEvent (the MotionEvent EV) 
{ 
        Boolean Consume = to false ;
         IF (onInterceptTouchEvent (EV)) { 
                Consume = onTouchEvent (EV); 
        } 
    the else  
      { 
              Consume = child.dispatchTouchEvent (EV); 
          } 
            return Consume; 
} after that the right to modify its own the




 public Boolean dispatchTouchEvent (the MotionEvent EV) 
{ 
    Boolean Consume =to false ;
     int Action = ev.getAction () & MotionEvent.ACTION_MASK; 
    intercepted = onInterceptTouchEvent (EV)
     IF (intercepted) 
    { 
        Consume = onTouchEvent (EV); 
    } 
    the else  
    { 
        IF (== Action Down) 
        { 
            Consume = child.dispatchTouchEvent ( EV);
             iF (consume == false ) // no less here, recursively back we need to determine whether the consumer is not spending, they have to be consumed. MFirstTouchTarget source is determined whether the value is null. 
            { 
                Consume =onTouchEvent (EV); 
            } 
        } 
        the else 
        { 
            IF (Child == null ) // is not in the end, if the current view is the lowest level of consumption of view. It is directly consumed. Otherwise, continue recursion. 
            { 
                Consume = onTouchEvent (EV); 
            } 
            the else 
            { 
                child.dispatchTouchEvent (EV); 
            } 
        } 
    } 
    return Consume; 
}

Guess you like

Origin www.cnblogs.com/lsfv/p/11538321.html