public boolean isAutomatedMessage() { return getAutomated(); }
public boolean isOutgoingMessage() { // Default is true because this field is only set from the server. return getBoolean(KEY_INBOUND, true); }
public Double getCreatedAt() { return getDouble(KEY_CREATED_AT); }
@Override public synchronized void updateMessage(ApptentiveMessage apptentiveMessage) { fetchEntries(); MessageEntry entry = findMessageEntry(apptentiveMessage); if (entry != null) { entry.id = apptentiveMessage.getId(); entry.clientCreatedAt = apptentiveMessage.getClientCreatedAt(); entry.nonce = apptentiveMessage.getNonce(); entry.state = apptentiveMessage.getState().name(); if (apptentiveMessage.isRead()) { // A apptentiveMessage can't be unread after being read. entry.isRead = true; } entry.json = apptentiveMessage.getJsonObject().toString(); writeToFile(); } }
if (!uniqueNonce.add(((ApptentiveMessage) message).getNonce())) { listItemIterator.remove(); messageCenterRecyclerViewAdapter.notifyItemRemoved(adapterMessagePosition); Double sentOrReceivedAt = apptentiveMessage.getCreatedAt(); String dateStamp = createDatestamp(sentOrReceivedAt); if (dateStamp != null) { if (dateStampsSeen.add(dateStamp)) { if (apptentiveMessage.setDatestamp(dateStamp)) { messageCenterRecyclerViewAdapter.notifyItemChanged(adapterMessagePosition); if (apptentiveMessage.clearDatestamp()) { messageCenterRecyclerViewAdapter.notifyItemChanged(adapterMessagePosition); if (apptentiveMessage.isOutgoingMessage()) { if (sentOrReceivedAt != null && sentOrReceivedAt > Double.MIN_VALUE) { lastSent = (MessageCenterUtil.CompoundMessageCommonInterface) apptentiveMessage;
MessageCenterListItem message = fragment.listItems.get(i); if (message instanceof ApptentiveMessage) { String nonce = ((ApptentiveMessage) message).getNonce(); if (nonce != null) { String sentNonce = apptentiveMessage.getNonce(); if (sentNonce != null && nonce.equals(sentNonce)) { ((ApptentiveMessage) message).setCreatedAt(apptentiveMessage.getCreatedAt()); fragment.messageCenterRecyclerViewAdapter.notifyItemChanged(i); break; if (lastItem != null && lastItem.getListItemType() == MESSAGE_OUTGOING) { ApptentiveMessage apptentiveMessage = (ApptentiveMessage) lastItem; if (apptentiveMessage.isOutgoingMessage()) { Double createdTime = apptentiveMessage.getCreatedAt(); if (createdTime != null && createdTime > Double.MIN_VALUE) { MessageCenterStatus status = fragment.interaction.getRegularStatus();
public void setSenderId(String senderId) { try { JSONObject sender; if (!isNull((KEY_SENDER))) { sender = getJSONObject(KEY_SENDER); } else { sender = new JSONObject(); put(KEY_SENDER, sender); } sender.put(KEY_SENDER_ID, senderId); } catch (JSONException e) { ApptentiveLog.e(e, "Exception setting ApptentiveMessage's %s field.", KEY_SENDER_ID); logException(e); } }
@Override protected Void doInBackground(ApptentiveMessage... messages) { final ApptentiveMessage message = messages[0]; message.setRead(true); JSONObject data = new JSONObject(); try { data.put("message_id", message.getId()); data.put("message_type", message.getMessageType().name()); } catch (JSONException e) { logException(e); } fragment.engageInternal(MessageCenterInteraction.EVENT_NAME_READ, data.toString()); dispatchConversationTask(new ConversationDispatchTask() { @Override protected boolean execute(Conversation conversation) { MessageManager mgr = conversation.getMessageManager(); if (mgr != null) { mgr.updateMessage(message); mgr.notifyHostUnreadMessagesListeners(mgr.getUnreadMessageCount()); } return false; } }, "update message"); return null; }
if (apptentiveMessage.isOutgoingMessage()) { apptentiveMessage.setRead(true); } else { if (messageOnToast == null) { if (apptentiveMessage.getMessageType() == ApptentiveMessage.Type.CompoundMessage) { messageOnToast = (CompoundMessage) apptentiveMessage;
public String getSenderProfilePhoto() { try { if (!isNull((KEY_SENDER))) { JSONObject sender = getJSONObject(KEY_SENDER); if (!sender.isNull((KEY_SENDER_PROFILE_PHOTO))) { return sender.getString(KEY_SENDER_PROFILE_PHOTO); } } } catch (JSONException e) { logException(e); } return null; }
public void setPaused(boolean paused) { if (isPaused ^ paused) { // Invalidate any unsent messages, as these will have status and progress bars that need to change. for (int i = 0; i < listItems.size(); i++) { MessageCenterListItem item = listItems.get(i); if (item instanceof ApptentiveMessage) { ApptentiveMessage message = (ApptentiveMessage) item; if (message.isOutgoingMessage() && message.getCreatedAt() == null) { messageCenterRecyclerViewAdapter.notifyItemChanged(i); } } } } isPaused = paused; }
@Override public synchronized void addOrUpdateMessages(ApptentiveMessage... apptentiveMessages) { fetchEntries(); for (ApptentiveMessage apptentiveMessage : apptentiveMessages) { MessageEntry existing = findMessageEntry(apptentiveMessage); if (existing != null) { // Update existing.id = apptentiveMessage.getId(); existing.state = apptentiveMessage.getState().name(); if (apptentiveMessage.isRead()) { // A message can't be unread after being read. existing.isRead = true; } existing.json = apptentiveMessage.getJsonObject().toString(); } else { // Insert MessageEntry entry = new MessageEntry(); entry.id = apptentiveMessage.getId(); entry.clientCreatedAt = apptentiveMessage.getClientCreatedAt(); entry.nonce = apptentiveMessage.getNonce(); entry.state = apptentiveMessage.getState().name(); entry.isRead = apptentiveMessage.isRead(); entry.json = apptentiveMessage.getJsonObject().toString(); messageEntries.add(entry); } } writeToFile(); }
public String getSenderUsername() { try { if (!isNull((KEY_SENDER))) { JSONObject sender = getJSONObject(KEY_SENDER); if (!sender.isNull((KEY_SENDER_NAME))) { return sender.getString(KEY_SENDER_NAME); } } } catch (JSONException e) { logException(e); } return null; }
if (item instanceof ApptentiveMessage) { ApptentiveMessage apptentiveMessage = (ApptentiveMessage) item; Double createdAt = apptentiveMessage.getCreatedAt(); if (apptentiveMessage.isOutgoingMessage() && createdAt == null) { unsentMessagesCount++; while (listIterator.hasNext()) { next = (ApptentiveMessage) listIterator.next(); Double nextCreatedAt = next.getCreatedAt(); if (next == null || next.getCreatedAt() == null || createdAt == null || next.getCreatedAt() <= createdAt || createdAt <= Double.MIN_VALUE) { listIterator.add(item);
public boolean getAutomated() { return getBoolean(KEY_AUTOMATED); }
public boolean isHidden() { return getBoolean(KEY_HIDDEN); }