Intent list, object, set transfer data association parcelable and comparable class

Source: Internet
Author: User
Tags comparable

Public class immessage implements parcelable, comparable <immessage> {public static final string immessage_key = "immessage. key "; public static final string key_time =" immessage. time "; public static final int success = 0; public static final int error = 1; private int type; private string content; private string time; private string fromsubjid; private int msgtype = 0; // 0: accept 1: Send public immessage () {This. type = success;} public int GetType () {return type;} public void settype (INT type) {This. type = type;} Public String getcontent () {return content;} public void setcontent (string content) {This. content = content;} Public String gettime () {return time;} public void settime (string time) {This. time = time;} Public String getfromsubjid () {return fromsubjid;} public void setfromsubjid (string fromsubjid) {This. fromsubjid = fromsubjid;} public int getmsgtype () {return msgtype;} public void setmsgtype (INT msgtype) {This. msgtype = msgtype ;}@ overridepublic int describecontents () {return 0 ;}@ overridepublic void writetoparcel (parcel DEST, int flags) {DeST. writeint (type); DeST. writestring (content); DeST. writestring (time); DeST. writestring (fromsubjid); DeST. writeint (msgtype);} public static final parcelable. creator <immessage> creator = new parcelable. creator <immessage> () {@ overridepublic immessage createfromparcel (parcel source) {immessage message = new immessage (); message. settype (source. readint (); message. setcontent (source. readstring (); message. settime (source. readstring (); message. setfromsubjid (source. readstring (); message. setmsgtype (source. readint (); return message;} @ overridepublic immessage [] newarray (INT size) {return New immessage [size] ;}; public immessage (string content, string time, string withsb, int msgtype) {super (); this. content = content; this. time = time; this. msgtype = msgtype; this. fromsubjid = withsb;} @ overridepublic int compareto (immessage OTH) {If (null = This. gettime () | null = oth. gettime () {return 0;} string time1 = ""; string time2 = ""; time1 = This. gettime (); time2 = oth. gettime (); Return time1.compareto (time2 );}}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.