use of cx.ring.model.HistoryCall in project ring-client-android by savoirfairelinux.
the class SmartListPresenter method modelToViewModel.
private SmartListViewModel modelToViewModel(String ringId, CallContact callContact, @NonNull List<HistoryText> lastTexts, @NonNull List<HistoryCall> lastCalls) {
HistoryText lastText = lastTexts.size() > 0 ? lastTexts.get(0) : null;
HistoryCall lastCall = lastCalls.size() > 0 ? lastCalls.get(0) : null;
long lastInteractionLong = 0;
int lastEntryType = 0;
String lastInteraction = "";
boolean hasUnreadMessage = lastText != null && !lastText.isRead();
long lastTextTimestamp = lastText != null ? lastText.getDate() : 0;
long lastCallTimestamp = lastCall != null ? lastCall.getEndDate().getTime() : 0;
if (lastTextTimestamp > 0 && lastTextTimestamp > lastCallTimestamp) {
String msgString = lastText.getMessage();
if (msgString != null && !msgString.isEmpty() && msgString.contains("\n")) {
int lastIndexOfChar = msgString.lastIndexOf("\n");
if (lastIndexOfChar + 1 < msgString.length()) {
msgString = msgString.substring(msgString.lastIndexOf("\n") + 1);
}
}
lastInteractionLong = lastTextTimestamp;
lastEntryType = lastText.isIncoming() ? SmartListViewModel.TYPE_INCOMING_MESSAGE : SmartListViewModel.TYPE_OUTGOING_MESSAGE;
lastInteraction = msgString;
} else if (lastCallTimestamp > 0) {
lastInteractionLong = lastCallTimestamp;
lastEntryType = lastCall.isIncoming() ? SmartListViewModel.TYPE_INCOMING_CALL : SmartListViewModel.TYPE_OUTGOING_CALL;
lastInteraction = lastCall.getDurationString();
}
SmartListViewModel smartListViewModel;
mContactService.loadContactData(callContact);
smartListViewModel = new SmartListViewModel(ringId, callContact.getStatus(), callContact.getDisplayName() != null ? callContact.getDisplayName() : callContact.getUsername(), callContact.getPhoto(), lastInteractionLong, lastEntryType, lastInteraction, hasUnreadMessage);
smartListViewModel.setOnline(mPresenceService.isBuddyOnline(callContact.getIds().get(0)));
return smartListViewModel;
}
use of cx.ring.model.HistoryCall in project ring-client-android by savoirfairelinux.
the class ConversationFacade method parseHistoryCalls.
private void parseHistoryCalls(List<HistoryCall> historyCalls, boolean acceptAllMessages) {
for (HistoryCall call : historyCalls) {
CallContact contact = mContactService.findContact(call.getContactID(), call.getContactKey(), new Uri(call.getNumber()));
String key = contact.getIds().get(0);
String phone = contact.getPhones().get(0).getNumber().getRawUriString();
if (mConversationMap.containsKey(key) || mConversationMap.containsKey(phone)) {
mConversationMap.get(key).addHistoryCall(call);
} else if (acceptAllMessages) {
Conversation conversation = new Conversation(contact);
conversation.addHistoryCall(call);
mConversationMap.put(key, conversation);
}
}
}
Aggregations