Repository navigation
Expand file tree
/
Copy pathChatRoom.java
More file actions
85 lines (62 loc) · 2.06 KB
/
Copy pathChatRoom.java
File metadata and controls
85 lines (62 loc) · 2.06 KB
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
package com.example.sunaustin8.chatter;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by sunaustin8 on 4/16/17.
*/
public class ChatRoom implements Parcelable {
String name;
String key;
HashMap<String, String> participants = new HashMap<String, String>();
public ChatRoom() {}
public ChatRoom(String name) { this.name = name; this.participants = participants;}
public ChatRoom(String name, HashMap<String, String> participants){
this.name = name;
this.participants = participants;
}
public ChatRoom(String name, String key, HashMap<String, String> participants) {
this.name = name;
this.key = key;
this.participants = participants;
}
public ChatRoom(HashMap<String, String> participants) {
this.participants = participants;
}
public HashMap<String, String> getParticipants() {
return this.participants;
}
public void addParticipant(Participant newPart, String message) {
participants.put(newPart.getName(), message);
}
public String getParticipantMessage(String parName) {
return participants.get(parName);
}
public String getName() { return this.name; }
public void setKey(String newKey) { this.key = newKey; }
public String getKey() { return this.key; }
private int getMessageCount() { return this.participants.size(); }
//parcel methods for the Adapter
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.name);
}
protected ChatRoom(Parcel in) {
this.name = in.readString();
}
public static final Creator<ChatRoom> CREATOR = new Creator<ChatRoom>() {
@Override
public ChatRoom createFromParcel(Parcel parcel) {
return new ChatRoom(parcel);
}
@Override
public ChatRoom[] newArray(int size) {
return new ChatRoom[size];
}
};
}