From a1a47038e4e37e16211dd7c56aa1051093752db4 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 24 Oct 2015 17:56:52 +0300
Subject: moving to Gradle
---
src/main/java/com/juick/Group.java | 29 ++++++
src/main/java/com/juick/Message.java | 173 +++++++++++++++++++++++++++++++++++
src/main/java/com/juick/Place.java | 33 +++++++
src/main/java/com/juick/Tag.java | 35 +++++++
src/main/java/com/juick/User.java | 53 +++++++++++
5 files changed, 323 insertions(+)
create mode 100644 src/main/java/com/juick/Group.java
create mode 100644 src/main/java/com/juick/Message.java
create mode 100644 src/main/java/com/juick/Place.java
create mode 100644 src/main/java/com/juick/Tag.java
create mode 100644 src/main/java/com/juick/User.java
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Group.java b/src/main/java/com/juick/Group.java
new file mode 100644
index 00000000..008d3af2
--- /dev/null
+++ b/src/main/java/com/juick/Group.java
@@ -0,0 +1,29 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2013, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Group {
+
+ public String Name = null;
+ public int GID = 0;
+ public int UsersCnt = 0;
+}
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
new file mode 100644
index 00000000..3d2b8227
--- /dev/null
+++ b/src/main/java/com/juick/Message.java
@@ -0,0 +1,173 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Message {
+
+ public int MID = 0;
+ public int RID = 0;
+ public int ReplyTo = 0;
+ public String Text = null;
+ public User User = null;
+ public ArrayList Tags = new ArrayList();
+ public Date Timestamp = null;
+ public String TimestampString = null;
+ public int TimeAgo = 0;
+ public int Privacy = 1;
+ public boolean FriendsOnly = false;
+ public boolean ReadOnly = false;
+ public boolean Hidden = false;
+ public boolean VisitorCanComment = true;
+ public int Replies = 0;
+ public String RepliesBy = null;
+ public String AttachmentType = null;
+ public String Photo = null;
+ public String Video = null;
+ public Place Place = null;
+ public int Likes = 0;
+ public boolean UserLike = false;
+ public ArrayList childs = new ArrayList();
+
+ public Message() {
+ }
+
+ public Message(Message msg) {
+ MID = msg.MID;
+ RID = msg.RID;
+ ReplyTo = msg.ReplyTo;
+ Text = msg.Text;
+ User = msg.User;
+ Tags = msg.Tags;
+ Timestamp = msg.Timestamp;
+ TimestampString = msg.TimestampString;
+ TimeAgo = msg.TimeAgo;
+ Privacy = msg.Privacy;
+ FriendsOnly = msg.FriendsOnly;
+ ReadOnly = msg.ReadOnly;
+ Hidden = msg.Hidden;
+ Replies = msg.Replies;
+ AttachmentType = msg.AttachmentType;
+ Photo = msg.Photo;
+ Video = msg.Video;
+ Place = msg.Place;
+ Likes = msg.Likes;
+ UserLike = msg.UserLike;
+ childs = msg.childs;
+ }
+
+ public void parseTags(String strTags) {
+ Tags.addAll(Arrays.asList(strTags.split(" ")));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Message)) {
+ return false;
+ }
+ Message jmsg = (Message) obj;
+ return (this.MID == jmsg.MID && this.RID == jmsg.RID);
+ }
+
+ public int compareTo(Object obj) throws ClassCastException {
+ if (!(obj instanceof Message)) {
+ throw new ClassCastException();
+ }
+ Message jmsg = (Message) obj;
+
+ if (this.MID != jmsg.MID) {
+ if (this.MID > jmsg.MID) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ if (this.RID != jmsg.RID) {
+ if (this.RID < jmsg.RID) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+
+ public int getChildsCount() {
+ int cnt = childs.size();
+ for (int i = 0; i < childs.size(); i++) {
+ cnt += childs.get(i).getChildsCount();
+ }
+ return cnt;
+ }
+
+ public void cleanupChilds() {
+ if (!childs.isEmpty()) {
+ for (int i = 0; i < childs.size(); i++) {
+ childs.get(i).cleanupChilds();
+ }
+ childs.clear();
+ }
+ }
+
+ public String getAttachmentURL() {
+ if (AttachmentType != null) {
+ String url = "http://i.juick.com/";
+ url += AttachmentType.equals("mp4") ? "video" : "photos-1024";
+ url += "/" + MID;
+ if (RID > 0) {
+ url += "-" + RID;
+ }
+ url += "." + AttachmentType;
+ return url;
+ } else {
+ return null;
+ }
+ }
+
+ public String getTagsString() {
+ String ret = "";
+ for (int i = 0; i < Tags.size(); i++) {
+ ret += " *" + Tags.get(i);
+ }
+ if (FriendsOnly) {
+ ret += " *friends";
+ }
+ if (Privacy == -2) {
+ ret += " *private";
+ }
+ if (Privacy == -1) {
+ ret += " *friends";
+ }
+ if (Privacy == 2) {
+ ret += " *public";
+ }
+ if (ReadOnly) {
+ ret += " *readonly";
+ }
+ return ret;
+ }
+}
diff --git a/src/main/java/com/juick/Place.java b/src/main/java/com/juick/Place.java
new file mode 100644
index 00000000..7174ed6e
--- /dev/null
+++ b/src/main/java/com/juick/Place.java
@@ -0,0 +1,33 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Place {
+
+ public int pid = 0;
+ public double lat = 0;
+ public double lon = 0;
+ public String name = null;
+ public int users = 0;
+ public int messages = 0;
+ public int distance = 0;
+}
diff --git a/src/main/java/com/juick/Tag.java b/src/main/java/com/juick/Tag.java
new file mode 100644
index 00000000..3cee3358
--- /dev/null
+++ b/src/main/java/com/juick/Tag.java
@@ -0,0 +1,35 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class Tag implements Comparable {
+
+ public String Name = null;
+ public int TID = 0;
+ public int SynonymID = 0;
+ public int UsageCnt = 0;
+
+ @Override
+ public int compareTo(Tag o) {
+ return this.Name.compareTo(o.Name);
+ }
+}
diff --git a/src/main/java/com/juick/User.java b/src/main/java/com/juick/User.java
new file mode 100644
index 00000000..e3fc0ae7
--- /dev/null
+++ b/src/main/java/com/juick/User.java
@@ -0,0 +1,53 @@
+/*
+ * Juick
+ * Copyright (C) 2008-2011, Ugnich Anton
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+package com.juick;
+
+/**
+ *
+ * @author Ugnich Anton
+ */
+public class User {
+
+ public int UID = 0;
+ public String UName = null;
+ public Object Avatar = null;
+ public String FullName = null;
+ public String JID = null;
+ public int MessagesCount = 0;
+ public String AuthHash = null;
+ public boolean Banned = false;
+
+ public User() {
+ }
+
+ public User(User u) {
+ UID = u.UID;
+ UName = u.UName;
+ Avatar = u.Avatar;
+ FullName = u.FullName;
+ JID = u.JID;
+ MessagesCount = u.MessagesCount;
+ AuthHash = u.AuthHash;
+ Banned = u.Banned;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof User && ((User) obj).UID == this.UID);
+ }
+}
--
cgit v1.2.3
From a5766d12d6dbd80a44d6d1deee4d454016b37079 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 26 Oct 2015 17:17:08 +0300
Subject: fix tags string
---
src/main/java/com/juick/Message.java | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 3d2b8227..4db2620e 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -150,23 +150,25 @@ public class Message {
public String getTagsString() {
String ret = "";
- for (int i = 0; i < Tags.size(); i++) {
- ret += " *" + Tags.get(i);
- }
- if (FriendsOnly) {
- ret += " *friends";
- }
- if (Privacy == -2) {
- ret += " *private";
- }
- if (Privacy == -1) {
- ret += " *friends";
- }
- if (Privacy == 2) {
- ret += " *public";
- }
- if (ReadOnly) {
- ret += " *readonly";
+ if (!Tags.isEmpty()) {
+ for (int i = 0; i < Tags.size(); i++) {
+ ret += " *" + Tags.get(i);
+ }
+ if (FriendsOnly) {
+ ret += " *friends";
+ }
+ if (Privacy == -2) {
+ ret += " *private";
+ }
+ if (Privacy == -1) {
+ ret += " *friends";
+ }
+ if (Privacy == 2) {
+ ret += " *public";
+ }
+ if (ReadOnly) {
+ ret += " *readonly";
+ }
}
return ret;
}
--
cgit v1.2.3
From c3d949e11a4380a2353fca0abf12292285fde02c Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 4 Nov 2015 14:19:11 +0300
Subject: initial gson support
---
build.gradle | 1 +
src/main/java/com/juick/Message.java | 7 +++++++
src/test/java/com/juick/tests/MessageTests.java | 2 ++
3 files changed, 10 insertions(+)
(limited to 'src/main/java/com')
diff --git a/build.gradle b/build.gradle
index c973749c..397234a6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
apply plugin: "java"
dependencies {
+ compile 'com.google.code.gson:gson:2.4'
testCompile 'junit:junit:4.12'
}
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 4db2620e..c87bf445 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -17,6 +17,8 @@
*/
package com.juick;
+import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -27,8 +29,13 @@ import java.util.Date;
*/
public class Message {
+ @SerializedName("mid")
public int MID = 0;
+
+ @SerializedName("rid")
public int RID = 0;
+
+ @SerializedName("replyto")
public int ReplyTo = 0;
public String Text = null;
public User User = null;
diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java
index 47b2d13c..0392c7b3 100644
--- a/src/test/java/com/juick/tests/MessageTests.java
+++ b/src/test/java/com/juick/tests/MessageTests.java
@@ -1,3 +1,5 @@
+package com.juick.tests;
+
import static org.junit.Assert.assertEquals;
import org.junit.Test;
--
cgit v1.2.3
From 5f08b8b1cfaacf1e78c56e7752277533eb84b02e Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Wed, 4 Nov 2015 15:19:11 +0300
Subject: drop gson
---
build.gradle | 1 -
src/main/java/com/juick/Message.java | 5 -----
2 files changed, 6 deletions(-)
(limited to 'src/main/java/com')
diff --git a/build.gradle b/build.gradle
index 397234a6..c973749c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,5 @@
apply plugin: "java"
dependencies {
- compile 'com.google.code.gson:gson:2.4'
testCompile 'junit:junit:4.12'
}
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index c87bf445..7875cea7 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -17,8 +17,6 @@
*/
package com.juick;
-import com.google.gson.annotations.SerializedName;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -29,13 +27,10 @@ import java.util.Date;
*/
public class Message {
- @SerializedName("mid")
public int MID = 0;
- @SerializedName("rid")
public int RID = 0;
- @SerializedName("replyto")
public int ReplyTo = 0;
public String Text = null;
public User User = null;
--
cgit v1.2.3
From d7f4564910568e289273f575b7972a745661956d Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 10 Jan 2016 19:57:49 +0300
Subject: refactoring
---
src/main/java/com/juick/Message.java | 52 ++++++++++++++++++++++--------
src/main/java/com/juick/User.java | 62 +++++++++++++++++++++++++++++-------
2 files changed, 89 insertions(+), 25 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 7875cea7..8306dd8b 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -27,13 +27,13 @@ import java.util.Date;
*/
public class Message {
- public int MID = 0;
+ private int MID = 0;
- public int RID = 0;
+ private int RID = 0;
public int ReplyTo = 0;
public String Text = null;
- public User User = null;
+ private User User = null;
public ArrayList Tags = new ArrayList();
public Date Timestamp = null;
public String TimestampString = null;
@@ -57,11 +57,11 @@ public class Message {
}
public Message(Message msg) {
- MID = msg.MID;
- RID = msg.RID;
+ setMID(msg.getMID());
+ setRID(msg.getRID());
ReplyTo = msg.ReplyTo;
Text = msg.Text;
- User = msg.User;
+ setUser(msg.getUser());
Tags = msg.Tags;
Timestamp = msg.Timestamp;
TimestampString = msg.TimestampString;
@@ -90,7 +90,7 @@ public class Message {
return false;
}
Message jmsg = (Message) obj;
- return (this.MID == jmsg.MID && this.RID == jmsg.RID);
+ return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID());
}
public int compareTo(Object obj) throws ClassCastException {
@@ -99,16 +99,16 @@ public class Message {
}
Message jmsg = (Message) obj;
- if (this.MID != jmsg.MID) {
- if (this.MID > jmsg.MID) {
+ if (this.getMID() != jmsg.getMID()) {
+ if (this.getMID() > jmsg.getMID()) {
return -1;
} else {
return 1;
}
}
- if (this.RID != jmsg.RID) {
- if (this.RID < jmsg.RID) {
+ if (this.getRID() != jmsg.getRID()) {
+ if (this.getRID() < jmsg.getRID()) {
return -1;
} else {
return 1;
@@ -139,9 +139,9 @@ public class Message {
if (AttachmentType != null) {
String url = "http://i.juick.com/";
url += AttachmentType.equals("mp4") ? "video" : "photos-1024";
- url += "/" + MID;
- if (RID > 0) {
- url += "-" + RID;
+ url += "/" + getMID();
+ if (getRID() > 0) {
+ url += "-" + getRID();
}
url += "." + AttachmentType;
return url;
@@ -174,4 +174,28 @@ public class Message {
}
return ret;
}
+
+ public int getMID() {
+ return MID;
+ }
+
+ public void setMID(int MID) {
+ this.MID = MID;
+ }
+
+ public int getRID() {
+ return RID;
+ }
+
+ public void setRID(int RID) {
+ this.RID = RID;
+ }
+
+ public com.juick.User getUser() {
+ return User;
+ }
+
+ public void setUser(com.juick.User user) {
+ User = user;
+ }
}
diff --git a/src/main/java/com/juick/User.java b/src/main/java/com/juick/User.java
index e3fc0ae7..40a3df96 100644
--- a/src/main/java/com/juick/User.java
+++ b/src/main/java/com/juick/User.java
@@ -23,31 +23,71 @@ package com.juick;
*/
public class User {
- public int UID = 0;
- public String UName = null;
+ private int UID = 0;
+ private String UName = null;
public Object Avatar = null;
- public String FullName = null;
- public String JID = null;
+ private String FullName = null;
+ private String JID = null;
public int MessagesCount = 0;
- public String AuthHash = null;
+ private String AuthHash = null;
public boolean Banned = false;
public User() {
}
public User(User u) {
- UID = u.UID;
- UName = u.UName;
+ setUID(u.getUID());
+ setUName(u.getUName());
Avatar = u.Avatar;
- FullName = u.FullName;
- JID = u.JID;
+ setFullName(u.getFullName());
+ setJID(u.getJID());
MessagesCount = u.MessagesCount;
- AuthHash = u.AuthHash;
+ setAuthHash(u.getAuthHash());
Banned = u.Banned;
}
@Override
public boolean equals(Object obj) {
- return (obj instanceof User && ((User) obj).UID == this.UID);
+ return (obj instanceof User && ((User) obj).getUID() == this.getUID());
+ }
+
+ public int getUID() {
+ return UID;
+ }
+
+ public void setUID(int UID) {
+ this.UID = UID;
+ }
+
+ public String getUName() {
+ return UName;
+ }
+
+ public void setUName(String UName) {
+ this.UName = UName;
+ }
+
+ public String getFullName() {
+ return FullName;
+ }
+
+ public void setFullName(String fullName) {
+ FullName = fullName;
+ }
+
+ public String getJID() {
+ return JID;
+ }
+
+ public void setJID(String JID) {
+ this.JID = JID;
+ }
+
+ public String getAuthHash() {
+ return AuthHash;
+ }
+
+ public void setAuthHash(String authHash) {
+ AuthHash = authHash;
}
}
--
cgit v1.2.3
From 1df19b47f7f463e6cafa7dcf877cb42967fff166 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 10 Jan 2016 20:09:38 +0300
Subject: refactoring, part 2
---
src/main/java/com/juick/Message.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 8306dd8b..03573aed 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -32,7 +32,7 @@ public class Message {
private int RID = 0;
public int ReplyTo = 0;
- public String Text = null;
+ private String Text = null;
private User User = null;
public ArrayList Tags = new ArrayList();
public Date Timestamp = null;
@@ -60,7 +60,7 @@ public class Message {
setMID(msg.getMID());
setRID(msg.getRID());
ReplyTo = msg.ReplyTo;
- Text = msg.Text;
+ setText(msg.getText());
setUser(msg.getUser());
Tags = msg.Tags;
Timestamp = msg.Timestamp;
@@ -198,4 +198,12 @@ public class Message {
public void setUser(com.juick.User user) {
User = user;
}
+
+ public String getText() {
+ return Text;
+ }
+
+ public void setText(String text) {
+ Text = text;
+ }
}
--
cgit v1.2.3
From a4eb42bf34b42d0abb0ed0bf2619a0ba96edd0d8 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 17:37:02 +0300
Subject: fix possible NPE
---
src/main/java/com/juick/Message.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 03573aed..ea1d550b 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -81,7 +81,9 @@ public class Message {
}
public void parseTags(String strTags) {
- Tags.addAll(Arrays.asList(strTags.split(" ")));
+ if (strTags != null) {
+ Tags.addAll(Arrays.asList(strTags.split(" ")));
+ }
}
@Override
--
cgit v1.2.3
From 39ec74abe77cdab5aa8f50c2524e6f71c2dbbd01 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 16 Jan 2016 18:23:47 +0300
Subject: get date
---
src/main/java/com/juick/Message.java | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index ea1d550b..003622ec 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -35,8 +35,7 @@ public class Message {
private String Text = null;
private User User = null;
public ArrayList Tags = new ArrayList();
- public Date Timestamp = null;
- public String TimestampString = null;
+ private Date date = null;
public int TimeAgo = 0;
public int Privacy = 1;
public boolean FriendsOnly = false;
@@ -63,8 +62,7 @@ public class Message {
setText(msg.getText());
setUser(msg.getUser());
Tags = msg.Tags;
- Timestamp = msg.Timestamp;
- TimestampString = msg.TimestampString;
+ setDate(msg.getDate());
TimeAgo = msg.TimeAgo;
Privacy = msg.Privacy;
FriendsOnly = msg.FriendsOnly;
@@ -208,4 +206,13 @@ public class Message {
public void setText(String text) {
Text = text;
}
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+
+ this.date = date;
+ }
}
--
cgit v1.2.3
From e001fdc08bc50d73b2920bb96e85c481bdee1c1f Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 8 Feb 2016 20:44:19 +0300
Subject: add pm and recommendations
---
src/main/java/com/juick/Message.java | 27 ++++++++++++++++++++++-----
src/main/java/com/juick/PM.java | 16 ++++++++++++++++
src/main/java/com/juick/Recommendation.java | 16 ++++++++++++++++
3 files changed, 54 insertions(+), 5 deletions(-)
create mode 100644 src/main/java/com/juick/PM.java
create mode 100644 src/main/java/com/juick/Recommendation.java
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 003622ec..c6e10214 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -17,9 +17,7 @@
*/
package com.juick;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
+import java.util.*;
/**
*
@@ -34,7 +32,7 @@ public class Message {
public int ReplyTo = 0;
private String Text = null;
private User User = null;
- public ArrayList Tags = new ArrayList();
+ public List Tags = new ArrayList<>();
private Date date = null;
public int TimeAgo = 0;
public int Privacy = 1;
@@ -50,7 +48,9 @@ public class Message {
public Place Place = null;
public int Likes = 0;
public boolean UserLike = false;
- public ArrayList childs = new ArrayList();
+ public ArrayList childs = new ArrayList<>();
+ private Optional PM = Optional.empty();
+ Optional Recommendation = Optional.empty();
public Message() {
}
@@ -76,6 +76,8 @@ public class Message {
Likes = msg.Likes;
UserLike = msg.UserLike;
childs = msg.childs;
+ PM = msg.PM;
+ Recommendation = msg.Recommendation;
}
public void parseTags(String strTags) {
@@ -215,4 +217,19 @@ public class Message {
this.date = date;
}
+
+ public Optional getPM() {
+ return PM;
+ }
+
+ public void setPM(com.juick.PM PM) {
+ this.PM = Optional.ofNullable(PM);
+ }
+
+ public Optional getRecommendation() {
+ return Recommendation;
+ }
+ public void setRecommendation(Recommendation recommendation) {
+ this.Recommendation = Optional.ofNullable(recommendation);
+ }
}
diff --git a/src/main/java/com/juick/PM.java b/src/main/java/com/juick/PM.java
new file mode 100644
index 00000000..658cafc9
--- /dev/null
+++ b/src/main/java/com/juick/PM.java
@@ -0,0 +1,16 @@
+package com.juick;
+
+/**
+ * Created by vt on 08/02/16.
+ */
+public class PM {
+ private User to;
+
+ public User getTo() {
+ return to;
+ }
+
+ public PM(User to) {
+ this.to = to;
+ }
+}
diff --git a/src/main/java/com/juick/Recommendation.java b/src/main/java/com/juick/Recommendation.java
new file mode 100644
index 00000000..4cfa67c2
--- /dev/null
+++ b/src/main/java/com/juick/Recommendation.java
@@ -0,0 +1,16 @@
+package com.juick;
+
+/**
+ * Created by vt on 08/02/16.
+ */
+public class Recommendation {
+ User from;
+
+ public User getFrom() {
+ return from;
+ }
+
+ public Recommendation(User from) {
+ this.from = from;
+ }
+}
--
cgit v1.2.3
From c84041327cbac8d67fd75ff4c223cf43f7fc73e7 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 8 Feb 2016 21:15:49 +0300
Subject: cleanup
---
src/main/java/com/juick/Message.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index c6e10214..10f7c698 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -33,7 +33,7 @@ public class Message {
private String Text = null;
private User User = null;
public List Tags = new ArrayList<>();
- private Date date = null;
+ private Date date;
public int TimeAgo = 0;
public int Privacy = 1;
public boolean FriendsOnly = false;
@@ -48,7 +48,7 @@ public class Message {
public Place Place = null;
public int Likes = 0;
public boolean UserLike = false;
- public ArrayList childs = new ArrayList<>();
+ public List childs = new ArrayList<>();
private Optional PM = Optional.empty();
Optional Recommendation = Optional.empty();
@@ -122,16 +122,16 @@ public class Message {
public int getChildsCount() {
int cnt = childs.size();
- for (int i = 0; i < childs.size(); i++) {
- cnt += childs.get(i).getChildsCount();
+ for (Message child : childs) {
+ cnt += child.getChildsCount();
}
return cnt;
}
public void cleanupChilds() {
if (!childs.isEmpty()) {
- for (int i = 0; i < childs.size(); i++) {
- childs.get(i).cleanupChilds();
+ for (Message child : childs) {
+ child.cleanupChilds();
}
childs.clear();
}
--
cgit v1.2.3
From d23e7fff4da9bbfd7ee85ff34c78de631d55c4a5 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 26 Feb 2016 17:04:42 +0300
Subject: Message is Comparable
---
src/main/java/com/juick/Message.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 10f7c698..263a247d 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -23,7 +23,7 @@ import java.util.*;
*
* @author Ugnich Anton
*/
-public class Message {
+public class Message implements Comparable {
private int MID = 0;
@@ -95,6 +95,7 @@ public class Message {
return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID());
}
+ @Override
public int compareTo(Object obj) throws ClassCastException {
if (!(obj instanceof Message)) {
throw new ClassCastException();
--
cgit v1.2.3
From 80cd101bf9291cd9e8b1a883e3148ff95c445cc1 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 8 Apr 2016 16:22:07 +0300
Subject: encapsulate some properties
---
src/main/java/com/juick/Message.java | 18 +++++++++++++-----
src/main/java/com/juick/User.java | 24 ++++++++++++++++++++----
2 files changed, 33 insertions(+), 9 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index 263a247d..c128b4f2 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -47,10 +47,10 @@ public class Message implements Comparable {
public String Video = null;
public Place Place = null;
public int Likes = 0;
- public boolean UserLike = false;
+ private boolean liked = false;
public List childs = new ArrayList<>();
private Optional PM = Optional.empty();
- Optional Recommendation = Optional.empty();
+ private Optional Recommendation = Optional.empty();
public Message() {
}
@@ -74,7 +74,7 @@ public class Message implements Comparable {
Video = msg.Video;
Place = msg.Place;
Likes = msg.Likes;
- UserLike = msg.UserLike;
+ setLiked(msg.isLiked());
childs = msg.childs;
PM = msg.PM;
Recommendation = msg.Recommendation;
@@ -156,8 +156,8 @@ public class Message implements Comparable {
public String getTagsString() {
String ret = "";
if (!Tags.isEmpty()) {
- for (int i = 0; i < Tags.size(); i++) {
- ret += " *" + Tags.get(i);
+ for (String Tag : Tags) {
+ ret += " *" + Tag;
}
if (FriendsOnly) {
ret += " *friends";
@@ -233,4 +233,12 @@ public class Message implements Comparable {
public void setRecommendation(Recommendation recommendation) {
this.Recommendation = Optional.ofNullable(recommendation);
}
+
+ public boolean isLiked() {
+ return liked;
+ }
+
+ public void setLiked(boolean liked) {
+ this.liked = liked;
+ }
}
diff --git a/src/main/java/com/juick/User.java b/src/main/java/com/juick/User.java
index 40a3df96..13df2058 100644
--- a/src/main/java/com/juick/User.java
+++ b/src/main/java/com/juick/User.java
@@ -28,9 +28,9 @@ public class User {
public Object Avatar = null;
private String FullName = null;
private String JID = null;
- public int MessagesCount = 0;
+ private int unreadCount;
private String AuthHash = null;
- public boolean Banned = false;
+ private boolean banned = false;
public User() {
}
@@ -41,9 +41,9 @@ public class User {
Avatar = u.Avatar;
setFullName(u.getFullName());
setJID(u.getJID());
- MessagesCount = u.MessagesCount;
+ setUnreadCount(u.getUnreadCount());
setAuthHash(u.getAuthHash());
- Banned = u.Banned;
+ setBanned(u.isBanned());
}
@Override
@@ -90,4 +90,20 @@ public class User {
public void setAuthHash(String authHash) {
AuthHash = authHash;
}
+
+ public int getUnreadCount() {
+ return unreadCount;
+ }
+
+ public void setUnreadCount(int unreadCount) {
+ this.unreadCount = unreadCount;
+ }
+
+ public boolean isBanned() {
+ return banned;
+ }
+
+ public void setBanned(boolean banned) {
+ this.banned = banned;
+ }
}
--
cgit v1.2.3
From 277077cd978b708f6cdcf9132154342d17978c55 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 22 Apr 2016 16:41:31 +0300
Subject: fix tag equality
---
src/main/java/com/juick/Tag.java | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'src/main/java/com')
diff --git a/src/main/java/com/juick/Tag.java b/src/main/java/com/juick/Tag.java
index 3cee3358..119aad99 100644
--- a/src/main/java/com/juick/Tag.java
+++ b/src/main/java/com/juick/Tag.java
@@ -17,11 +17,13 @@
*/
package com.juick;
+import java.util.Objects;
+
/**
*
* @author Ugnich Anton
*/
-public class Tag implements Comparable {
+public class Tag {
public String Name = null;
public int TID = 0;
@@ -29,7 +31,11 @@ public class Tag implements Comparable {
public int UsageCnt = 0;
@Override
- public int compareTo(Tag o) {
- return this.Name.compareTo(o.Name);
+ public boolean equals(Object o) {
+ boolean equal = false;
+ if (o != null && o instanceof Tag) {
+ equal = Objects.equals(Name, ((Tag) o).Name);
+ }
+ return equal;
}
}
--
cgit v1.2.3
From fb4dfa3fbc04e44e808bbd4d1ad764fa979bb3ca Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Fri, 22 Apr 2016 16:59:50 +0300
Subject: drop tags parser
---
build.gradle | 6 +-----
src/main/java/com/juick/Message.java | 6 ------
src/test/java/com/juick/tests/MessageTests.java | 18 ------------------
3 files changed, 1 insertion(+), 29 deletions(-)
delete mode 100644 src/test/java/com/juick/tests/MessageTests.java
(limited to 'src/main/java/com')
diff --git a/build.gradle b/build.gradle
index c973749c..e9bf9cdc 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1 @@
-apply plugin: "java"
-
-dependencies {
- testCompile 'junit:junit:4.12'
-}
+apply plugin: "java"
\ No newline at end of file
diff --git a/src/main/java/com/juick/Message.java b/src/main/java/com/juick/Message.java
index c128b4f2..1a690106 100644
--- a/src/main/java/com/juick/Message.java
+++ b/src/main/java/com/juick/Message.java
@@ -80,12 +80,6 @@ public class Message implements Comparable {
Recommendation = msg.Recommendation;
}
- public void parseTags(String strTags) {
- if (strTags != null) {
- Tags.addAll(Arrays.asList(strTags.split(" ")));
- }
- }
-
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Message)) {
diff --git a/src/test/java/com/juick/tests/MessageTests.java b/src/test/java/com/juick/tests/MessageTests.java
deleted file mode 100644
index 0392c7b3..00000000
--- a/src/test/java/com/juick/tests/MessageTests.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.juick.tests;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-import com.juick.Message;
-
-public class MessageTests {
- @Test
- public void messageTagsParser() {
- Message msg = new Message();
- msg.parseTags("test test" + (char)0xA0 + "2 test3");
- assertEquals("First tag must be", "test", msg.Tags.get(0));
- assertEquals("Third tag must be", "test3", msg.Tags.get(2));
- assertEquals("Count of tags must be", 3, msg.Tags.size());
- }
-}
\ No newline at end of file
--
cgit v1.2.3