Program: 13831
Project: 13831
Buggy source:
public void onMediaTapped(final String mediaId,final MediaType mediaType,final JSONObject meta,String uploadStatus){
  if (mediaType == null || !isAdded()) {
    return;
  }
switch (uploadStatus) {
case ATTR_STATUS_UPLOADING:
    if (TextUtils.isEmpty(mediaId) || StringUtils.stringToInt(mediaId) <= 0) {
      return;
    }
  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){
  mEditorFragmentListener.onMediaUploadCancelClicked(mediaId,true);
  mWebView.post(new Runnable(){
    @Override public void run(){
switch (mediaType) {
case IMAGE:
        mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
      break;
case VIDEO:
    mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
}
mUploadingMedia.remove(mediaId);
}
}
);
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 (TextUtils.isEmpty(mediaId) || StringUtils.stringToInt(mediaId) <= 0) {
return;
}
mEditorFragmentListener.onMediaRetryClicked(mediaId);
mWebView.post(new Runnable(){
@Override public void run(){
switch (mediaType) {
case IMAGE:
mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
break;
case VIDEO:
mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
}
mFailedMediaIds.remove(mediaId);
mUploadingMedia.put(mediaId,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);
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(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();
mWebView.notifyVisibilityChanged(false);
break;
}
}

Fixed version (ground truth):
public void onMediaTapped(final String mediaId,final MediaType mediaType,final JSONObject meta,String uploadStatus){
  if (mediaType == null || !isAdded()) {
    return;
  }
switch (uploadStatus) {
case ATTR_STATUS_UPLOADING:
    if (TextUtils.isEmpty(mediaId) || StringUtils.stringToInt(mediaId) <= 0) {
      return;
    }
  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){
  mEditorFragmentListener.onMediaUploadCancelClicked(mediaId);
  mWebView.post(new Runnable(){
    @Override public void run(){
switch (mediaType) {
case IMAGE:
        mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
      break;
case VIDEO:
    mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
}
mUploadingMedia.remove(mediaId);
}
}
);
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 (TextUtils.isEmpty(mediaId) || StringUtils.stringToInt(mediaId) <= 0) {
return;
}
mEditorFragmentListener.onMediaRetryClicked(mediaId);
mWebView.post(new Runnable(){
@Override public void run(){
switch (mediaType) {
case IMAGE:
mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
break;
case VIDEO:
mWebView.execJavaScriptFromString("String_Node_Str" + mediaId + "String_Node_Str");
}
mFailedMediaIds.remove(mediaId);
mUploadingMedia.put(mediaId,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);
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(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();
mWebView.notifyVisibilityChanged(false);
break;
}
}