1 package cc.minsnail.beans;
3 import android.os.Parcel;
4 import android.os.Parcelable;
6 import org.jivesoftware.smack.packet.Message;
9 * Created by yg on 2016/9/27.
11 public class YgMessage implements Parcelable {
21 public void setBody(String body) {
25 public void setTo(String to) {
29 public void setFrom(String from) {
33 public void setType(String type) {
37 public void setCustom(int isCustom) {
38 this.custom = isCustom;
41 public String getBody() {
45 public String getFrom() {
49 public String getTo() {
53 public String getType() {
57 public int getCustom() {
61 public YgMessage getFromMessage(Message message) {
62 this.setTo(message.getTo());
63 this.setFrom(message.getFrom());
64 this.setBody(message.getBody());
65 this.setType(message.getType().toString());
69 protected YgMessage(Parcel in) {
70 this.to = in.readString();
71 this.from = in.readString();
72 this.type = in.readString();
73 this.body = in.readString();
74 this.custom = in.readInt();
77 public static final Creator<YgMessage> CREATOR = new Creator<YgMessage>() {
79 public YgMessage createFromParcel(Parcel in) {
80 return new YgMessage(in);
84 public YgMessage[] newArray(int size) {
85 return new YgMessage[size];
90 public int describeContents() {
95 public void writeToParcel(Parcel parcel, int i) {
96 parcel.writeString(this.to);
97 parcel.writeString(this.from);
98 parcel.writeString(this.type);
99 parcel.writeString(this.body);
100 parcel.writeInt(this.custom);
103 public String toJson() {
104 return "{\"to\":" + to + ",\"from\":" + from + ",\"body\":" + body + ",\"type\":" + type + "}";