[Demonstration 1]

[Buggy Method]
public void openBrushSizeDialog(int i) {
    if (dialog == null) {
        dialog = new BrushSizeDialog(this, i, drawView.getBrushSize());
    }
}

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

[Patch]
if(dialog==null || !dialog.isShowing()){

[Demonstration 2]

[Buggy Method]
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    /*
		 * Google Play services can resolve some errors it detects. If the error
		 * has a resolution, try sending an Intent to start a Google Play
		 * services activity that can resolve error.
		 */
    if (connectionResult.hasResolution()) {
        try {
            // Start an Activity that tries to resolve the error
            connectionResult.startResolutionForResult(mCordova.getActivity(), LocationUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST);
        } catch (IntentSender.SendIntentException e) {
            // Log the error
            e.printStackTrace();
        }
    } else {
        // If no resolution is available, display a dialog to the user with
        // the error.
        showErrorDialog(connectionResult.getErrorCode());
    }
}

[Buggy Hunk]
showErrorDialog(connectionResult.getErrorCode());

[Patch]
showErrorDialog(connectionResult.getErrorCode(), LocationUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST);

[Demonstration 3]

[Buggy Method]
private void openMarkItemDialog(final ItemEntry itemEntry) {
    final Dialog dialog = new Dialog(getContext());
    dialog.setContentView(R.layout.dialog_choose_bought_amount);
    dialog.setTitle("How many " + itemEntry + " did u buy?");
    final EditText AmountEditText = (EditText) dialog.findViewById(R.id.dialog_txtBoughtItemAmount);
    Button btAbort = (Button) dialog.findViewById(R.id.dialog_btAbortBoughtItemDialog);
    Button btBoughtAmount = (Button) dialog.findViewById(R.id.dialog_btBoughtAmount);
    Button btBoughtAll = (Button) dialog.findViewById(R.id.dialog_btBoughtAll);
    btAbort.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    btBoughtAmount.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            _productHolder.markItemAsBought(itemEntry, itemEntry.getAmount() - Integer.parseInt(AmountEditText.getText().toString()));
            productsChanged();
            dialog.dismiss();
        }
    });
    btBoughtAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            _productHolder.markItemAsBought(itemEntry);
            productsChanged();
            dialog.dismiss();
        }
    });
    dialog.show();
}

[Buggy Hunk]
_productHolder.markItemAsBought(itemEntry, itemEntry.getAmount() - Integer.parseInt(AmountEditText.getText().toString()));

[Patch]
_productHolder.markItemAsBought(itemEntry, Integer.parseInt(AmountEditText.getText().toString()));