private void postTouchEvent ( MonocleWindow window , View view , TouchState newState ) { int count = countEvents ( newState ) ; switch ( count ) { case 0 : postNoPoints ( view ) ; break ; case 1 : if ( state . getPointCount ( ) == 1 ) { // There is one point and it already existed TouchState . Point oldPoint = state . getPoint ( 0 ) ; TouchState . Point newPoint = newState . getPointForID ( oldPoint . id ) ; if ( newPoint != null ) { if ( newPoint . x == oldPoint . x && newPoint . y == oldPoint . y ) { postPoint ( window , view , TouchEvent . TOUCH_STILL , newPoint ) ; } else { postPoint ( window , view , TouchEvent . TOUCH_MOVED , newPoint ) ; } } else { postPoint ( window , view , TouchEvent . TOUCH_RELEASED , oldPoint ) ; } } else { // There is one point and it is newly pressed postPoint ( window , view , TouchEvent . TOUCH_PRESSED , newState . getPoint ( 0 ) ) ; } break ; default : { int [ ] states = new int [ count ] ; int [ ] ids = new int [ count ] ; int [ ] xs = new int [ count ] ; int [ ] ys = new int [ count ] ; for ( int i = 0 ; i < state . getPointCount ( ) ; i ++ ) { TouchState . Point oldPoint = state . getPoint ( i ) ; TouchState . Point newPoint = newState . getPointForID ( oldPoint . id ) ; if ( newPoint != null ) { ids [ i ] = newPoint . id ; xs [ i ] = newPoint . x ; ys [ i ] = newPoint . y ; if ( newPoint . x == oldPoint . x && newPoint . y == oldPoint . y ) { states [ i ] = TouchEvent . TOUCH_STILL ; } else { states [ i ] = TouchEvent . TOUCH_MOVED ; } } else { states [ i ] = TouchEvent . TOUCH_RELEASED ; ids [ i ] = oldPoint . id ; xs [ i ] = oldPoint . x ; ys [ i ] = oldPoint . y ; } } // Once we have dealt with updates to old points, all that are left // are new points. for ( int i = 0 , j = state . getPointCount ( ) ; i < newState . getPointCount ( ) ; i ++ ) { TouchState . Point newPoint = newState . getPoint ( i ) ; TouchState . Point oldPoint = state . getPointForID ( newPoint . id ) ; if ( oldPoint == null ) { states [ j ] = TouchEvent . TOUCH_PRESSED ; ids [ j ] = newPoint . id ; xs [ j ] = newPoint . x ; ys [ j ] = newPoint . y ; j ++ ; } } postPoints ( window , view , states , ids , xs , ys ) ; } } }
Sends updated touch points within the same View as last processed touch points .