public ThreadRecord getCurrent() {
      long threadId = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.ID));
      String recipientId =
          cursor.getString(cursor.getColumnIndexOrThrow(ThreadDatabase.RECIPIENT_IDS));
      Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientId, true);

      DisplayRecord.Body body = getPlaintextBody(cursor);
      long date = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.DATE));
      long count = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.MESSAGE_COUNT));
      long read = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.READ));
      long type = cursor.getLong(cursor.getColumnIndexOrThrow(ThreadDatabase.SNIPPET_TYPE));
      int distributionType = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.TYPE));
      boolean archived = cursor.getInt(cursor.getColumnIndex(ThreadDatabase.ARCHIVED)) != 0;
      int status = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.STATUS));
      int receiptCount = cursor.getInt(cursor.getColumnIndexOrThrow(ThreadDatabase.RECEIPT_COUNT));
      Uri snippetUri = getSnippetUri(cursor);

      return new ThreadRecord(
          context,
          body,
          snippetUri,
          recipients,
          date,
          count,
          read == 1,
          threadId,
          receiptCount,
          status,
          type,
          distributionType,
          archived);
    }
  public @Nullable Recipients getRecipientsForThreadId(long threadId) {
    SQLiteDatabase db = databaseHelper.getReadableDatabase();
    Cursor cursor = null;

    try {
      cursor =
          db.query(TABLE_NAME, null, ID + " = ?", new String[] {threadId + ""}, null, null, null);

      if (cursor != null && cursor.moveToFirst()) {
        String recipientIds = cursor.getString(cursor.getColumnIndexOrThrow(RECIPIENT_IDS));
        return RecipientFactory.getRecipientsForIds(context, recipientIds, false);
      }
    } finally {
      if (cursor != null) cursor.close();
    }

    return null;
  }
  private void initializeResources() {
    recipients =
        RecipientFactory.getRecipientsForIds(
            this, getIntent().getStringExtra(RECIPIENTS_EXTRA), true);
    threadId = getIntent().getLongExtra(THREAD_ID_EXTRA, -1);
    distributionType =
        getIntent().getIntExtra(DISTRIBUTION_TYPE_EXTRA, ThreadDatabase.DistributionTypes.DEFAULT);
    sendButton = (ImageButton) findViewById(R.id.send_button);
    composeText = (EditText) findViewById(R.id.embedded_text_editor);
    masterSecret = getIntent().getParcelableExtra(MASTER_SECRET_EXTRA);
    charactersLeft = (TextView) findViewById(R.id.space_left);
    emojiDrawer = (EmojiDrawer) findViewById(R.id.emoji_drawer);
    emojiToggle = (EmojiToggle) findViewById(R.id.emoji_toggle);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      emojiToggle.setVisibility(View.GONE);
    }

    attachmentAdapter = new AttachmentTypeSelectorAdapter(this);
    attachmentManager = new AttachmentManager(this, this);

    SendButtonListener sendButtonListener = new SendButtonListener();
    ComposeKeyPressedListener composeKeyPressedListener = new ComposeKeyPressedListener();

    sendButton.setOnClickListener(sendButtonListener);
    sendButton.setEnabled(true);
    composeText.setOnKeyListener(composeKeyPressedListener);
    composeText.addTextChangedListener(composeKeyPressedListener);
    composeText.setOnEditorActionListener(sendButtonListener);
    composeText.setOnClickListener(composeKeyPressedListener);
    emojiDrawer.setComposeEditText(composeText);
    emojiToggle.setOnClickListener(new EmojiToggleListener());

    recipients.addListener(
        new RecipientModifiedListener() {
          @Override
          public void onModified(Recipient recipient) {
            initializeTitleBar();
          }
        });

    registerForContextMenu(sendButton);
  }