WorkingMessage
WorkingMessage类包含所有当前用户正在编辑的信息的状态。
重要的成员变量:
private int mMmsState; // Mms状态,指示这个消息要通过mms发送,是以下flag相与的结果
// States that can require us to save or send a message as MMS.
private static final int RECIPIENTS_REQUIRE_MMS = (1 << 0); // 1
private static final int HAS_SUBJECT = (1 << 1); // 2
private static final int HAS_ATTACHMENT = (1 << 2); // 4
private static final int LENGTH_REQUIRES_MMS = (1 << 3); // 8
private static final int FORCE_MMS = (1 << 4); // 16
private static final int MULTIPLE_RECIPIENTS = (1 << 5); // 32
private int mAttachmentType; // 附件类型,包含以下几种
// Attachment types
public static final int TEXT = 0;
public static final int IMAGE = 1;
public static final int VIDEO = 2;
public static final int AUDIO = 3;
public static final int SLIDESHOW = 4;
// Conversation this message is targeting.
private Conversation mConversation;
方法:
1. public static WorkingMessage createEmpty(ComposeMessageActivity) // Creates a new working message.
2. public static WorkingMessage load(ComposeMessageActivity, Uri) // 从一个指定的URI加载WorkingMessage对象,如果msg不在DRAFT,移动到草稿箱中。
3. private void correctAttachmentState() // 纠正附件的状态,指定mAttachmentType的值,IMAGE、VIDEO、AUDIO、SLIDESHOW
4. public static WorkingMessage loadDraft(ComposeMessageActivity, final Conversation, final Runnable) // Load the draft message for the specified conversation, or a new empty message if none exists.
5. public void setText(CharSequence) / public CharSequence getText() //
6. public boolean hasText() // True if the message has any text.
7. public void removeAttachment(boolean) // 删除附件
8. public static void removeThumbnailsFromCache(SlideshowModel) // 删除VIDEO/IMAGE的缩略图,利用ThumbnailManager对象
9. public int setAttachment(int, Uri, boolean) // Adds an attachment to the message, replacing an old one if it existed.
10. public boolean isWorthSaving() // Returns true if this message contains anything worth saving.
11. private int changeMedia(int, Uri, SlideshowEditor) // Change the message's attachment to the data in the specified Uri.If the attachment fails to attach, restore the slide to its original state.
12. private int appendMedia(int, Uri, SlideshowEditor) // Add the message's attachment to the data in the specified Uri to a new slide.
13. public boolean hasAttachment() // Returns true if the message has an attachment (including slideshows).
14. public SlideshowModel getSlideshow() / public boolean hasSlideshow()
15. public void setSubject(CharSequence, boolean) / public CharSequence getSubject() / public boolean hasSubject()
16. public void syncWorkingRecipients() // 解析联系人列表成一个ContactList对象
17. public String getWorkingRecipients() // 以String的形式返回一个联系人列表
18. public Uri saveAsMms(boolean) // Force the message to be saved as MMS and return the Uri of the message.
19. public void setWorkingRecipients(List<String>) // Update the temporary list of recipients, used when setting up a new conversation.
20. public void setConversation(Conversation) // Set the conversation associated with this message.
21. public void send(String) // Send this message over the network. This WorkingMessage object is no longer useful after this method has been called.
if (requiresMms()) sendMmsWorker(conv, mmsUri, persister, slideshow, sendReq, textOnly);
else preSendSmsWorker(conv, msgText, recipientsInUI);