Code example for MotionEvent

Methods: getActionobtain

0
 
		if (!swipeEnabled)
			return super.onTouchEvent(event);
 
		// l("onTouch", event, false); 
		switch (event.getAction()) {
		case MotionEvent.ACTION_CANCEL:
			cancelAllTouchTargets(event);
			// inTouchButtonDelegate = false; 
			inTouchCheckBoxDelegate = false;
			inSuper = false;
			inGestureDetector = false;
			return false; 
		case MotionEvent.ACTION_DOWN:
			cancelAllTouchTargets(event);
 
			boolean consumed = false;
 
			if (checkBoxDelegate != null) {
				consumed = checkBoxDelegate.onTouchEvent(event);
				// l("cb touch delegate", event, consumed); 
				if (consumed) {
					inTouchCheckBoxDelegate = true;
					return true; 
				} 
			} 
 
			consumed = gestureDetector.onTouchEvent(event);
			// l("gesture detector", event, consumed); 
			if (consumed) {
				inGestureDetector = true;
				return true; 
			} 
 
			consumed = super.onTouchEvent(event);
			// l("super", event, consumed); 
			if (consumed) {
				inSuper = true;
				return true; 
			} 
 
			break; 
 
		case MotionEvent.ACTION_UP:
 
			if (inTouchCheckBoxDelegate) {
				inTouchCheckBoxDelegate = false;
				consumed = checkBoxDelegate.onTouchEvent(event);
				// l("cb touch delegate", event, consumed); 
 
				return consumed;
			} 
			if (inGestureDetector) {
				inGestureDetector = false;
				consumed = gestureDetector.onTouchEvent(event);
				// l("gesture detector", event, consumed); 
 
				return consumed;
			} 
			if (inSuper) {
				inSuper = false;
				consumed = super.onTouchEvent(event);
				// l("super", event, consumed); 
 
				return consumed;
			} 
			break; 
 
		case MotionEvent.ACTION_MOVE:
 
			if (inTouchCheckBoxDelegate) {
				consumed = checkBoxDelegate.onTouchEvent(event);
				// l("cb touch delegate", event, consumed); 
 
				return consumed;
			} 
			if (inGestureDetector) {
				consumed = gestureDetector.onTouchEvent(event);
				// l("gesture detector", event, consumed); 
 
				return consumed;
			} 
			if (inSuper) {
				consumed = super.onTouchEvent(event);
				// l("super", event, consumed); 
 
				return consumed;
			} 
			break; 
		} 
		return false; 
	} 
 
	private void cancelAllTouchTargets(MotionEvent event) {
		MotionEvent cancelEvent = MotionEvent.obtain(event);
		cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
 
		/* buttonDelegate.onTouchEvent(cancelEvent); */ 
		if (checkBoxDelegate != null)
			checkBoxDelegate.onTouchEvent(cancelEvent);