Source:
protected void setupTouchListener( final View view, final int idx, TappingIntervalResult.TappingButtonIdentifier buttonId, boolean countsAsATap) { view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: if (lastPointerIdx[idx] == INVALID_POINTER_IDX) { buttonSamples[idx] = new TappingIntervalResult.Sample(); buttonSamples[idx].setTimestamp(motionEvent.getEventTime() - startTime); buttonSamples[idx].setButtonIdentifier(buttonId); buttonSamples[idx].setLocation(new TappingIntervalResult.Point( (int)(motionEvent.getX() + leftButtonRect.left), (int)(motionEvent.getY() + leftButtonRect.top))); lastPointerIdx[idx] = motionEvent.getActionMasked(); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_CANCEL: boolean correctFingerForIdx = motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL || (motionEvent.getActionMasked() == MotionEvent.ACTION_UP && lastPointerIdx[idx] == MotionEvent.ACTION_DOWN) || (motionEvent.getActionMasked() == MotionEvent.ACTION_POINTER_UP && lastPointerIdx[idx] == MotionEvent.ACTION_POINTER_DOWN); if (buttonSamples[idx] != null && correctFingerForIdx) { buttonSamples[idx].setDuration(motionEvent.getDownTime()); sampleList.add(buttonSamples[idx]); buttonSamples[idx] = null; lastPointerIdx[idx] = INVALID_POINTER_IDX; if (countsAsATap) { countATap(); } Log.d("TODO_REMOVE", "tap up with idx " + idx); } break; } if (!countsAsATap) { return true; } else { return view.onTouchEvent(motionEvent); } } }); }

Target:
protected void setupTouchListener( final View view, final int idx, TappingIntervalResult.TappingButtonIdentifier buttonId, boolean countsAsATap) { view.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getActionMasked()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: if (lastPointerIdx[idx] == INVALID_POINTER_IDX) { buttonSamples[idx] = new TappingIntervalResult.Sample(); buttonSamples[idx].setTimestamp(motionEvent.getEventTime() - startTime); buttonSamples[idx].setButtonIdentifier(buttonId); buttonSamples[idx].setLocation(new TappingIntervalResult.Point( (int)(motionEvent.getX() + leftButtonRect.left), (int)(motionEvent.getY() + leftButtonRect.top))); lastPointerIdx[idx] = motionEvent.getActionMasked(); LogExt.d(getClass(), "tap down with button idx " + idx); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_CANCEL: boolean correctFingerForIdx = motionEvent.getActionMasked() == MotionEvent.ACTION_CANCEL || (motionEvent.getActionMasked() == MotionEvent.ACTION_UP && lastPointerIdx[idx] == MotionEvent.ACTION_DOWN) || (motionEvent.getActionMasked() == MotionEvent.ACTION_POINTER_UP && lastPointerIdx[idx] == MotionEvent.ACTION_POINTER_DOWN); if (buttonSamples[idx] != null && correctFingerForIdx) { buttonSamples[idx].setDuration(motionEvent.getDownTime()); sampleList.add(buttonSamples[idx]); buttonSamples[idx] = null; lastPointerIdx[idx] = INVALID_POINTER_IDX; if (countsAsATap) { countATap(); } LogExt.d(getClass(), "tap up with button idx " + idx); } break; } if (!countsAsATap) { return true; } else { return view.onTouchEvent(motionEvent); } } }); }