Skip to content

Commit 79e6406

Browse files
committed
Merged latest remote commit into local project.
2 parents f407246 + 61cac35 commit 79e6406

5 files changed

Lines changed: 108 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### What is this?
44

5-
This is a library, prviding some core functionality for an Android App aiming
5+
This is a library, providing some core functionality for an Android App aiming
66
to implement the API of the [Proxer.me](https://proxer.me/) website.
77

88
### Including in your project

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.os.Parcelable;
55
import android.support.annotation.IntRange;
66
import android.support.annotation.NonNull;
7+
import android.support.annotation.Nullable;
78

89
import com.afollestad.bridge.annotations.Body;
910
import com.proxerme.library.interfaces.IdItem;
@@ -39,7 +40,7 @@ public Conference[] newArray(int size) {
3940
@Body(name = "count")
4041
private int participantAmount;
4142
@Body(name = "image")
42-
private String imageId;
43+
private String image;
4344
@Body(name = "group")
4445
private boolean isGroup;
4546
@Body(name = "read")
@@ -55,25 +56,30 @@ public Conference[] newArray(int size) {
5556
}
5657

5758
public Conference(@NonNull String id, @NonNull String topic, @NonNull String customTopic,
58-
@IntRange(from = 2) int participantAmount, @NonNull String imageId,
59-
boolean isGroup, boolean isRead, long time,
59+
@IntRange(from = 2) int participantAmount, @Nullable String imageType,
60+
@Nullable String imageId, boolean isGroup, boolean isRead, long time,
6061
@IntRange(from = 0) int unreadMessageAmount,
6162
@NonNull String lastReadMessageId) {
6263
this.id = id;
6364
this.topic = topic;
6465
this.customTopic = customTopic;
6566
this.participantAmount = participantAmount;
66-
this.imageId = imageId;
6767
this.isGroup = isGroup;
6868
this.isRead = isRead;
6969
this.time = time;
7070
this.unreadMessageAmount = unreadMessageAmount;
7171
this.lastReadMessageId = lastReadMessageId;
72+
73+
if (imageType == null || imageType.isEmpty() || imageId == null || imageType.isEmpty()) {
74+
this.image = "";
75+
} else {
76+
this.image = imageType + ":" + imageId;
77+
}
7278
}
7379

7480
protected Conference(Parcel in) {
7581
this.lastReadMessageId = in.readString();
76-
this.imageId = in.readString();
82+
this.image = in.readString();
7783
this.isRead = in.readByte() != 0;
7884
this.customTopic = in.readString();
7985
this.participantAmount = in.readInt();
@@ -91,7 +97,7 @@ public String getLastReadMessageId() {
9197

9298
@NonNull
9399
public String getImageType() {
94-
String[] split = imageId.split(":");
100+
String[] split = image.split(":");
95101

96102
if (split.length == 2) {
97103
return split[0];
@@ -103,7 +109,7 @@ public String getImageType() {
103109
@Override
104110
@NonNull
105111
public String getImageId() {
106-
String[] split = imageId.split(":");
112+
String[] split = image.split(":");
107113

108114
if (split.length == 2) {
109115
return split[1];
@@ -164,7 +170,7 @@ public boolean equals(Object o) {
164170
if (isGroup != that.isGroup) return false;
165171
if (unreadMessageAmount != that.unreadMessageAmount) return false;
166172
if (!lastReadMessageId.equals(that.lastReadMessageId)) return false;
167-
if (!imageId.equals(that.imageId)) return false;
173+
if (!image.equals(that.image)) return false;
168174
if (!customTopic.equals(that.customTopic)) return false;
169175
if (!topic.equals(that.topic)) return false;
170176
return id.equals(that.id);
@@ -174,7 +180,7 @@ public boolean equals(Object o) {
174180
@Override
175181
public int hashCode() {
176182
int result = lastReadMessageId.hashCode();
177-
result = 31 * result + imageId.hashCode();
183+
result = 31 * result + image.hashCode();
178184
result = 31 * result + (isRead ? 1 : 0);
179185
result = 31 * result + customTopic.hashCode();
180186
result = 31 * result + participantAmount;
@@ -194,7 +200,7 @@ public int describeContents() {
194200
@Override
195201
public void writeToParcel(Parcel dest, int flags) {
196202
dest.writeString(this.lastReadMessageId);
197-
dest.writeString(this.imageId);
203+
dest.writeString(this.image);
198204
dest.writeByte(this.isRead ? (byte) 1 : (byte) 0);
199205
dest.writeString(this.customTopic);
200206
dest.writeInt(this.participantAmount);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.proxerme.library.connection.messenger.request;
2+
3+
import android.support.annotation.NonNull;
4+
5+
import com.afollestad.bridge.Form;
6+
import com.afollestad.bridge.Response;
7+
import com.proxerme.library.connection.ProxerRequest;
8+
import com.proxerme.library.connection.messenger.result.SendMessageResult;
9+
import com.proxerme.library.info.ProxerTag;
10+
import com.proxerme.library.info.ProxerUrlHolder;
11+
12+
/**
13+
* TODO: Describe class
14+
*
15+
* @author Ruben Gees
16+
*/
17+
18+
public class SendMessageRequest extends ProxerRequest<SendMessageResult> {
19+
20+
private static final String SEND_MESSAGE_URL = "/api/v1/messenger/setmessage";
21+
22+
private static final String CONFERENCE_ID_FORM = "conference_id";
23+
private static final String TEXT_FORM = "text";
24+
25+
private String conferenceId;
26+
private String text;
27+
28+
public SendMessageRequest(@NonNull String conferenceId, @NonNull String text) {
29+
this.conferenceId = conferenceId;
30+
this.text = text;
31+
}
32+
33+
@Override
34+
protected int getTag() {
35+
return ProxerTag.MESSENGER_SEND_MESSAGE;
36+
}
37+
38+
@Override
39+
protected SendMessageResult parse(@NonNull Response response) throws Exception {
40+
return response.asClass(SendMessageResult.class);
41+
}
42+
43+
@NonNull
44+
@Override
45+
protected String getURL() {
46+
return ProxerUrlHolder.getHost() + SEND_MESSAGE_URL;
47+
}
48+
49+
@Override
50+
protected Form getBody() {
51+
return new Form().add(CONFERENCE_ID_FORM, conferenceId)
52+
.add(TEXT_FORM, text);
53+
}
54+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.proxerme.library.connection.messenger.result;
2+
3+
import android.support.annotation.Nullable;
4+
5+
import com.afollestad.bridge.annotations.Body;
6+
import com.proxerme.library.interfaces.ProxerResult;
7+
8+
/**
9+
* TODO: Describe class
10+
*
11+
* @author Ruben Gees
12+
*/
13+
14+
public class SendMessageResult implements ProxerResult<String> {
15+
16+
@Nullable
17+
@Body(name = "data")
18+
String item;
19+
20+
SendMessageResult() {
21+
}
22+
23+
public SendMessageResult(@Nullable String item) {
24+
this.item = item;
25+
}
26+
27+
@Override
28+
@Nullable
29+
public String getItem() {
30+
return item;
31+
}
32+
}

library/src/main/java/com/proxerme/library/info/ProxerTag.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public class ProxerTag {
2525
public static final int INFO_ENTRY_SYNONYM = 21;
2626
public static final int INFO_ENTRY_SEASON = 22;
2727

28-
2928
public static final int MESSENGER_CONFERENCES = 30;
3029
public static final int MESSENGER_MESSAGES = 31;
31-
public static final int MESSENGER_CONFERENCE_CONSTANTS = 32;
32-
public static final int MESSENGER_CONFERENCE_INFO = 33;
30+
public static final int MESSENGER_SEND_MESSAGE = 32;
31+
public static final int MESSENGER_CONFERENCE_CONSTANTS = 33;
32+
public static final int MESSENGER_CONFERENCE_INFO = 34;
3333

3434
public static final int CONFERENCES = 100;
3535
public static final int CHAT = 101;
@@ -41,7 +41,8 @@ public class ProxerTag {
4141
@IntDef({LOGIN, NEWS, LOGOUT, USERINFO, TOPTEN, CONFERENCES, CHAT, SEND_MESSAGE,
4242
USER_MEDIA_LIST, MEDIA_LIST, MEDIA_SEARCH,
4343
INFO_ENTRY_CORE, INFO_ENTRY_SYNONYM, INFO_ENTRY_SEASON,
44-
MESSENGER_CONFERENCES, MESSENGER_MESSAGES, MESSENGER_CONFERENCE_CONSTANTS, MESSENGER_CONFERENCE_INFO})
44+
MESSENGER_CONFERENCES, MESSENGER_MESSAGES, MESSENGER_SEND_MESSAGE,
45+
MESSENGER_CONFERENCE_CONSTANTS, MESSENGER_CONFERENCE_INFO})
4546
@Retention(RetentionPolicy.SOURCE)
4647
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
4748
public @interface ConnectionTag {

0 commit comments

Comments
 (0)