Exemple #1
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);
    }
  }
Exemple #2
0
  /** Helper method to set the contents and visibility of each field */
  public synchronized void bindView(View view, NoteOrUpdate item) {
    // picture
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      pictureView.setDefaultImageDrawable(
          ResourceDrawableCache.getImageDrawableFromId(
              resources, R.drawable.icn_default_person_image));
      pictureView.setUrl(item.picture);
    }

    // name
    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(item.title);
      if (NameMaps.TABLE_ID_HISTORY.equals(item.type)) nameView.setTextColor(grayColor);
      else nameView.setTextColor(color);
      Linkify.addLinks(nameView, Linkify.ALL);
    }

    // date
    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              item.createdAt,
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }

    // picture
    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    {
      UpdateAdapter.setupImagePopupForCommentView(
          view,
          commentPictureView,
          item.pictureThumb,
          item.pictureFull,
          item.commentBitmap,
          item.title.toString(),
          fragment,
          imageCache);
    }
  }
  /** Helper method to set the contents and visibility of each field */
  @SuppressWarnings("nls")
  public synchronized void setFieldContentsAndVisibility(View view, Update update) {
    JSONObject user = ActFmPreferenceService.userFromModel(update);

    // picture
    final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture);
    {
      String pictureUrl = user.optString("picture");
      pictureView.setUrl(pictureUrl);
    }

    final AsyncImageView commentPictureView =
        (AsyncImageView) view.findViewById(R.id.comment_picture);
    {
      final String updatePicture = update.getValue(Update.PICTURE);
      setupImagePopupForCommentView(
          view,
          commentPictureView,
          updatePicture,
          update.getValue(Update.MESSAGE),
          fragment,
          imageCache);
    }

    // name
    final TextView nameView = (TextView) view.findViewById(R.id.title);
    {
      nameView.setText(getUpdateComment(update, user, linkColor, fromView));
    }

    // date
    final TextView date = (TextView) view.findViewById(R.id.date);
    {
      CharSequence dateString =
          DateUtils.getRelativeTimeSpanString(
              update.getValue(Update.CREATION_DATE),
              DateUtilities.now(),
              DateUtils.MINUTE_IN_MILLIS,
              DateUtils.FORMAT_ABBREV_RELATIVE);
      date.setText(dateString);
    }
  }