@Override public int getItemViewType(int position) { // This method shouldn't be called if our cursor is null, since the framework should know // that there aren't any items to look at in that case MessageItem item = getItem(position); int boxId = item.getBoxId(); if (item.isSms()) { if (boxId == TextBasedSmsColumns.MESSAGE_TYPE_INBOX || boxId == TextBasedSmsColumns.MESSAGE_TYPE_ALL) { return INCOMING_ITEM; } else { return OUTGOING_ITEM; } } else { if (boxId == Telephony.Mms.MESSAGE_BOX_ALL || boxId == Telephony.Mms.MESSAGE_BOX_INBOX) { return INCOMING_ITEM; } else { return OUTGOING_ITEM; } } }
private int getItemViewType(Cursor cursor) { String type = cursor.getString(mColumnsMap.mColumnMsgType); int boxId; if ("sms".equals(type)) { boxId = cursor.getInt(mColumnsMap.mColumnSmsType); // Note that messages from the SIM card all have a boxId of zero. return (boxId == TextBasedSmsColumns.MESSAGE_TYPE_INBOX || boxId == TextBasedSmsColumns.MESSAGE_TYPE_ALL) ? INCOMING_ITEM_TYPE_SMS : OUTGOING_ITEM_TYPE_SMS; } else { boxId = cursor.getInt(mColumnsMap.mColumnMmsMessageBox); // Note that messages from the SIM card all have a boxId of zero: Mms.MESSAGE_BOX_ALL return (boxId == Mms.MESSAGE_BOX_INBOX || boxId == Mms.MESSAGE_BOX_ALL) ? INCOMING_ITEM_TYPE_MMS : OUTGOING_ITEM_TYPE_MMS; } }
private int getItemViewType(Cursor cursor) { String type = cursor.getString(mColumnsMap.mColumnMsgType); int boxId; if ("sms".equals(type)) { boxId = cursor.getInt(mColumnsMap.mColumnSmsType); // Note that messages from the SIM card all have a boxId of zero. return (boxId == TextBasedSmsColumns.MESSAGE_TYPE_INBOX || boxId == TextBasedSmsColumns.MESSAGE_TYPE_ALL) ? INCOMING_ITEM_TYPE_SMS : OUTGOING_ITEM_TYPE_SMS; } else { boxId = cursor.getInt(mColumnsMap.mColumnMmsMessageBox); // Note that messages from the SIM card all have a boxId of zero: // Mms.MESSAGE_BOX_ALL return (boxId == Mms.MESSAGE_BOX_INBOX || boxId == Mms.MESSAGE_BOX_ALL) ? INCOMING_ITEM_TYPE_MMS : OUTGOING_ITEM_TYPE_MMS; } }