예제 #1
0
  @Override
  protected void prepare(Activity context, LinearLayout items) {

    final RedditPost post = getArguments().getParcelable("post");

    items.addView(
        propView(
            context,
            R.string.props_title,
            StringEscapeUtils.unescapeHtml4(post.title.trim()),
            true));
    items.addView(propView(context, R.string.props_author, post.author, false));
    items.addView(
        propView(context, R.string.props_url, StringEscapeUtils.unescapeHtml4(post.url), false));
    items.addView(
        propView(
            context,
            R.string.props_created,
            RRTime.formatDateTime(post.created_utc * 1000, context),
            false));

    if (post.edited instanceof Long) {
      items.addView(
          propView(
              context,
              R.string.props_edited,
              RRTime.formatDateTime((Long) post.edited * 1000, context),
              false));
    } else {
      items.addView(propView(context, R.string.props_edited, R.string.props_never, false));
    }

    items.addView(propView(context, R.string.props_subreddit, post.subreddit, false));
    items.addView(
        propView(
            context,
            R.string.props_score,
            String.format(
                "%d (%d %s, %d %s)",
                post.score,
                post.ups,
                context.getString(R.string.props_up),
                post.downs,
                context.getString(R.string.props_down)),
            false));
    items.addView(
        propView(context, R.string.props_num_comments, String.valueOf(post.num_comments), false));

    if (post.selftext != null && post.selftext.length() > 0) {
      items.addView(
          propView(
              context,
              R.string.props_self_markdown,
              StringEscapeUtils.unescapeHtml4(post.selftext),
              false));
    }
  }