touchMoved Method of Class DoodleView

The touchMoved method (Fig. 7.30) is called when the user moves one or more fingers across the screen. The system MotionEvent passed from onTouchEvent contains touch information for multiple moves on the screen if they occur at the same time. MotionEvent method getPointerCount (line 222) returns the number of touches this MotionEvent describes. For each, we store the finger’s ID (line 225) in pointerID, and store the finger’s corresponding index in this MotionEvent (line 226) in pointerIndex. Then we check whether there’s a corresponding Path in the pathMap HashMap (line 229). If so, we use MotionEvent’s getX and getY methods to get the last coordinates for this drag event for the specified pointerIndex

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.