6 import android.os.Parcelable; |
6 import android.os.Parcelable; |
7 |
7 |
8 import com.beem.project.beem.utils.PresenceType; |
8 import com.beem.project.beem.utils.PresenceType; |
9 import com.beem.project.beem.utils.Status; |
9 import com.beem.project.beem.utils.Status; |
10 |
10 |
|
11 /** |
|
12 * this class contain contact presence informations. |
|
13 * @author nikita |
|
14 */ |
11 public class PresenceAdapter implements Parcelable { |
15 public class PresenceAdapter implements Parcelable { |
|
16 |
|
17 /** |
|
18 * Parcelable.Creator needs by Android. |
|
19 */ |
|
20 public static final Parcelable.Creator<PresenceAdapter> CREATOR = new Parcelable.Creator<PresenceAdapter>() { |
|
21 |
|
22 @Override |
|
23 public PresenceAdapter createFromParcel( |
|
24 Parcel source) { |
|
25 return new PresenceAdapter(source); |
|
26 } |
|
27 |
|
28 @Override |
|
29 public PresenceAdapter[] newArray(int size) { |
|
30 return new PresenceAdapter[size]; |
|
31 } |
|
32 }; |
12 |
33 |
13 private int mType; |
34 private int mType; |
14 private int mStatus; |
35 private int mStatus; |
15 private String mTo; |
36 private String mTo; |
16 private String mFrom; |
37 private String mFrom; |
17 private String mStatusText; |
38 private String mStatusText; |
18 |
39 |
|
40 |
19 /** |
41 /** |
20 * Parcelable.Creator needs by Android. |
42 * constructor from Parcel. |
|
43 * @param source parcelable presence. |
21 */ |
44 */ |
22 public static final Parcelable.Creator<PresenceAdapter> CREATOR = new Parcelable.Creator<PresenceAdapter>() { |
45 public PresenceAdapter(final Parcel source) { |
23 |
|
24 @Override |
|
25 public PresenceAdapter createFromParcel( |
|
26 Parcel source) { |
|
27 return new PresenceAdapter(source); |
|
28 } |
|
29 |
|
30 @Override |
|
31 public PresenceAdapter[] newArray(int size) { |
|
32 return new PresenceAdapter[size]; |
|
33 } |
|
34 }; |
|
35 |
|
36 public PresenceAdapter(Parcel source) { |
|
37 mType = source.readInt(); |
46 mType = source.readInt(); |
38 mStatus = source.readInt(); |
47 mStatus = source.readInt(); |
39 mTo = source.readString(); |
48 mTo = source.readString(); |
40 mFrom = source.readString(); |
49 mFrom = source.readString(); |
41 mStatusText = source.readString(); |
50 mStatusText = source.readString(); |
42 } |
51 } |
43 |
52 |
44 public PresenceAdapter(Presence presence) { |
53 /** |
|
54 * constructor from smack Presence. |
|
55 * @param presence smack presence. |
|
56 */ |
|
57 public PresenceAdapter(final Presence presence) { |
45 mType = PresenceType.getPresenceType(presence); |
58 mType = PresenceType.getPresenceType(presence); |
46 mStatus = Status.getStatusFromPresence(presence); |
59 mStatus = Status.getStatusFromPresence(presence); |
47 mTo = presence.getTo(); |
60 mTo = presence.getTo(); |
48 mFrom = presence.getFrom(); |
61 mFrom = presence.getFrom(); |
49 mStatusText = presence.getStatus(); |
62 mStatusText = presence.getStatus(); |
54 // TODO Auto-generated method stub |
67 // TODO Auto-generated method stub |
55 return 0; |
68 return 0; |
56 } |
69 } |
57 |
70 |
58 /** |
71 /** |
|
72 * mFrom getter. |
59 * @return the mFrom |
73 * @return the mFrom |
60 */ |
74 */ |
61 public String getFrom() { |
75 public String getFrom() { |
62 return mFrom; |
76 return mFrom; |
63 } |
77 } |
64 |
78 |
65 /** |
79 /** |
|
80 * mStatus getter. |
66 * @return the mStatus |
81 * @return the mStatus |
67 */ |
82 */ |
68 public int getStatus() { |
83 public int getStatus() { |
69 return mStatus; |
84 return mStatus; |
70 } |
85 } |
71 |
86 |
72 /** |
87 /** |
|
88 * mStatusText getter. |
73 * @return the mStatusText |
89 * @return the mStatusText |
74 */ |
90 */ |
75 public String getStatusText() { |
91 public String getStatusText() { |
76 return mStatusText; |
92 return mStatusText; |
77 } |
93 } |
78 |
94 |
79 /** |
95 /** |
|
96 * mTo getter. |
80 * @return the mTo |
97 * @return the mTo |
81 */ |
98 */ |
82 public String getTo() { |
99 public String getTo() { |
83 return mTo; |
100 return mTo; |
84 } |
101 } |
85 |
102 |
86 /** |
103 /** |
|
104 * mType getter. |
87 * @return the mType |
105 * @return the mType |
88 */ |
106 */ |
89 public int getType() { |
107 public int getType() { |
90 return mType; |
108 return mType; |
91 } |
109 } |
92 |
110 |
93 /** |
111 /** |
94 * @param mFrom |
112 * mFrom setter. |
95 * the mFrom to set |
113 * @param from the mFrom to set |
96 */ |
114 */ |
97 public void setFrom(String mFrom) { |
115 public void setFrom(final String from) { |
98 this.mFrom = mFrom; |
116 this.mFrom = from; |
99 } |
117 } |
100 |
118 |
101 /** |
119 /** |
102 * @param mStatus |
120 * mStatus setter. |
103 * the mStatus to set |
121 * @param status the mStatus to set |
104 */ |
122 */ |
105 public void setStatus(int mStatus) { |
123 public void setStatus(final int status) { |
106 this.mStatus = mStatus; |
124 this.mStatus = status; |
107 } |
125 } |
108 |
126 |
109 /** |
127 /** |
110 * @param mStatusText |
128 * mStatusText setter. |
111 * the mStatusText to set |
129 * @param statusText the mStatusText to set |
112 */ |
130 */ |
113 public void setStatusText(String mStatusText) { |
131 public void setStatusText(final String statusText) { |
114 this.mStatusText = mStatusText; |
132 this.mStatusText = statusText; |
115 } |
133 } |
116 |
134 |
117 /** |
135 /** |
118 * @param mTo |
136 * mTo setter. |
119 * the mTo to set |
137 * @param to the mTo to set |
120 */ |
138 */ |
121 public void setTo(String mTo) { |
139 public void setTo(final String to) { |
122 this.mTo = mTo; |
140 this.mTo = to; |
123 } |
141 } |
124 |
142 |
125 /** |
143 /** |
126 * @param mType |
144 * mType setter. |
127 * the mType to set |
145 * @param type the type to set |
128 */ |
146 */ |
129 public void setType(int mType) { |
147 public void setType(int type) { |
130 this.mType = mType; |
148 this.mType = type; |
131 } |
149 } |
132 |
150 |
133 @Override |
151 @Override |
134 public void writeToParcel(Parcel dest, int flags) { |
152 public void writeToParcel(Parcel dest, int flags) { |
135 dest.writeInt(mType); |
153 dest.writeInt(mType); |