use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ChatSessionAdapter method getNickName.
String getNickName(String username) {
ImEntity participant = mChatSession.getParticipant();
if (mIsGroupChat) {
ChatGroup group = (ChatGroup) participant;
/**
* List<Contact> members = group.getMembers();
* for (Contact c : members) {
* if (username.equals(c.getAddress().getAddress())) {
*
* return c.getAddress().getResource();
*
* }
* }*
*/
Contact groupMember = group.getMember(username);
if (groupMember != null) {
return groupMember.getAddress().getAddress();
} else {
// not found, impossible
String[] parts = username.split("/");
return parts[parts.length - 1];
}
} else {
return ((Contact) participant).getName();
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ChatSessionAdapter method getParticipants.
public String[] getParticipants() {
if (mIsGroupChat) {
Contact self = mConnection.getLoginUser();
ChatGroup group = (ChatGroup) mChatSession.getParticipant();
List<Contact> members = group.getMembers();
String[] result = new String[members.size() - 1];
int index = 0;
for (Contact c : members) {
if (!c.equals(self)) {
result[index++] = c.getAddress().getAddress();
}
}
return result;
} else {
return new String[] { mChatSession.getParticipant().getAddress().getAddress() };
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ChatSessionAdapter method onConvertToGroupChatSuccess.
void onConvertToGroupChatSuccess(ChatGroup group) {
Contact oldParticipant = (Contact) mChatSession.getParticipant();
String oldAddress = getAddress();
// mChatSession.setParticipant(group);
mChatSessionManager.updateChatSession(oldAddress, this);
Uri oldChatUri = mChatURI;
Uri oldMessageUri = mMessageURI;
init(group, false);
// copyHistoryMessages(oldParticipant);
mContentResolver.delete(oldMessageUri, NON_CHAT_MESSAGE_SELECTION, null);
mContentResolver.delete(oldChatUri, null, null);
mListenerAdapter.notifyChatSessionConverted();
mConvertingToGroupChat = false;
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ChatSessionAdapter method init.
private void init(ChatGroup group, boolean isNewSession) {
mIsGroupChat = true;
mNickname = group.getName();
mContactId = insertOrUpdateGroupContactInDb(group);
group.addMemberListener(mListenerAdapter);
mChatSession.setMessageListener(mListenerAdapter);
try {
mChatURI = ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, mContactId);
mChatSessionManager.getChatGroupManager().joinChatGroupAsync(group.getAddress(), group.getName());
mMessageURI = Imps.Messages.getContentUriByThreadId(mContactId);
if (isNewSession)
insertOrUpdateChat("");
for (Contact c : group.getMembers()) {
mContactStatusMap.put(c.getName(), c.getPresence().getStatus());
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.
the class ContactListAdapter method getContacts.
public String[] getContacts() {
Collection<Contact> contacts = mAdaptee.getContacts();
String[] contactArray = new String[contacts.size()];
int i = 0;
for (Contact contact : contacts) contactArray[i++] = contact.getAddress().getAddress();
return contactArray;
}
Aggregations