use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatActivity method createSpecificChatIntent.
public static Intent createSpecificChatIntent(Context context, AccountJid account, UserJid user) {
Intent intent = new EntityIntentBuilder(context, ChatActivity.class).setAccount(account).setUser(user).build();
intent.setAction(ACTION_SPECIFIC_CHAT);
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
intent.putExtra(KEY_SHOW_ARCHIVED, chat != null && chat.isArchived());
return intent;
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ContactListActivity method openChat.
/**
* Open chat with specified contact.
* <p/>
* Show dialog to choose account if necessary.
*
* @param user
* @param text can be <code>null</code>.
*/
private void openChat(UserJid user, String text) {
UserJid bareAddress = user.getBareUserJid();
ArrayList<BaseEntity> entities = new ArrayList<>();
for (AbstractChat check : MessageManager.getInstance().getChats()) {
if (check.isActive() && check.getUser().equals(bareAddress)) {
entities.add(check);
}
}
if (entities.size() == 1) {
openChat(entities.get(0), text);
return;
}
entities.clear();
Collection<AccountJid> enabledAccounts = AccountManager.getInstance().getEnabledAccounts();
RosterManager rosterManager = RosterManager.getInstance();
for (AccountJid accountJid : enabledAccounts) {
RosterContact rosterContact = rosterManager.getRosterContact(accountJid, user);
if (rosterContact != null && rosterContact.isEnabled()) {
entities.add(rosterContact);
}
}
if (entities.size() == 1) {
openChat(entities.get(0), text);
return;
}
if (enabledAccounts.isEmpty()) {
return;
}
if (enabledAccounts.size() == 1) {
openChat(rosterManager.getBestContact(enabledAccounts.iterator().next(), bareAddress), text);
return;
}
AccountChooseDialogFragment.newInstance(bareAddress, text).show(getFragmentManager(), "OPEN_WITH_ACCOUNT");
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class OccupantListActivity method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
com.xabber.android.data.extension.muc.Occupant occupant = (com.xabber.android.data.extension.muc.Occupant) listAdapter.getItem(position);
LogManager.i(this, occupant.getNickname().toString());
UserJid occupantFullJid = null;
try {
occupantFullJid = UserJid.from(JidCreate.entityFullFrom(room, occupant.getNickname()));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
return;
}
final AbstractChat mucPrivateChat;
try {
mucPrivateChat = MessageManager.getInstance().getOrCreatePrivateMucChat(account, occupantFullJid.getJid().asFullJidIfPossible());
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
return;
}
mucPrivateChat.setIsPrivateMucChatAccepted(true);
startActivity(ChatActivity.createSpecificChatIntent(this, account, occupantFullJid));
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ContactListPresenter method getAllChatsSize.
public int getAllChatsSize() {
Collection<AbstractChat> chats = MessageManager.getInstance().getChatsOfEnabledAccount();
GroupConfiguration chatsGroup = getChatsGroup(chats, ChatListState.all);
return chatsGroup.getTotal();
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ContactListPresenter method getTwoNextRecentChat.
public ArrayList<IFlexible> getTwoNextRecentChat() {
Collection<AbstractChat> chats = MessageManager.getInstance().getChatsOfEnabledAccount();
GroupConfiguration chatsGroup = getChatsGroup(chats, currentChatsState);
ArrayList<AbstractContact> contacts = (ArrayList<AbstractContact>) chatsGroup.getAbstractContacts();
ArrayList<IFlexible> items = new ArrayList<>();
if (contacts != null && contacts.size() >= MAX_RECENT_ITEMS) {
items.add(ChatVO.convert(contacts.get(MAX_RECENT_ITEMS - 2), this, null));
if (getAllChatsSize() > MAX_RECENT_ITEMS)
items.add(ChatWithButtonVO.convert(contacts.get(MAX_RECENT_ITEMS - 1), this));
else
items.add(ChatVO.convert(contacts.get(MAX_RECENT_ITEMS - 1), this));
}
return items;
}
Aggregations