Program: 13805
Project: 13805
Buggy source:
@Override public void appendMediaFile(final MediaFile mediaFile,final String mediaUrl,ImageLoader imageLoader){
  final String safeMediaUrl=Utils.escapeQuotes(mediaUrl);
  if (URLUtil.isNetworkUrl(mediaUrl)) {
    if (mediaFile.isVideo()) {
      ToastUtils.showToast(getActivity(),R.string.media_insert_unimplemented);
    }
 else {
      imageLoader.get(mediaUrl,new ImageLoader.ImageListener(){
        @Override public void onErrorResponse(        VolleyError error){
          ToastUtils.showToast(getActivity(),R.string.error_media_load);
          Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
          AztecAttributes attributes=new AztecAttributes();
          attributes.setValue(ATTR_SRC,mediaUrl);
          setAttributeValuesIfNotDefault(attributes,mediaFile);
          content.insertImage(drawable,attributes);
        }
        @Override public void onResponse(        ImageLoader.ImageContainer container,        boolean isImmediate){
          Bitmap downloadedBitmap=container.getBitmap();
          if (downloadedBitmap == null) {
            return;
          }
          AztecAttributes attributes=new AztecAttributes();
          attributes.setValue(ATTR_SRC,mediaUrl);
          setAttributeValuesIfNotDefault(attributes,mediaFile);
          int minimumDimension=DisplayUtils.dpToPx(getActivity(),MIN_BITMAP_DIMENSION_DP);
          if (downloadedBitmap.getHeight() < minimumDimension || downloadedBitmap.getWidth() < minimumDimension) {
            ToastUtils.showToast(getActivity(),R.string.error_media_small);
            Drawable drawable=getResources().getDrawable(R.drawable.ic_image_loading_grey_a_40_48dp);
            content.insertImage(drawable,attributes);
            return;
          }
          Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,DisplayUtils.getDisplayPixelWidth(getActivity()));
          content.insertImage(new BitmapDrawable(getResources(),resizedBitmap),attributes);
        }
      }
,0,0);
    }
    mActionStartedAt=System.currentTimeMillis();
  }
 else {
    String localMediaId=String.valueOf(mediaFile.getId());
    if (mediaFile.isVideo()) {
      ToastUtils.showToast(getActivity(),R.string.media_insert_unimplemented);
    }
 else {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_ID_WP,localMediaId);
      attrs.setValue(ATTR_SRC,safeMediaUrl);
      attrs.setValue(ATTR_CLASS,ATTR_STATUS_UPLOADING);
      addDefaultSizeClassIfMissing(attrs);
      int maxWidth=DisplayUtils.getDisplayPixelWidth(getActivity());
      Bitmap bitmapToShow=ImageUtils.getWPImageSpanThumbnailFromFilePath(getActivity(),safeMediaUrl,maxWidth);
      if (bitmapToShow != null) {
        content.insertImage(new BitmapDrawable(getResources(),bitmapToShow),attrs);
      }
 else {
        ToastUtils.showToast(getActivity(),R.string.error_media_load);
        Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
        drawable.setBounds(0,0,maxWidth,maxWidth);
        content.insertImage(drawable,attrs);
      }
      AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.setOverlay(localMediaIdPredicate,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(localMediaIdPredicate,1,progressDrawable,Gravity.FILL_HORIZONTAL | Gravity.TOP);
      content.updateElementAttributes(localMediaIdPredicate,attrs);
      content.refreshText();
      mUploadingMedia.put(localMediaId,MediaType.IMAGE);
    }
  }
}

Fixed version (ground truth):
@Override public void appendMediaFile(final MediaFile mediaFile,final String mediaUrl,ImageLoader imageLoader){
  final String safeMediaUrl=Utils.escapeQuotes(mediaUrl);
  if (URLUtil.isNetworkUrl(mediaUrl)) {
    if (mediaFile.isVideo()) {
      ToastUtils.showToast(getActivity(),R.string.media_insert_unimplemented);
    }
 else {
      imageLoader.get(mediaUrl,new ImageLoader.ImageListener(){
        @Override public void onErrorResponse(        VolleyError error){
          ToastUtils.showToast(getActivity(),R.string.error_media_load);
          Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
          AztecAttributes attributes=new AztecAttributes();
          attributes.setValue(ATTR_SRC,mediaUrl);
          setAttributeValuesIfNotDefault(attributes,mediaFile);
          content.insertImage(drawable,attributes);
        }
        @Override public void onResponse(        ImageLoader.ImageContainer container,        boolean isImmediate){
          Bitmap downloadedBitmap=container.getBitmap();
          if (downloadedBitmap == null) {
            return;
          }
          AztecAttributes attributes=new AztecAttributes();
          attributes.setValue(ATTR_SRC,mediaUrl);
          setAttributeValuesIfNotDefault(attributes,mediaFile);
          int minimumDimension=DisplayUtils.dpToPx(getActivity(),MIN_BITMAP_DIMENSION_DP);
          if (downloadedBitmap.getHeight() < minimumDimension || downloadedBitmap.getWidth() < minimumDimension) {
            ToastUtils.showToast(getActivity(),R.string.error_media_small);
            Drawable drawable=getResources().getDrawable(R.drawable.ic_image_loading_grey_a_40_48dp);
            content.insertImage(drawable,attributes);
            return;
          }
          Bitmap resizedBitmap=ImageUtils.getScaledBitmapAtLongestSide(downloadedBitmap,DisplayUtils.getDisplayPixelWidth(getActivity()));
          content.insertImage(new BitmapDrawable(getResources(),resizedBitmap),attributes);
        }
      }
,0,0);
    }
    mActionStartedAt=System.currentTimeMillis();
  }
 else {
    String localMediaId=String.valueOf(mediaFile.getId());
    if (mediaFile.isVideo()) {
      ToastUtils.showToast(getActivity(),R.string.media_insert_unimplemented);
    }
 else {
      AztecAttributes attrs=new AztecAttributes();
      attrs.setValue(ATTR_ID_WP,localMediaId);
      attrs.setValue(ATTR_SRC,safeMediaUrl);
      attrs.setValue(ATTR_CLASS,ATTR_STATUS_UPLOADING);
      addDefaultSizeClassIfMissing(attrs);
      int maxWidth=DisplayUtils.getDisplayPixelWidth(getActivity());
      Bitmap bitmapToShow=ImageUtils.getWPImageSpanThumbnailFromFilePath(getActivity(),safeMediaUrl,maxWidth);
      if (bitmapToShow != null) {
        content.insertImage(new BitmapDrawable(getResources(),bitmapToShow),attrs);
      }
 else {
        ToastUtils.showToast(getActivity(),R.string.error_media_load);
        Drawable drawable=getResources().getDrawable(R.drawable.ic_image_failed_grey_a_40_48dp);
        drawable.setBounds(0,0,maxWidth,maxWidth);
        content.insertImage(drawable,attrs);
      }
      AztecText.AttributePredicate localMediaIdPredicate=ImagePredicate.getLocalMediaIdPredicate(localMediaId);
      content.setOverlay(localMediaIdPredicate,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(localMediaIdPredicate,1,progressDrawable,Gravity.FILL_HORIZONTAL | Gravity.TOP);
      content.updateElementAttributes(localMediaIdPredicate,attrs);
      content.resetAttributedMediaSpan(localMediaIdPredicate);
      mUploadingMedia.put(localMediaId,MediaType.IMAGE);
    }
  }
}