コード例 #1
0
  private static String buildAttachment(
      ThreadRowInfo row, boolean showImage, int imageQuality, HashSet<String> imageURLSet) {

    if (row == null || row.getAttachs() == null || row.getAttachs().size() == 0) {
      return "";
    }
    StringBuilder ret = new StringBuilder();
    ThemeManager theme = ThemeManager.getInstance();
    ret.append("<br/><br/>").append(attachment).append("<hr/><br/>");
    // ret.append("<table style='background:#e1c8a7;border:1px solid #b9986e;margin:0px 0px 10px
    // 30px;padding:10px;color:#6b2d25;max-width:100%;'>");
    if (theme.mode == theme.MODE_NIGHT) {
      ret.append(
          "<table style='background:#000000;border:1px solid #b9986e;padding:10px;color:#6b2d25;font-size:2'>");
    } else {
      ret.append(
          "<table style='background:#e1c8a7;border:1px solid #b9986e;padding:10px;color:#6b2d25;font-size:2'>");
    }
    ret.append("<tbody>");
    Iterator<Entry<String, Attachment>> it = row.getAttachs().entrySet().iterator();
    int attachmentCount = 0;
    while (it.hasNext()) {
      Entry<String, Attachment> entry = it.next();
      if (imageURLSet != null
          && imageURLSet.size() > 0
          && imageURLSet.contains(entry.getValue().getAttachurl())) {
        continue;
      }
      // String url = "http://img.nga.178.com/attachments/" +
      // entry.getValue().getAttachurl();
      ret.append("<tr><td><a href='http://" + HttpUtil.NGA_ATTACHMENT_HOST + "/attachments/");
      ret.append(entry.getValue().getAttachurl());
      ret.append("'>");
      if (showImage) {
        String attachURL =
            "http://"
                + HttpUtil.NGA_ATTACHMENT_HOST
                + "/attachments/"
                + entry.getValue().getAttachurl();
        if ("1".equals(entry.getValue().getThumb())) {
          attachURL = attachURL + ".thumb.jpg";
          // ret.append(entry.getValue().getExt());
        } else {
          attachURL = StringUtil.buildOptimizedImageURL(attachURL, imageQuality);
        }
        ret.append("<img src='");
        ret.append(attachURL);
      } else {
        ret.append("<img src='file:///android_asset/ic_offline_image.png");
      }

      ret.append("' style= 'max-width:70%;'></a>");

      ret.append("</td></tr>");
      attachmentCount++;
    }
    ret.append("</tbody></table>");
    if (attachmentCount == 0) return "";
    else return ret.toString();
  }