MessageListAdapterpublic class MessageListAdapter extends android.widget.CursorAdapter The back-end data adapter of a message list. |
Fields Summary |
---|
private static final String | TAG | private static final boolean | DEBUG | private static final boolean | LOCAL_LOGV | static final String[] | PROJECTION | static final int | COLUMN_MSG_TYPE | static final int | COLUMN_ID | static final int | COLUMN_THREAD_ID | static final int | COLUMN_SMS_ADDRESS | static final int | COLUMN_SMS_BODY | static final int | COLUMN_SMS_DATE | static final int | COLUMN_SMS_READ | static final int | COLUMN_SMS_TYPE | static final int | COLUMN_SMS_STATUS | static final int | COLUMN_MMS_SUBJECT | static final int | COLUMN_MMS_SUBJECT_CHARSET | static final int | COLUMN_MMS_DATE | static final int | COLUMN_MMS_READ | static final int | COLUMN_MMS_MESSAGE_TYPE | static final int | COLUMN_MMS_MESSAGE_BOX | static final int | COLUMN_MMS_DELIVERY_REPORT | static final int | COLUMN_MMS_READ_REPORT | static final int | COLUMN_MMS_ERROR_TYPE | private static final int | CACHE_SIZE | protected android.view.LayoutInflater | mInflater | private final android.widget.ListView | mListView | private final LinkedHashMap | mMessageItemCache | private final ColumnsMap | mColumnsMap | private OnDataSetChangedListener | mOnDataSetChangedListener | private final int | mThreadType | private android.os.Handler | mMsgListItemHandler |
Constructors Summary |
---|
public MessageListAdapter(android.content.Context context, android.database.Cursor c, android.widget.ListView listView, boolean useDefaultColumnsMap, int threadType)
super(context, c);
mThreadType = threadType;
mInflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
mListView = listView;
mMessageItemCache = new LinkedHashMap<Long, MessageItem>(
10, 1.0f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry eldest) {
return size() > CACHE_SIZE;
}
};
if (useDefaultColumnsMap) {
mColumnsMap = new ColumnsMap();
} else {
mColumnsMap = new ColumnsMap(c);
}
|
Methods Summary |
---|
public void | bindView(android.view.View view, android.content.Context context, android.database.Cursor cursor)
if (view instanceof MessageListItem) {
String type = cursor.getString(mColumnsMap.mColumnMsgType);
long msgId = cursor.getLong(mColumnsMap.mColumnMsgId);
MessageItem msgItem = getCachedMessageItem(type, msgId, cursor);
if (msgItem != null) {
((MessageListItem) view).bind(msgItem);
((MessageListItem) view).setMsgListItemHandler(mMsgListItemHandler);
}
}
| public MessageItem | getCachedMessageItem(java.lang.String type, long msgId, android.database.Cursor c)
MessageItem item = mMessageItemCache.get(getKey(type, msgId));
if (item == null) {
try {
item = new MessageItem(mContext, type, c, mColumnsMap, mThreadType);
mMessageItemCache.put(getKey(item.mType, item.mMsgId), item);
} catch (MmsException e) {
Log.e(TAG, e.getMessage());
}
}
return item;
| private static long | getKey(java.lang.String type, long id)
if (type.equals("mms")) {
return -id;
} else {
return id;
}
| public android.view.View | newView(android.content.Context context, android.database.Cursor cursor, android.view.ViewGroup parent)
return mInflater.inflate(R.layout.message_list_item, parent, false);
| public void | notifyDataSetChanged()
super.notifyDataSetChanged();
if (LOCAL_LOGV) {
Log.v(TAG, "MessageListAdapter.notifyDataSetChanged().");
}
mListView.setSelection(mListView.getCount());
mMessageItemCache.clear();
if (mOnDataSetChangedListener != null) {
mOnDataSetChangedListener.onDataSetChanged(this);
}
| public void | setMsgListItemHandler(android.os.Handler handler)
mMsgListItemHandler = handler;
| public void | setOnDataSetChangedListener(com.android.mms.ui.MessageListAdapter$OnDataSetChangedListener l)
mOnDataSetChangedListener = l;
|
|