Beispiel #1
1
  private void setupHistoryRow(View view, History history, User user) {
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      if (user.containsNonNullValue(USER_PICTURE)) {
        String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB);
        pictureView.setUrl(pictureUrl);
      } else {
        pictureView.setUrl(null);
      }
      pictureView.setVisibility(View.VISIBLE);
    }

    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    commentPictureView.setVisibility(View.GONE);

    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(
          getHistoryComment(
              (AstridActivity) fragment.getActivity(), history, user, linkColor, fromView));
      nameView.setTextColor(grayColor);
    }

    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              history.getValue(History.CREATED_AT),
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }
  }
Beispiel #2
0
  private void setupUserActivityRow(View view, UserActivity activity, User user) {
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      if (user.containsNonNullValue(USER_PICTURE)) {
        String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB);
        pictureView.setUrl(pictureUrl);
      } else {
        pictureView.setUrl(null);
      }
      pictureView.setVisibility(View.VISIBLE);
    }

    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    {
      String pictureThumb =
          activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
      String pictureFull = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE);
      Bitmap updateBitmap = null;
      if (TextUtils.isEmpty(pictureThumb))
        updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE);
      setupImagePopupForCommentView(
          view,
          commentPictureView,
          pictureThumb,
          pictureFull,
          updateBitmap,
          activity.getValue(UserActivity.MESSAGE),
          fragment,
          imageCache);
    }

    // name
    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(
          getUpdateComment(
              (AstridActivity) fragment.getActivity(), activity, user, linkColor, fromView));
      nameView.setMovementMethod(new LinkMovementMethod());
      nameView.setTextColor(color);
    }

    // date
    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              activity.getValue(UserActivity.CREATED_AT),
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }
  }
Beispiel #3
0
    public static NoteOrUpdate fromUpdateOrHistory(
        AstridActivity context, UserActivity u, History history, User user, String linkColor) {
      String userImage = ""; // $NON-NLS-1$
      String pictureThumb = ""; // $NON-NLS-1$
      String pictureFull = ""; // $NON-NLS-1$
      Spanned title;
      Bitmap commentBitmap = null;
      long createdAt = 0;
      String type = null;

      if (u != null) {
        pictureThumb = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM);
        pictureFull = u.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE);
        if (TextUtils.isEmpty(pictureThumb))
          commentBitmap = u.getPictureBitmap(UserActivity.PICTURE);
        title =
            UpdateAdapter.getUpdateComment(
                context, u, user, linkColor, UpdateAdapter.FROM_TASK_VIEW);
        userImage = ""; // $NON-NLS-1$
        if (user.containsNonNullValue(UpdateAdapter.USER_PICTURE))
          userImage = user.getPictureUrl(UpdateAdapter.USER_PICTURE, RemoteModel.PICTURE_THUMB);
        createdAt = u.getValue(UserActivity.CREATED_AT);
        type = NameMaps.TABLE_ID_USER_ACTIVITY;
      } else {
        if (user.containsNonNullValue(UpdateAdapter.USER_PICTURE))
          userImage = user.getPictureUrl(UpdateAdapter.USER_PICTURE, RemoteModel.PICTURE_THUMB);
        title =
            new SpannableString(
                UpdateAdapter.getHistoryComment(
                    context, history, user, linkColor, UpdateAdapter.FROM_TASK_VIEW));
        createdAt = history.getValue(History.CREATED_AT);
        type = NameMaps.TABLE_ID_HISTORY;
      }

      return new NoteOrUpdate(
          userImage, title, pictureThumb, pictureFull, commentBitmap, createdAt, type);
    }