private Cell detectAndAddHit(float x,float y){
  final Cell cell=checkForNewHit(x,y);
  if (cell != null) {
    Cell fillInGapCell=null;
    final ArrayList<Cell> pattern=mPattern;
    if (!pattern.isEmpty()) {
      final Cell lastCell=pattern.get(pattern.size() - 1);
      int dRow=cell.row - lastCell.row;
      int dColumn=cell.column - lastCell.column;
      int fillInRow=lastCell.row;
      int fillInColumn=lastCell.column;
      if (Math.abs(dRow) == 2 && Math.abs(dColumn) != 1) {
        fillInRow=lastCell.row + ((dRow > 0) ? 1 : -1);
      }
      if (Math.abs(dColumn) == 2 && Math.abs(dRow) != 1) {
        fillInColumn=lastCell.column + ((dColumn > 0) ? 1 : -1);
      }
      fillInGapCell=Cell.of(fillInRow,fillInColumn);
    }
    if (fillInGapCell != null && !mPatternDrawLookup[fillInGapCell.row][fillInGapCell.column]) {
      addCellToPattern(fillInGapCell);
    }
    addCellToPattern(cell);
    return cell;
  }
  return null;
}

private Cell detectAndAddHit ( float x , float y ) { final Cell cell = checkForNewHit ( x , y ) ; if ( cell != null ) { Cell fillInGapCell = null ; final ArrayList < Cell > pattern = mPattern ; if ( ! pattern . isEmpty ( ) ) { final Cell lastCell = pattern . get ( pattern . size ( ) - 1 ) ; int dRow = cell . row - lastCell . row ; int dColumn = cell . column - lastCell . column ; int fillInRow = lastCell . row ; int fillInColumn = lastCell . column ; if ( Math . abs ( dRow ) == 2 && Math . abs ( dColumn ) != 1 ) { fillInRow = lastCell . row + ( ( dRow > 0 ) ? 1 : - 1 ) ; } if ( Math . abs ( dColumn ) == 2 && Math . abs ( dRow ) != 1 ) { fillInColumn = lastCell . column + ( ( dColumn > 0 ) ? 1 : - 1 ) ; } fillInGapCell = Cell . of ( fillInRow , fillInColumn ) ; } if ( fillInGapCell != null && ! mPatternDrawLookup [ fillInGapCell . row ] [ fillInGapCell . column ] ) { addCellToPattern ( fillInGapCell ) ; } addCellToPattern ( cell ) ; return cell ; } return null ; }
determines whether the point x , y will add a new point to the current pattern ( in addition to finding the cell , also makes heuristic choices such as filling in gaps based on current pattern ) .
