Ejemplo n.º 1
0
  public void set(
      ThreadRecord thread, Locale locale, Set<Long> selectedThreads, boolean batchMode) {
    this.selectedThreads = selectedThreads;
    this.recipients = thread.getRecipients();
    this.threadId = thread.getThreadId();
    this.read = thread.isRead();
    this.distributionType = thread.getDistributionType();

    this.recipients.addListener(this);
    this.fromView.setText(recipients, read);

    this.subjectView.setText(thread.getDisplayBody());
    this.subjectView.setTypeface(read ? LIGHT_TYPEFACE : BOLD_TYPEFACE);

    if (thread.getDate() > 0) {
      CharSequence date =
          DateUtils.getBriefRelativeTimeSpanString(getContext(), locale, thread.getDate());
      dateView.setText(
          read ? date : color(getResources().getColor(R.color.smssecure_primary), date));
      dateView.setTypeface(read ? LIGHT_TYPEFACE : BOLD_TYPEFACE);
    }

    setBatchState(batchMode);
    setBackground(thread);
    setRippleColor(recipients);
    this.contactPhotoImage.setAvatar(recipients, true);
  }
  @Override
  public long getItemId(@NonNull Cursor cursor) {
    ThreadRecord record = getThreadRecord(cursor);
    StringBuilder builder = new StringBuilder("" + record.getThreadId());

    for (long recipientId : record.getRecipients().getIds()) {
      builder.append("::").append(recipientId);
    }

    return Conversions.byteArrayToLong(digest.digest(builder.toString().getBytes()));
  }