Skip to content

Commit f407246

Browse files
committed
Added implementation of the ConferenceInfo API.
1 parent 57c517e commit f407246

6 files changed

Lines changed: 522 additions & 2 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package com.proxerme.library.connection.messenger.entity;
2+
3+
import android.os.Parcel;
4+
import android.os.Parcelable;
5+
6+
import com.afollestad.bridge.annotations.Body;
7+
import com.proxerme.library.connection.messenger.entity.conferenceInfo.User;
8+
9+
import java.util.Arrays;
10+
11+
/**
12+
* Class that represents the infos of a conference such as the participating users.
13+
*
14+
* @author Desnoo
15+
*/
16+
public class ConferenceInfo implements Parcelable {
17+
18+
public static final Creator<ConferenceInfo> CREATOR = new Creator<ConferenceInfo>() {
19+
@Override
20+
public ConferenceInfo createFromParcel(Parcel in) {
21+
return new ConferenceInfo(in);
22+
}
23+
24+
@Override
25+
public ConferenceInfo[] newArray(int size) {
26+
return new ConferenceInfo[size];
27+
}
28+
};
29+
30+
@Body(name = "conference")
31+
Conference conference;
32+
@Body(name = "users")
33+
User[] user;
34+
35+
/**
36+
* Private Constructor.
37+
*/
38+
ConferenceInfo() {
39+
}
40+
41+
/**
42+
* The Constructor.
43+
*
44+
* @param conference The conference object.
45+
* @param user The user object.
46+
*/
47+
public ConferenceInfo(Conference conference, User[] user) {
48+
this.conference = conference;
49+
this.user = user;
50+
}
51+
52+
/**
53+
* The Constructor to parse a parcel.
54+
*
55+
* @param in The parcel to parse.
56+
*/
57+
protected ConferenceInfo(Parcel in) {
58+
conference = in.readParcelable(Conference.class.getClassLoader());
59+
user = in.createTypedArray(User.CREATOR);
60+
}
61+
62+
@Override
63+
public int describeContents() {
64+
return 0;
65+
}
66+
67+
@Override
68+
public void writeToParcel(Parcel parcel, int i) {
69+
parcel.writeParcelable(conference, i);
70+
parcel.writeTypedArray(user, i);
71+
}
72+
73+
/**
74+
* Returns the Conference.
75+
*
76+
* @return The Conference.‚
77+
**/
78+
public Conference getConference() {
79+
return conference;
80+
}
81+
82+
/**
83+
* Returns the User.
84+
*
85+
* @return The User.
86+
**/
87+
public User[] getUser() {
88+
return user;
89+
}
90+
91+
@Override
92+
public boolean equals(Object o) {
93+
if (this == o) return true;
94+
if (o == null || getClass() != o.getClass()) return false;
95+
96+
ConferenceInfo that = (ConferenceInfo) o;
97+
98+
if (!conference.equals(that.conference)) return false;
99+
// Probably incorrect - comparing Object[] arrays with Arrays.equals
100+
return Arrays.equals(user, that.user);
101+
102+
}
103+
104+
@Override
105+
public int hashCode() {
106+
int result = conference.hashCode();
107+
result = 31 * result + Arrays.hashCode(user);
108+
return result;
109+
}
110+
}
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
package com.proxerme.library.connection.messenger.entity.conferenceInfo;
2+
3+
import android.os.Parcel;
4+
import android.os.Parcelable;
5+
import android.support.annotation.IntRange;
6+
import android.support.annotation.NonNull;
7+
8+
import com.afollestad.bridge.annotations.Body;
9+
10+
/**
11+
* The class that represents the ConferenceInfo Conference entity.
12+
* This class is different to the {@link com.proxerme.library.connection.messenger.entity.Conference}
13+
*
14+
* @author Desnoo
15+
*/
16+
public class Conference implements Parcelable {
17+
18+
public static final Creator<Conference> CREATOR = new Creator<Conference>() {
19+
@Override
20+
public Conference createFromParcel(Parcel in) {
21+
return new Conference(in);
22+
}
23+
24+
@Override
25+
public Conference[] newArray(int size) {
26+
return new Conference[size];
27+
}
28+
};
29+
30+
@Body(name = "topic")
31+
String topic;
32+
@Body(name = "count")
33+
int participants;
34+
@Body(name = "timestampStart")
35+
long timestampStart;
36+
@Body(name = "timestampEnd")
37+
long timestampEnd;
38+
@Body(name = "leader")
39+
String leaderId;
40+
41+
/**
42+
* Private Constructor.
43+
*/
44+
Conference() {
45+
}
46+
47+
/**
48+
* The Constructor.
49+
*
50+
* @param topic The topic.
51+
* @param participants The participants of this conference.
52+
* @param timestampStart The timestamp when the conference started.
53+
* @param timestampEnd The timestamp when the last message of the conference was sent.
54+
* @param leaderId The user id of the conference leader.
55+
*/
56+
public Conference(@NonNull String topic, @IntRange(from = 1) int participants,
57+
@IntRange(from = 0) long timestampStart, @IntRange(from = 0) long timestampEnd,
58+
@NonNull String leaderId) {
59+
this.topic = topic;
60+
this.participants = participants;
61+
this.timestampStart = timestampStart;
62+
this.timestampEnd = timestampEnd;
63+
this.leaderId = leaderId;
64+
}
65+
66+
/**
67+
* The Constructor parses the parcel.
68+
*
69+
* @param in The parcel to parse.
70+
*/
71+
protected Conference(Parcel in) {
72+
topic = in.readString();
73+
participants = in.readInt();
74+
timestampStart = in.readLong();
75+
timestampEnd = in.readLong();
76+
leaderId = in.readString();
77+
}
78+
79+
80+
@Override
81+
public int describeContents() {
82+
return 0;
83+
}
84+
85+
@Override
86+
public void writeToParcel(Parcel parcel, int i) {
87+
parcel.writeString(topic);
88+
parcel.writeInt(participants);
89+
parcel.writeLong(timestampStart);
90+
parcel.writeLong(timestampEnd);
91+
parcel.writeString(leaderId);
92+
}
93+
94+
95+
/**
96+
* Returns the Topic.
97+
*
98+
* @return The Topic.
99+
**/
100+
@NonNull
101+
public String getTopic() {
102+
return topic;
103+
}
104+
105+
/**
106+
* Returns the Count.
107+
*
108+
* @return The Count.
109+
**/
110+
@IntRange(from = 1)
111+
public int getParticipants() {
112+
return participants;
113+
}
114+
115+
/**
116+
* Returns the TimestampStart.
117+
*
118+
* @return The TimestampStart.
119+
**/
120+
@IntRange(from = 0)
121+
public long getTimestampStart() {
122+
return timestampStart;
123+
}
124+
125+
/**
126+
* Returns the TimestampEnd.
127+
*
128+
* @return The TimestampEnd.
129+
**/
130+
@IntRange(from = 0)
131+
public long getTimestampEnd() {
132+
return timestampEnd;
133+
}
134+
135+
/**
136+
* Returns the Leader.
137+
*
138+
* @return The Leader.
139+
**/
140+
@NonNull
141+
public String getLeaderId() {
142+
return leaderId;
143+
}
144+
145+
@SuppressWarnings("SimplifiableIfStatement")
146+
@Override
147+
public boolean equals(Object o) {
148+
if (this == o) return true;
149+
if (o == null || getClass() != o.getClass()) return false;
150+
151+
Conference that = (Conference) o;
152+
153+
if (participants != that.participants) return false;
154+
if (timestampStart != that.timestampStart) return false;
155+
if (timestampEnd != that.timestampEnd) return false;
156+
if (!topic.equals(that.topic)) return false;
157+
return leaderId.equals(that.leaderId);
158+
159+
}
160+
161+
@Override
162+
public int hashCode() {
163+
int result = topic.hashCode();
164+
result = 31 * result + participants;
165+
result = 31 * result + (int) (timestampStart ^ (timestampStart >>> 32));
166+
result = 31 * result + (int) (timestampEnd ^ (timestampEnd >>> 32));
167+
result = 31 * result + leaderId.hashCode();
168+
return result;
169+
}
170+
}

0 commit comments

Comments
 (0)