[Demonstration 1]

[Buggy Method]
public Mat drawSudokuSquares(int width, int height) {
    if (hlavolam == null) {
        return drawMergedLinesAfterTransform(width, height);
    }
    Mat rgba = new Mat(picture.image.size(), picture.image.type());
    picture.image.copyTo(rgba);
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            Scalar color;
            if (hlavolam.getLetters()[i][j].getHasChar())
                color = new Scalar(255, 0, 0);
            else
                color = new Scalar(0, 255, 0);
            //Imgproc.rectangle( rgba, hlavolam.getLetters()[i][j].rect.tl(), hlavolam.getLetters()[i][j].rect.br(), color, 2, 8, 0 );
            Log.e(TAG, "drawSudokuSquares: Size>" + sols.size() + " IsEmpty> " + sols.isEmpty() + " String> " + sols.toString());
            if (sols.isEmpty()) {
                if (hlavolam.getLetters()[i][j].getHasChar()) {
                    Point[] segment = hlavolam.getLetters()[i][j].getSegment().toArray();
                    Imgproc.putText(rgba, hlavolam.getLetters()[i][j].character, segment[2], Core.FONT_HERSHEY_SIMPLEX, 1.5, new Scalar(255, 0, 0), 5);
                } else {
                    Point[] segment = hlavolam.getLetters()[i][j].getSegment().toArray();
                    Imgproc.putText(rgba, "X", segment[2], Core.FONT_HERSHEY_SIMPLEX, 3, new Scalar(0, 0, 255), 5);
                }
            } else {
                int[][] sol = sols.get(0);
                if (hlavolam.getLetters()[i][j].getHasChar()) {
                    Point[] segment = hlavolam.getLetters()[i][j].getSegment().toArray();
                    Imgproc.putText(rgba, hlavolam.getLetters()[i][j].character, segment[2], Core.FONT_HERSHEY_SIMPLEX, 1.5, new Scalar(255, 0, 0), 5);
                } else {
                    Point[] segment = hlavolam.getLetters()[i][j].getSegment().toArray();
                    Imgproc.putText(rgba, Integer.toString(sol[i][j]), segment[2], Core.FONT_HERSHEY_SIMPLEX, 3, new Scalar(0, 0, 255), 5);
                }
            }
        }
    }
    rgba = CustomMathOperations.rotateMat(rgba, CustomMathOperations.ROTATE_LEFT);
    Mat resizeimage = new Mat(width, height, rgba.type());
    Size sz = new Size(width, height);
    Imgproc.resize(rgba, resizeimage, sz);
    return resizeimage;
}

[Buggy Hunk]
if(hlavolam == null) {

[Patch]
if(hlavolam == null || isSudoku != true) {

[Demonstration 2]

[Buggy Method]
public static void createTextBitmap(String string, final String fontName, final int fontSize, final int alignment, final int width, final int height) {
    // text font and color
    createTextBitmapShadowStroke(// text font and color
    string, // text font and color
    fontName, // text font and color
    fontSize, // text font and color
    255, // text font and color
    255, // text font and color
    255, // text font and color
    255, // alignment and size
    alignment, // alignment and size
    width, // alignment and size
    height, // no shadow
    false, // no shadow
    0.0f, // no shadow
    0.0f, // no shadow
    0.0f, // no shadow
    0.0f, false, 255, 255, 255, 255, // no stroke
    0.0f);
}

[Buggy Hunk]
createTextBitmapShadowStroke( string, fontName, fontSize, 255, 255, 255, 255,   // text font and color

[Patch]
createTextBitmapShadowStroke( string.getBytes(), fontName, fontSize, 255, 255, 255, 255,   // text font and color

[Demonstration 3]

[Buggy Method]
@Override
public boolean hasNext() {
    return list.size() > currentIndex;
}

[Buggy Hunk]
return list.size() > currentIndex;

[Patch]
return currentIndex < ArrayList.this.size();