package com.humbughq.android;

import org.json.JSONException;
import org.json.JSONObject;

public class Message {
    public static final int STREAM_MESSAGE = 1;
    public static final int HUDDLE_MESSAGE = 2;

    private String sender;
    private String display_recipient;
    private int type;
    private String content;
    private String subject;
    private String senderEmail;

    public Message() {
        // Default constructor
    }

    public Message(JSONObject message) throws JSONException {
        this.populate(message);
    }

    public void populate(JSONObject message) throws JSONException {
        this.setSender(message.getString("sender_full_name"));
        this.setSenderEmail(message.getString("sender_email"));
        this.setDisplayRecipient(message.getString("display_recipient"));
        if (message.getString("type").equals("stream")) {
            this.setType(Message.STREAM_MESSAGE);
        } else if (message.getString("type").equals("huddle")) {
            this.setType(Message.HUDDLE_MESSAGE);
        }
        this.setContent(message.getString("content"));
        if (this.getType() == Message.STREAM_MESSAGE) {
            this.setSubject(message.getString("subject"));
        } else {
            this.setSubject(null);
        }
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getDisplayRecipient() {
        return display_recipient;
    }

    public void setDisplayRecipient(String display_recipient) {
        this.display_recipient = display_recipient;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getSender() {
        return sender;
    }

    public void setSender(String sender) {
        this.sender = sender;
    }

    public String getSenderEmail() {
        return senderEmail;
    }

    public void setSenderEmail(String senderEmail) {
        this.senderEmail = senderEmail;
    }
}

@@ -24,16 +24,40 @@
 droid;%0A%0A
+import java.util.Date;%0A%0A
 import o
@@ -79,16 +79,16 @@
 eption;%0A
-
 import o
@@ -402,16 +402,46 @@
 erEmail;
+%0A    private Date curDateTime;
 %0A%0A    pu
@@ -1325,24 +1325,93 @@
 );%0A        %7D
+%0A%0A        this.setCurDateTime(new Date(message.getInt(%22timestamp%22)));
 %0A    %7D%0A%0A    
@@ -2295,24 +2295,24 @@
 derEmail) %7B%0A
-
         this
@@ -2344,11 +2344,179 @@
 l;%0A    %7D
+%0A%0A    public Date getCurDateTime() %7B%0A        return curDateTime;%0A    %7D%0A%0A    public void setCurDateTime(Date curDateTime) %7B%0A        this.curDateTime = curDateTime;%0A    %7D
 %0A%7D%0A

Store the timestamp in the message object.