aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/entities
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-01-24 23:58:51 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-01-24 23:58:51 +0100
commitdf9dcb1060d44a719e2892446b62cde884a880cf (patch)
treeed3bf01c8f249162018b33460f81b52ac2f618fb /src/de/gultsch/chat/entities
parentb273390e26e1d28f6df01fb421d8554cb7588a58 (diff)
basic persistance layer. refactor some parts of the conversation activity
Diffstat (limited to '')
-rw-r--r--src/de/gultsch/chat/entities/Account.java11
-rw-r--r--src/de/gultsch/chat/entities/Contact.java (renamed from src/de/gultsch/chat/Contact.java)2
-rw-r--r--src/de/gultsch/chat/entities/Conversation.java99
-rw-r--r--src/de/gultsch/chat/entities/Message.java (renamed from src/de/gultsch/chat/Message.java)2
4 files changed, 112 insertions, 2 deletions
diff --git a/src/de/gultsch/chat/entities/Account.java b/src/de/gultsch/chat/entities/Account.java
new file mode 100644
index 00000000..f1e15f0b
--- /dev/null
+++ b/src/de/gultsch/chat/entities/Account.java
@@ -0,0 +1,11 @@
+package de.gultsch.chat.entities;
+
+public class Account {
+
+ private String uuid;
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+}
diff --git a/src/de/gultsch/chat/Contact.java b/src/de/gultsch/chat/entities/Contact.java
index 64204461..30dfc05b 100644
--- a/src/de/gultsch/chat/Contact.java
+++ b/src/de/gultsch/chat/entities/Contact.java
@@ -1,4 +1,4 @@
-package de.gultsch.chat;
+package de.gultsch.chat.entities;
import java.io.Serializable;
diff --git a/src/de/gultsch/chat/entities/Conversation.java b/src/de/gultsch/chat/entities/Conversation.java
new file mode 100644
index 00000000..92d5bcba
--- /dev/null
+++ b/src/de/gultsch/chat/entities/Conversation.java
@@ -0,0 +1,99 @@
+package de.gultsch.chat.entities;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.UUID;
+
+import android.content.ContentValues;
+import android.database.Cursor;
+import android.net.Uri;
+
+public class Conversation implements Serializable {
+
+ private static final long serialVersionUID = -6727528868973996739L;
+ public static final int STATUS_AVAILABLE = 0;
+ public static final int STATUS_ARCHIVED = 1;
+ public static final int STATUS_DELETED = 2;
+ private String uuid;
+ private String name;
+ private String profilePhotoUri;
+ private String accountUuid;
+ private String contactJid;
+ private int status;
+
+ // legacy. to be removed
+ private ArrayList<Message> msgs = new ArrayList<Message>();
+
+ public Conversation(String name, Uri profilePhoto, Account account,
+ String contactJid) {
+ this(UUID.randomUUID().toString(), name, profilePhoto.toString(),
+ account.getUuid(), contactJid, STATUS_AVAILABLE);
+ }
+
+ public Conversation(String uuid, String name, String profilePhoto,
+ String accountUuid, String contactJid, int status) {
+ this.uuid = uuid;
+ this.name = name;
+ this.profilePhotoUri = profilePhoto;
+ this.accountUuid = accountUuid;
+ this.contactJid = contactJid;
+ this.status = status;
+ }
+
+ public ArrayList<Message> getLastMessages(int count, int offset) {
+ msgs.add(new Message("this is my last message"));
+ return msgs;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public String getProfilePhotoString() {
+ return this.profilePhotoUri;
+ }
+
+ public String getAccountUuid() {
+ return this.accountUuid;
+ }
+
+ public String getContactJid() {
+ return this.contactJid;
+ }
+
+ public Uri getProfilePhotoUri() {
+ if (this.profilePhotoUri != null) {
+ return Uri.parse(profilePhotoUri);
+ }
+ return null;
+ }
+
+ public int getStatus() {
+ return this.status;
+ }
+
+ public ContentValues getContentValues() {
+ ContentValues values = new ContentValues();
+ values.put("uuid", this.uuid);
+ values.put("name", this.name);
+ values.put("profilePhotoUri", this.profilePhotoUri);
+ values.put("accountUuid", this.accountUuid);
+ values.put("contactJid", this.contactJid);
+ values.put("status", this.status);
+ return values;
+ }
+
+ public static Conversation fromCursor(Cursor cursor) {
+ return new Conversation(
+ cursor.getString(cursor.getColumnIndex("uuid")),
+ cursor.getString(cursor.getColumnIndex("name")),
+ cursor.getString(cursor.getColumnIndex("profilePhotoUri")),
+ cursor.getString(cursor.getColumnIndex("accountUuid")),
+ cursor.getString(cursor.getColumnIndex("contactJid")),
+ cursor.getInt(cursor.getColumnIndex("status")));
+ }
+}
diff --git a/src/de/gultsch/chat/Message.java b/src/de/gultsch/chat/entities/Message.java
index b4e5e7ca..3b4e2115 100644
--- a/src/de/gultsch/chat/Message.java
+++ b/src/de/gultsch/chat/entities/Message.java
@@ -1,4 +1,4 @@
-package de.gultsch.chat;
+package de.gultsch.chat.entities;
public class Message {