コード例 #1
0
  @Override
  public void bindView(final View view, final Context context, final Cursor cursor) {
    final DraftViewHolder holder = (DraftViewHolder) view.getTag();
    final long[] accountIds =
        TwidereArrayUtils.parseLongArray(cursor.getString(mIndices.account_ids), ',');
    final String text = cursor.getString(mIndices.text);
    final ParcelableMediaUpdate[] mediaUpdates =
        ParcelableMediaUpdate.fromJSONString(cursor.getString(mIndices.media));
    final long timestamp = cursor.getLong(mIndices.timestamp);
    final int actionType = cursor.getInt(mIndices.action_type);
    final String actionName = getActionName(context, actionType);
    holder.media_preview_container.setStyle(mMediaPreviewStyle);
    if (actionType == Drafts.ACTION_UPDATE_STATUS) {
      final ParcelableMedia[] media = ParcelableMedia.fromMediaUpdates(mediaUpdates);
      holder.media_preview_container.setVisibility(View.VISIBLE);
      holder.media_preview_container.displayMedia(
          media, mImageLoader, -1L, null, mMediaLoadingHandler);
    } else {
      holder.media_preview_container.setVisibility(View.GONE);
    }
    holder.content.drawEnd(getAccountColors(context, accountIds));
    holder.setTextSize(mTextSize);
    final boolean emptyContent = TextUtils.isEmpty(text);
    if (emptyContent) {
      holder.text.setText(R.string.empty_content);
    } else {
      holder.text.setText(text);
    }
    holder.text.setTypeface(
        holder.text.getTypeface(), emptyContent ? Typeface.ITALIC : Typeface.NORMAL);

    if (timestamp > 0) {
      final String timeString = Utils.formatSameDayTime(context, timestamp);
      holder.time.setText(
          context.getString(R.string.action_name_saved_at_time, actionName, timeString));
    } else {
      holder.time.setText(actionName);
    }
  }