在我们每次删除会话时,会清空所有缓存。
public static void startDelete(ConversationQueryHandler handler, int token, boolean deleteAll,
long threadId) {
synchronized(sDeletingThreadsLock) {
if (sDeletingThreads) {
Log.e(TAG, "startDeleteAll already in the middle of a delete", new Exception());
}
sDeletingThreads = true;
Uri uri = ContentUris.withAppendedId(Threads.CONTENT_URI, threadId);
String selection = deleteAll ? null : "locked=0";
MmsApp.getApplication().getPduLoaderManager().clear();//这里会将缓存的信息全部清空,下次进入短彩信,重新更新缓存。
// HACK: the keys to the thumbnail cache are the part uris, such as mms/part/3
// Because the part table doesn't have auto-increment ids, the part ids are reused
// when a message or thread is deleted. For now, we're clearing the whole thumbnail
// cache so we don't retrieve stale images when part ids are reused. This will be
// fixed in the next release in the mms provider.
MmsApp.getApplication().getThumbnailManager().clear();
handler.setDeleteToken(token);
handler.startDelete(token, new Long(threadId), uri, selection, null);
}
}
当删除单条信息时,会先清空这条信息对应的缓存,然后在删除。这个顺序很重要,如果先删除信息,在清空缓存信息,那么短彩信可能会引发同步错误。
private class DeleteMessageListener implements OnClickListener {
private final MessageItem mMessageItem;
public DeleteMessageListener(MessageItem messageItem) {
mMessageItem = messageItem;
}
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
new AsyncTask<Void, Void, Void>() {
protected Void doInBackground(Void... none) {
if (mMessageItem.isMms()) {
WorkingMessage.removeThumbnailsFromCache(mMessageItem.getSlideshow());
MmsApp.getApplication().getPduLoaderManager()
.removePdu(mMessageItem.mMessageUri);
// Delete the message *after* we've removed the thumbnails because we
// need the pdu and slideshow for removeThumbnailsFromCache to work.
}
mBackgroundQueryHandler.startDelete(DELETE_MESSAGE_TOKEN,
null, mMessageItem.mMessageUri,
mMessageItem.mLocked ? null : "locked=0", null);
return null;
}
}.execute();
}
}
以上就是幻灯片异步加载的一个大体流程。
相关阅读:Android短彩信附件机制 http://www.linuxidc.com/Linux/2013-03/81529.htm
更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11
