Пример #1
0
 public void findRepliesRecursively(ConversationOneMessage oMsg) {
   MyLog.v(this, "findReplies for id=" + oMsg.msgId);
   List<Long> replies = MyProvider.getReplyIds(oMsg.msgId);
   oMsg.nReplies = replies.size();
   for (long replyId : replies) {
     ConversationOneMessage oMsgReply = new ConversationOneMessage(replyId, oMsg.replyLevel + 1);
     findPreviousMessagesRecursively(oMsgReply);
   }
 }
Пример #2
0
 private void loadMessageFromDatabase(ConversationOneMessage oMsg) {
   Uri uri = MyProvider.getTimelineMsgUri(ma.getUserId(), TimelineTypeEnum.ALL, true, oMsg.msgId);
   Cursor cursor = null;
   try {
     cursor = context.getContentResolver().query(uri, PROJECTION, null, null, null);
     if (cursor != null && cursor.moveToFirst()) {
       loadMessageFromCursor(oMsg, cursor);
     }
   } finally {
     DbUtils.closeSilently(cursor);
   }
 }
Пример #3
0
 @Override
 public String messagePermalink(String userName, long messageId) {
   return MyProvider.msgIdToStringColumnValue(Msg.URL, messageId);
 }
Пример #4
0
  private void loadMessageFromCursor(ConversationOneMessage oMsg, Cursor cursor) {
    /**
     * IDs of all known senders of this message except for the Author These "senders" reblogged the
     * message
     */
    Set<Long> rebloggers = new HashSet<Long>();
    int ind = 0;
    do {
      long senderId = cursor.getLong(cursor.getColumnIndex(Msg.SENDER_ID));
      long authorId = cursor.getLong(cursor.getColumnIndex(Msg.AUTHOR_ID));
      long linkedUserId = cursor.getLong(cursor.getColumnIndex(User.LINKED_USER_ID));

      if (ind == 0) {
        // This is the same for all retrieved rows
        oMsg.inReplyToMsgId = cursor.getLong(cursor.getColumnIndex(Msg.IN_REPLY_TO_MSG_ID));
        oMsg.createdDate = cursor.getLong(cursor.getColumnIndex(Msg.CREATED_DATE));
        oMsg.author = cursor.getString(cursor.getColumnIndex(User.AUTHOR_NAME));
        oMsg.body = cursor.getString(cursor.getColumnIndex(Msg.BODY));
        String via = cursor.getString(cursor.getColumnIndex(Msg.VIA));
        if (!TextUtils.isEmpty(via)) {
          oMsg.via = Html.fromHtml(via).toString().trim();
        }
        if (MyPreferences.showAvatars()) {
          oMsg.avatarDrawable =
              new AvatarDrawable(
                  authorId, cursor.getString(cursor.getColumnIndex(Avatar.FILE_NAME)));
        }
        int colIndex = cursor.getColumnIndex(User.IN_REPLY_TO_NAME);
        if (colIndex > -1) {
          oMsg.inReplyToName = cursor.getString(colIndex);
          if (TextUtils.isEmpty(oMsg.inReplyToName)) {
            oMsg.inReplyToName = "";
          }
        }
        colIndex = cursor.getColumnIndex(User.RECIPIENT_NAME);
        if (colIndex > -1) {
          oMsg.recipientName = cursor.getString(colIndex);
          if (TextUtils.isEmpty(oMsg.recipientName)) {
            oMsg.recipientName = "";
          }
        }
      }

      if (senderId != authorId) {
        rebloggers.add(senderId);
      }
      if (linkedUserId != 0) {
        if (oMsg.linkedUserId == 0) {
          oMsg.linkedUserId = linkedUserId;
        }
        if (cursor.getInt(cursor.getColumnIndex(MsgOfUser.REBLOGGED)) == 1
            && linkedUserId != authorId) {
          rebloggers.add(linkedUserId);
        }
        if (cursor.getInt(cursor.getColumnIndex(MsgOfUser.FAVORITED)) == 1) {
          oMsg.favorited = true;
        }
      }

      ind++;
    } while (cursor.moveToNext());

    for (long rebloggerId : rebloggers) {
      if (!TextUtils.isEmpty(oMsg.rebloggersString)) {
        oMsg.rebloggersString += ", ";
      }
      oMsg.rebloggersString += MyProvider.userIdToName(rebloggerId);
    }
  }