Ejemplo n.º 1
0
        public static IEnumerable <ConversationMessage> GetConvoFromCursor(ContentResolver cr, ICursor c)
        {
            int depth        = c.Count;
            var listMessages = new List <ConversationMessage>();

            if (c.MoveToFirst())
            {
                do
                {
                    string messageType = c.GetString(c.GetColumnIndex("ct_t"));

                    if (messageType != null && messageType.Contains("application/vnd.wap.multipart"))
                    {
                        string messageId = c.GetString(c.GetColumnIndex("_id"));
                        listMessages.Add(MultimediaHelper.GetMessageById(cr, c, messageId));
                    }
                    else
                    {
                        string strDate = c.GetString(c.GetColumnIndex("date"));

                        listMessages.Add(new ConversationMessage(
                                             c.GetString(c.GetColumnIndex("thread_id")),
                                             c.GetString(c.GetColumnIndex("_id")),
                                             c.GetString(c.GetColumnIndex("body")),     //message
                                             DateTimeHelper.GetDateFromString(strDate), //date
                                             c.GetString(c.GetColumnIndex("type"))));   //whether the message is inbound or outbound
                    }
                }while (c.MoveToNext());
            }

            var orderedList = listMessages.OrderBy(x => x.Timestamp);

            return(orderedList);
        }
Ejemplo n.º 2
0
        public static IEnumerable <ConversationListItem> getFullConvoListFromCursor(Context context, ContentResolver cr, ICursor c)
        {
            int depth      = c.Count;
            var listConvos = new List <ConversationListItem>();

            try
            {
                if (c.MoveToFirst())
                {
                    do
                    {
                        string  rawPhone    = c.GetString(c.GetColumnIndex("address"));
                        Contact contact     = GetContactFromAddress(cr, rawPhone);
                        string  strDate     = c.GetString(c.GetColumnIndex("date"));
                        string  id          = c.GetString(c.GetColumnIndex("_id"));
                        string  messageType = c.GetString(c.GetColumnIndex("ct_t"));

                        if (messageType != null && messageType.Contains("application/vnd.wap.multipart"))
                        {
                            listConvos.Add(MultimediaHelper.GetConversationListItemById(context, cr, id));
                        }
                        else
                        {
                            listConvos.Add(new ConversationListItem(contact,
                                                                    long.Parse(strDate),                       //date as long
                                                                    DateTimeHelper.GetDateFromString(strDate), //date
                                                                    c.GetString(c.GetColumnIndex("body")),
                                                                    c.GetString(c.GetColumnIndex("thread_id")),
                                                                    c.GetString(c.GetColumnIndex("read")),
                                                                    true));
                        }
                    }while (c.MoveToNext());
                }
            }
            catch (System.Exception ex)
            {
                string DEBUG_TAG = "ConversationHelper";
                Log.Error(DEBUG_TAG, ex.Message);
            }

            // Descending?
            var orderedList = listConvos.OrderBy(x => x.LastTextSentOn);

            return(orderedList);
        }