private static String buildComment(
      ThreadRowInfo row, String fgColor, boolean showImage, int imageQuality) {
    if (row == null || row.getComments() == null || row.getComments().size() == 0) {
      return "";
    }

    StringBuilder ret = new StringBuilder();
    ret.append("<br/></br>").append(comment).append("<hr/><br/>");
    ret.append("<table border='1px' cellspacing='0px' style='border-collapse:collapse;");
    ret.append("color:");
    ret.append(fgColor);
    ret.append("'>");

    ret.append("<tbody>");

    Iterator<ThreadRowInfo> it = row.getComments().iterator();
    while (it.hasNext()) {
      ThreadRowInfo comment = it.next();
      ret.append("<tr><td>");
      ret.append("<span style='font-weight:bold' >");
      ret.append(comment.getAuthor());
      ret.append("</span><br/>");
      ret.append("<img src='");
      String avatarUrl = FunctionUtil.parseAvatarUrl(comment.getJs_escap_avatar());
      ret.append(avatarUrl);
      ret.append("' style= 'max-width:32;'>");

      ret.append("</td><td>");
      ret.append(StringUtil.decodeForumTag(comment.getContent(), showImage, imageQuality, null));
      ret.append("</td></tr>");
    }
    ret.append("</tbody></table>");
    return ret.toString();
  }
Exemplo n.º 2
0
  private boolean isComment(ThreadRowInfo row) {

    return row.getAlterinfo() == null
        && row.getAttachs() == null
        && row.getComments() == null
        && row.getJs_escap_avatar() == null
        && row.getLevel() == null
        && row.getSignature() == null;
  }
  private void handleAvatar(ImageView avatarIV, ThreadRowInfo row) {

    final int lou = row.getLou();
    final String avatarUrl = FunctionUtil.parseAvatarUrl(row.getJs_escap_avatar()); //
    final String userId = String.valueOf(row.getAuthorid());
    if (PhoneConfiguration.getInstance().nikeWidth < 3) {
      avatarIV.setImageBitmap(null);
      return;
    }
    if (defaultAvatar == null
        || defaultAvatar.getWidth() != PhoneConfiguration.getInstance().nikeWidth) {
      Resources res = avatarIV.getContext().getResources();
      InputStream is = res.openRawResource(R.drawable.default_avatar);
      InputStream is2 = res.openRawResource(R.drawable.default_avatar);
      this.defaultAvatar = ImageUtil.loadAvatarFromStream(is, is2);
    }

    Object tagObj = avatarIV.getTag();
    if (tagObj instanceof AvatarTag) {
      AvatarTag origTag = (AvatarTag) tagObj;
      if (origTag.isDefault == false) {
        ImageUtil.recycleImageView(avatarIV);
        // Log.d(TAG, "recycle avatar:" + origTag.lou);
      } else {
        // Log.d(TAG, "default avatar, skip recycle");
      }
    }

    AvatarTag tag = new AvatarTag(lou, true);
    avatarIV.setImageBitmap(defaultAvatar);
    avatarIV.setTag(tag);
    if (!StringUtil.isEmpty(avatarUrl)) {
      final String avatarPath = ImageUtil.newImage(avatarUrl, userId);
      if (avatarPath != null) {
        File f = new File(avatarPath);
        if (f.exists() && !isPending(avatarUrl)) {

          Bitmap bitmap = ImageUtil.loadAvatarFromSdcard(avatarPath);
          if (bitmap != null) {
            avatarIV.setImageBitmap(bitmap);
            tag.isDefault = false;
          } else f.delete();
          long date = f.lastModified();
          if ((System.currentTimeMillis() - date) / 1000 > 30 * 24 * 3600) {
            f.delete();
          }

        } else {
          final boolean downImg =
              isInWifi() || PhoneConfiguration.getInstance().isDownAvatarNoWifi();

          new AvatarLoadTask(avatarIV, null, downImg, lou, this)
              .execute(avatarUrl, avatarPath, userId);
        }
      }
    }
  }