@Override
    public boolean onTouchEvent(final MotionEvent event) {
        if (!inputEnabled || !isEnabled()) {
            return false;
        }

        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                handleActionDown(event);
                return true;
            case MotionEvent.ACTION_UP:
                handleActionUp();
                return true;
            case MotionEvent.ACTION_MOVE:
                handleActionMove(event);
                return true;
            case MotionEvent.ACTION_CANCEL:
            /*
             * Original source check for patternInProgress == true first before
			 * calling next three lines. But if we do that, there will be
			 * nothing happened when the user taps at empty area and releases
			 * the finger. We want the pattern to be reset and the message will
			 * be updated after the user did that.
			 */
                patternInProgress = false;
                resetPattern();
                notifyPatternCleared();

                if (PROFILE_DRAWING) {
                    if (drawingProfilingStarted) {
                        Debug.stopMethodTracing();
                        drawingProfilingStarted = false;
                    }
                }
                return true;
        }
        return false;
    }
Helper method to find the column x fallis into.

@param x The x coordinate.
@return The column that x falls in, or -1 if it falls in no column.
android-patternview/src/main/java/com/eftimoff/patternview/PatternView.java