Skip to content

Commit 37b8e17

Browse files
committed
Reorder constructor parameters, add missing fields and fix imageId
1 parent 28882d0 commit 37b8e17

2 files changed

Lines changed: 54 additions & 40 deletions

File tree

library/src/main/java/com/proxerme/library/connection/messenger/entity/Conference.java

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,30 @@ public Conference[] newArray(int size) {
3030
}
3131
};
3232

33-
@Body(name = "read_mid")
34-
private String lastReadMessageId;
35-
@Body(name = "image")
36-
private String imageId;
37-
@Body(name = "read")
38-
private boolean isRead;
33+
@Body(name = "id")
34+
private String id;
35+
@Body(name = "topic")
36+
private String topic;
3937
@Body(name = "topic_custom")
4038
private String customTopic;
4139
@Body(name = "count")
4240
private int participantAmount;
43-
@Body(name = "topic")
44-
private String topic;
45-
@Body(name = "id")
46-
private String id;
47-
@Body(name = "timestamp_end")
48-
private long time;
41+
@Body(name = "image")
42+
private String imageId;
4943
@Body(name = "group")
5044
private boolean isGroup;
45+
@Body(name = "read")
46+
private boolean isRead;
47+
@Body(name = "timestamp_end")
48+
private long time;
5149
@Body(name = "read_count")
5250
private int unreadMessageAmount;
51+
@Body(name = "read_mid")
52+
private String lastReadMessageId;
5353

5454
Conference() {
5555
}
5656

57-
public Conference(@NonNull String lastReadMessageId, @NonNull String imageId, boolean isRead,
58-
@NonNull String customTopic, int participantAmount, @NonNull String topic,
59-
@NonNull String id, long time, boolean isGroup, int unreadMessageAmount) {
60-
this.lastReadMessageId = lastReadMessageId;
61-
this.imageId = imageId;
62-
this.isRead = isRead;
63-
this.customTopic = customTopic;
64-
this.participantAmount = participantAmount;
65-
this.topic = topic;
66-
this.id = id;
67-
this.time = time;
68-
this.isGroup = isGroup;
69-
this.unreadMessageAmount = unreadMessageAmount;
70-
}
71-
7257
protected Conference(Parcel in) {
7358
this.lastReadMessageId = in.readString();
7459
this.imageId = in.readString();
@@ -87,10 +72,27 @@ public String getLastReadMessageId() {
8772
return lastReadMessageId;
8873
}
8974

75+
@NonNull
76+
public String getImageType() {
77+
String[] split = imageId.split(":");
78+
79+
if (split.length == 2) {
80+
return split[0];
81+
} else {
82+
return "";
83+
}
84+
}
85+
9086
@Override
9187
@NonNull
9288
public String getImageId() {
93-
return imageId;
89+
String[] split = imageId.split(":");
90+
91+
if (split.length == 2) {
92+
return split[1];
93+
} else {
94+
return "";
95+
}
9496
}
9597

9698
public boolean isRead() {

library/src/main/java/com/proxerme/library/connection/messenger/entity/Message.java

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
public class Message implements IdItem, TimeItem, Parcelable {
1818

19-
public static final Parcelable.Creator<Message> CREATOR = new Parcelable.Creator<Message>() {
19+
public static final Creator<Message> CREATOR = new Creator<Message>() {
2020
@Override
2121
public Message createFromParcel(Parcel source) {
2222
return new Message(source);
@@ -34,38 +34,42 @@ public Message[] newArray(int size) {
3434
String conferenceId;
3535
@Body(name = "user_id")
3636
String userId;
37+
@Body(name = "username")
38+
String username;
3739
@Body(name = "message")
3840
String message;
3941
@Body(name = "action")
4042
String action;
4143
@Body(name = "timestamp")
4244
long time;
43-
@Body(name = "username")
44-
String username;
45+
@Body(name = "device")
46+
String device;
4547

4648
Message() {
4749
}
4850

4951
public Message(@NonNull String id, @NonNull String conferenceId, @NonNull String userId,
50-
@NonNull String message, @NonNull String action, long time,
51-
@NonNull String username) {
52+
@NonNull String username, @NonNull String message, @NonNull String action,
53+
long time, @NonNull String device) {
5254
this.id = id;
5355
this.conferenceId = conferenceId;
5456
this.userId = userId;
57+
this.username = username;
5558
this.message = message;
5659
this.action = action;
5760
this.time = time;
58-
this.username = username;
61+
this.device = device;
5962
}
6063

6164
protected Message(Parcel in) {
6265
this.id = in.readString();
6366
this.conferenceId = in.readString();
6467
this.userId = in.readString();
68+
this.username = in.readString();
6569
this.message = in.readString();
6670
this.action = in.readString();
6771
this.time = in.readLong();
68-
this.username = in.readString();
72+
this.device = in.readString();
6973
}
7074

7175
@NonNull
@@ -84,6 +88,11 @@ public String getUserId() {
8488
return userId;
8589
}
8690

91+
@NonNull
92+
public String getUsername() {
93+
return username;
94+
}
95+
8796
@NonNull
8897
public String getMessage() {
8998
return message;
@@ -100,8 +109,8 @@ public long getTime() {
100109
}
101110

102111
@NonNull
103-
public String getUsername() {
104-
return username;
112+
public String getDevice() {
113+
return device;
105114
}
106115

107116
@Override
@@ -115,9 +124,10 @@ public boolean equals(Object o) {
115124
if (!id.equals(message1.id)) return false;
116125
if (!conferenceId.equals(message1.conferenceId)) return false;
117126
if (!userId.equals(message1.userId)) return false;
127+
if (!username.equals(message1.username)) return false;
118128
if (!message.equals(message1.message)) return false;
119129
if (!action.equals(message1.action)) return false;
120-
return username.equals(message1.username);
130+
return device.equals(message1.device);
121131

122132
}
123133

@@ -126,10 +136,11 @@ public int hashCode() {
126136
int result = id.hashCode();
127137
result = 31 * result + conferenceId.hashCode();
128138
result = 31 * result + userId.hashCode();
139+
result = 31 * result + username.hashCode();
129140
result = 31 * result + message.hashCode();
130141
result = 31 * result + action.hashCode();
131142
result = 31 * result + (int) (time ^ (time >>> 32));
132-
result = 31 * result + username.hashCode();
143+
result = 31 * result + device.hashCode();
133144
return result;
134145
}
135146

@@ -143,9 +154,10 @@ public void writeToParcel(Parcel dest, int flags) {
143154
dest.writeString(this.id);
144155
dest.writeString(this.conferenceId);
145156
dest.writeString(this.userId);
157+
dest.writeString(this.username);
146158
dest.writeString(this.message);
147159
dest.writeString(this.action);
148160
dest.writeLong(this.time);
149-
dest.writeString(this.username);
161+
dest.writeString(this.device);
150162
}
151163
}

0 commit comments

Comments
 (0)