你好,游客 登录 注册 搜索
背景:
阅读新闻

Android短彩信幻灯片异步加载机制

[日期:2013-03-24] 来源:Linux社区  作者:hailushijie [字体:大 中 小]

在MessageItem中会对cursor中的数据进行加载。

MessgeItem.java

MessageItem(Context context, String type, final Cursor cursor,
final ColumnsMap columnsMap, Pattern highlight, boolean fullTimestamp, boolean sentTimestamp) throws MmsException {
mContext = context;
mMsgId = cursor.getLong(columnsMap.mColumnMsgId);
mHighlight = highlight;
mType = type;
mCursor = cursor;
mColumnsMap = columnsMap;
mFullTimestamp = fullTimestamp;
mSentTimestamp = sentTimestamp;

if ("sms".equals(type)) {
mReadReport = false; // No read reports in sms

long status = cursor.getLong(columnsMap.mColumnSmsStatus);
if (status == Sms.STATUS_NONE) {
// No delivery report requested
mDeliveryStatus = DeliveryStatus.NONE;
} else if (status >= Sms.STATUS_FAILED) {
// Failure
mDeliveryStatus = DeliveryStatus.FAILED;
} else if (status >= Sms.STATUS_PENDING) {
// Pending
mDeliveryStatus = DeliveryStatus.PENDING;
} else {
// Success
mDeliveryStatus = DeliveryStatus.RECEIVED;
}

mMessageUri = ContentUris.withAppendedId(Sms.CONTENT_URI, mMsgId);
// Set contact and message body
mBoxId = cursor.getInt(columnsMap.mColumnSmsType);
mAddress = cursor.getString(columnsMap.mColumnSmsAddress);
if (Sms.isOutgoingFolder(mBoxId)) {
String meString = context.getString(
R.string.messagelist_sender_self);

mContact = meString;
} else {
// For incoming messages, the ADDRESS field contains the sender.
mContact = Contact.get(mAddress, false).getName();
}
mBody = cursor.getString(columnsMap.mColumnSmsBody);

// Unless the message is currently in the progress of being sent, it gets a time stamp.
if (!isOutgoingMessage()) {
// Set "received" or "sent" time stamp
long date = cursor.getLong(columnsMap.mColumnSmsDate);
if (mSentTimestamp && (mBoxId == Sms.MESSAGE_TYPE_INBOX)) {
date = cursor.getLong(columnsMap.mColumnSmsDateSent);
}
mTimestamp = MessageUtils.formatTimeStampString(context, date, mFullTimestamp);
}

mLocked = cursor.getInt(columnsMap.mColumnSmsLocked) != 0;
mErrorCode = cursor.getInt(columnsMap.mColumnSmsErrorCode);
} else if ("mms".equals(type)) {
mMessageUri = ContentUris.withAppendedId(Mms.CONTENT_URI, mMsgId);
mBoxId = cursor.getInt(columnsMap.mColumnMmsMessageBox);
mMessageType = cursor.getInt(columnsMap.mColumnMmsMessageType);
mErrorType = cursor.getInt(columnsMap.mColumnMmsErrorType);
String subject = cursor.getString(columnsMap.mColumnMmsSubject);
if (!TextUtils.isEmpty(subject)) {
EncodedStringValue v = new EncodedStringValue(
cursor.getInt(columnsMap.mColumnMmsSubjectCharset),
PduPersister.getBytes(subject));
mSubject = v.getString();
}
mLocked = cursor.getInt(columnsMap.mColumnMmsLocked) != 0;
mSlideshow = null;
mAttachmentType = ATTACHMENT_TYPE_NOT_LOADED;
mDeliveryStatus = DeliveryStatus.NONE;
mReadReport = false;
mBody = null;
mMessageSize = 0;
mTextContentType = null;
mTimestamp = null;
mMmsStatus = cursor.getInt(columnsMap.mColumnMmsStatus);

// Start an async load of the pdu. If the pdu is already loaded, the callback
// will get called immediately
boolean loadSlideshow = mMessageType != PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND;

<strong>mItemLoadedFuture = MmsApp.getApplication().getPduLoaderManager()//异步加载幻灯片的逻辑
.getPdu(mMessageUri, loadSlideshow,
new PduLoadedMessageItemCallback());</strong>

} else {
throw new MmsException("Unknown type of the message: " + type);
}
}

linux
相关资讯       Android幻灯片  Android异步加载 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款