Program: 13812
Project: 13812
Buggy source:
public void onMediaTapped(final String localMediaId,final MediaType mediaType,final JSONObject meta,String uploadStatus){
  if (mediaType == null || !isAdded()) {
    return;
  }
switch (uploadStatus) {
case ATTR_STATUS_UPLOADING:
    AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  builder.setTitle(getString(R.string.stop_upload_dialog_title));
builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
  public void onClick(  DialogInterface dialog,  int id){
    if (mUploadingMedia.containsKey(localMediaId)) {
      mEditorFragmentListener.onMediaUploadCancelClicked(localMediaId,true);
switch (mediaType) {
case IMAGE:
        content.removeMedia(mTappedImagePredicate);
      break;
case VIDEO:
  }
  mUploadingMedia.remove(localMediaId);
}
 else {
  ToastUtils.showToast(getActivity(),R.string.upload_finished_toast).show();
}
dialog.dismiss();
}
}
);
builder.setNegativeButton(getString(R.string.cancel),new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
dialog.dismiss();
}
}
);
AlertDialog dialog=builder.create();
dialog.show();
break;
case ATTR_STATUS_FAILED:
if (mFailedMediaIds.contains(localMediaId)) {
mEditorFragmentListener.onMediaRetryClicked(localMediaId);
}
switch (mediaType) {
case IMAGE:
AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(mTappedImagePredicate));
attributesWithClass.removeClass(ATTR_STATUS_FAILED);
attributesWithClass.addClass(ATTR_STATUS_UPLOADING);
content.setOverlay(mTappedImagePredicate,0,new ColorDrawable(getResources().getColor(R.color.media_shade_overlay_color)),Gravity.FILL);
Drawable progressDrawable=getResources().getDrawable(android.R.drawable.progress_horizontal);
progressDrawable.setBounds(0,0,0,4);
content.setOverlay(mTappedImagePredicate,1,progressDrawable,Gravity.FILL_HORIZONTAL | Gravity.TOP);
content.updateElementAttributes(mTappedImagePredicate,attributesWithClass.getAttributes());
content.refreshText();
break;
case VIDEO:
}
mFailedMediaIds.remove(localMediaId);
mUploadingMedia.put(localMediaId,mediaType);
break;
default :
if (!mediaType.equals(MediaType.IMAGE)) {
return;
}
FragmentManager fragmentManager=getFragmentManager();
if (fragmentManager.findFragmentByTag(ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_TAG) != null) {
return;
}
mEditorFragmentListener.onTrackableEvent(TrackableEvent.IMAGE_EDITED);
ImageSettingsDialogFragment imageSettingsDialogFragment=new ImageSettingsDialogFragment();
imageSettingsDialogFragment.setImageLoader(mImageLoader);
imageSettingsDialogFragment.setTargetFragment(this,ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_REQUEST_CODE);
Bundle dialogBundle=new Bundle();
dialogBundle.putString(EXTRA_MAX_WIDTH,mBlogSettingMaxImageWidth);
dialogBundle.putBoolean(EXTRA_IMAGE_FEATURED,mFeaturedImageSupported);
dialogBundle.putBoolean(EXTRA_ENABLED_AZTEC,true);
try {
final String imageSrc=meta.getString(ATTR_SRC);
String authHeader=mEditorFragmentListener.onAuthHeaderRequested(UrlUtils.makeHttps(imageSrc));
if (authHeader.length() > 0) {
meta.put(ATTR_SRC,UrlUtils.makeHttps(imageSrc));
}
}
 catch (JSONException e) {
AppLog.e(AppLog.T.EDITOR,"String_Node_Str");
}
dialogBundle.putString(EXTRA_IMAGE_META,meta.toString());
String imageId=JSONUtils.getString(meta,ATTR_ID_ATTACHMENT);
if (!imageId.isEmpty()) {
dialogBundle.putBoolean(EXTRA_FEATURED,mFeaturedImageId == Integer.parseInt(imageId));
}
imageSettingsDialogFragment.setArguments(dialogBundle);
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.add(android.R.id.content,imageSettingsDialogFragment,ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_TAG).addToBackStack(null).commit();
break;
}
}

Fixed version (ground truth):
public void onMediaTapped(final String localMediaId,final MediaType mediaType,final JSONObject meta,String uploadStatus){
  if (mediaType == null || !isAdded()) {
    return;
  }
switch (uploadStatus) {
case ATTR_STATUS_UPLOADING:
    AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  builder.setTitle(getString(R.string.stop_upload_dialog_title));
builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
  public void onClick(  DialogInterface dialog,  int id){
    if (mUploadingMedia.containsKey(localMediaId)) {
      mEditorFragmentListener.onMediaUploadCancelClicked(localMediaId,true);
switch (mediaType) {
case IMAGE:
        content.removeMedia(mTappedImagePredicate);
      break;
case VIDEO:
  }
  mUploadingMedia.remove(localMediaId);
}
 else {
  ToastUtils.showToast(getActivity(),R.string.upload_finished_toast).show();
}
dialog.dismiss();
}
}
);
builder.setNegativeButton(getString(R.string.cancel),new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int id){
dialog.dismiss();
}
}
);
AlertDialog dialog=builder.create();
dialog.show();
break;
case ATTR_STATUS_FAILED:
if (mFailedMediaIds.contains(localMediaId)) {
mEditorFragmentListener.onMediaRetryClicked(localMediaId);
}
switch (mediaType) {
case IMAGE:
AttributesWithClass attributesWithClass=new AttributesWithClass(content.getElementAttributes(mTappedImagePredicate));
attributesWithClass.removeClass(ATTR_STATUS_FAILED);
attributesWithClass.addClass(ATTR_STATUS_UPLOADING);
content.setOverlay(mTappedImagePredicate,0,new ColorDrawable(getResources().getColor(R.color.media_shade_overlay_color)),Gravity.FILL);
Drawable progressDrawable=getResources().getDrawable(android.R.drawable.progress_horizontal);
progressDrawable.setBounds(0,0,0,4);
content.setOverlay(mTappedImagePredicate,1,progressDrawable,Gravity.FILL_HORIZONTAL | Gravity.TOP);
content.updateElementAttributes(mTappedImagePredicate,attributesWithClass.getAttributes());
content.resetAttributedMediaSpan(mTappedImagePredicate);
break;
case VIDEO:
}
mFailedMediaIds.remove(localMediaId);
mUploadingMedia.put(localMediaId,mediaType);
break;
default :
if (!mediaType.equals(MediaType.IMAGE)) {
return;
}
FragmentManager fragmentManager=getFragmentManager();
if (fragmentManager.findFragmentByTag(ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_TAG) != null) {
return;
}
mEditorFragmentListener.onTrackableEvent(TrackableEvent.IMAGE_EDITED);
ImageSettingsDialogFragment imageSettingsDialogFragment=new ImageSettingsDialogFragment();
imageSettingsDialogFragment.setImageLoader(mImageLoader);
imageSettingsDialogFragment.setTargetFragment(this,ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_REQUEST_CODE);
Bundle dialogBundle=new Bundle();
dialogBundle.putString(EXTRA_MAX_WIDTH,mBlogSettingMaxImageWidth);
dialogBundle.putBoolean(EXTRA_IMAGE_FEATURED,mFeaturedImageSupported);
dialogBundle.putBoolean(EXTRA_ENABLED_AZTEC,true);
try {
final String imageSrc=meta.getString(ATTR_SRC);
String authHeader=mEditorFragmentListener.onAuthHeaderRequested(UrlUtils.makeHttps(imageSrc));
if (authHeader.length() > 0) {
meta.put(ATTR_SRC,UrlUtils.makeHttps(imageSrc));
}
}
 catch (JSONException e) {
AppLog.e(AppLog.T.EDITOR,"String_Node_Str");
}
dialogBundle.putString(EXTRA_IMAGE_META,meta.toString());
String imageId=JSONUtils.getString(meta,ATTR_ID_ATTACHMENT);
if (!imageId.isEmpty()) {
dialogBundle.putBoolean(EXTRA_FEATURED,mFeaturedImageId == Integer.parseInt(imageId));
}
imageSettingsDialogFragment.setArguments(dialogBundle);
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
fragmentTransaction.add(android.R.id.content,imageSettingsDialogFragment,ImageSettingsDialogFragment.IMAGE_SETTINGS_DIALOG_TAG).addToBackStack(null).commit();
break;
}
}