IOS
hefeixia
2021-02-18 49f3c1374873f73dbde2983ca0fcf1fb10bfedbf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright (c) 2020 WildFireChat. All rights reserved.
 */
 
package cn.wildfirechat.push;
 
import android.os.Parcel;
import android.os.Parcelable;
 
import org.json.JSONException;
import org.json.JSONObject;
 
/**
 * Created by heavyrain.lee on 2018/3/18.
 */
 
public class AndroidPushMessage implements Parcelable {
    public String sender;
    public String senderName;
    public int convType;
    public String target;
    public String targetName;
    public int line;
    public int cntType;
    public long serverTime;
    public int pushMessageType; //0 normal, 1 voip invite, 2 voip bye
    public String pushContent;
    public int unReceivedMsg;
    public int mentionedType;
    public boolean isHiddenDetail;
 
    protected AndroidPushMessage(Parcel in) {
        sender = in.readString();
        senderName = in.readString();
        convType = in.readInt();
        target = in.readString();
        targetName = in.readString();
        line = in.readInt();
        cntType = in.readInt();
        serverTime = in.readLong();
        pushMessageType = in.readInt();
        pushContent = in.readString();
        unReceivedMsg = in.readInt();
        mentionedType = in.readInt();
        isHiddenDetail = in.readInt()>0;
    }
 
    public static final Creator<AndroidPushMessage> CREATOR = new Creator<AndroidPushMessage>() {
        @Override
        public AndroidPushMessage createFromParcel(Parcel in) {
            return new AndroidPushMessage(in);
        }
 
        @Override
        public AndroidPushMessage[] newArray(int size) {
            return new AndroidPushMessage[size];
        }
    };
 
    public AndroidPushMessage() {
 
    }
 
    public static AndroidPushMessage messageFromJson(String jsonString) throws JSONException {
        JSONObject jsonObject = new JSONObject(jsonString);
        AndroidPushMessage pushMessage = new AndroidPushMessage();
        pushMessage.sender = jsonObject.getString("sender");
        pushMessage.senderName = jsonObject.optString("senderName");
        pushMessage.convType = jsonObject.getInt("convType");
        pushMessage.target = jsonObject.getString("target");
        pushMessage.targetName = jsonObject.optString("targetName");
        pushMessage.line = jsonObject.optInt("line");
        pushMessage.cntType = jsonObject.optInt("cntType");
        pushMessage.serverTime = jsonObject.getLong("serverTime");
        pushMessage.pushMessageType = jsonObject.getInt("pushMessageType");
        pushMessage.pushContent = jsonObject.optString("pushContent");
        pushMessage.unReceivedMsg = jsonObject.optInt("unReceivedMsg", 1);
        pushMessage.mentionedType = jsonObject.optInt("mentionedType", 0);
        pushMessage.isHiddenDetail = jsonObject.optBoolean("isHiddenDetail");
        return pushMessage;
    }
 
    @Override
    public int describeContents() {
        return 0;
    }
 
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(sender);
        dest.writeString(senderName);
        dest.writeInt(convType);
        dest.writeString(target);
        dest.writeString(targetName);
        dest.writeInt(line);
        dest.writeInt(cntType);
        dest.writeLong(serverTime);
        dest.writeInt(pushMessageType);
        dest.writeString(pushContent);
        dest.writeInt(unReceivedMsg);
        dest.writeInt(mentionedType);
        dest.writeInt(isHiddenDetail?1:0);
    }
}