[Demonstration 1]

[Buggy Method]
@Override
public void onDialogPositiveClick(DialogFragment dialog, ColourOptions colour, int position) {
    int drawable = colour.ColourDrawable();
    colours.add(position, drawable);
    circles.get(position).setImageDrawable(getResources().getDrawable(drawable));
    colourChangedCircles.add(circles.get(position));
    dialog.dismiss();
}

[Buggy Hunk]
colours.add(position, drawable);

[Patch]
setColours.put(position, drawable);

[Demonstration 2]

[Buggy Method]
@Override
public void onResume() {
    super.onResume();
    if (dialogsAdapter != null) {
        dialogsAdapter.notifyDataSetChanged();
    }
    if (dialogsSearchAdapter != null) {
        dialogsSearchAdapter.notifyDataSetChanged();
    }
    presentFragment(new ChatActivity(BuildVars.args), true);
}

[Buggy Hunk]
presentFragment(new ChatActivity(BuildVars.args), true);

[Patch]
openChatActivity();

[Demonstration 3]

[Buggy Method]
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == 0) {
            Utilities.addMediaToGallery(currentPicturePath);
            processSendingPhoto(currentPicturePath, null);
            currentPicturePath = null;
        } else if (requestCode == 1) {
            if (data == null || data.getData() == null) {
                showAttachmentError();
                return;
            }
            processSendingPhoto(null, data.getData());
        } else if (requestCode == 2) {
            String videoPath = null;
            if (data != null) {
                Uri uri = data.getData();
                boolean fromCamera = false;
                if (uri != null && uri.getScheme() != null) {
                    fromCamera = uri.getScheme().contains("file");
                } else if (uri == null) {
                    fromCamera = true;
                }
                if (fromCamera) {
                    if (uri != null) {
                        videoPath = uri.getPath();
                    } else {
                        videoPath = currentPicturePath;
                    }
                    Utilities.addMediaToGallery(currentPicturePath);
                    currentPicturePath = null;
                } else {
                    try {
                        videoPath = Utilities.getPath(uri);
                    } catch (Exception e) {
                        FileLog.e("tmessages", e);
                    }
                }
            }
            if (videoPath == null && currentPicturePath != null) {
                File f = new File(currentPicturePath);
                if (f.exists()) {
                    videoPath = currentPicturePath;
                }
                currentPicturePath = null;
            }
            if (android.os.Build.VERSION.SDK_INT >= 16) {
                Bundle args = new Bundle();
                args.putString("videoPath", videoPath);
                VideoEditorActivity fragment = new VideoEditorActivity(args);
                fragment.setDelegate(this);
                presentFragment(fragment);
            } else {
                processSendingVideo(videoPath, 0, 0, 0, 0, null);
            }
        } else if (requestCode == 21) {
            if (data == null || data.getData() == null) {
                showAttachmentError();
                return;
            }
            String tempPath = Utilities.getPath(data.getData());
            String originalPath = tempPath;
            if (tempPath == null) {
                originalPath = data.toString();
                tempPath = MediaController.copyDocumentToCache(data.getData(), "file");
            }
            if (tempPath == null) {
                showAttachmentError();
                return;
            }
            processSendingDocument(tempPath, originalPath);
        }
    }
}

[Buggy Hunk]
presentFragment(fragment);

[Patch]
presentFragment(fragment, false, true);