use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class RosterManager method onContactChanged.
/**
* Notifies registered {@link OnContactChangedListener}.
*/
public static void onContactChanged(String account, String bareAddress) {
final ArrayList<BaseEntity> entities = new ArrayList<>();
entities.add(new BaseEntity(account, bareAddress));
onContactsChanged(entities);
}
use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class ContactListFragment method onCreateContextMenu.
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(info.position);
if (baseEntity instanceof AbstractContact) {
ContextMenuHelper.createContactContextMenu(getActivity(), adapter, (AbstractContact) baseEntity, menu);
} else if (baseEntity instanceof AccountConfiguration) {
ContextMenuHelper.createAccountContextMenu(getActivity(), adapter, baseEntity.getAccount(), menu);
} else if (baseEntity instanceof GroupConfiguration) {
ContextMenuHelper.createGroupContextMenu(getActivity(), adapter, baseEntity.getAccount(), baseEntity.getUser(), menu);
} else {
throw new IllegalStateException();
}
}
use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class ContactListFragment method scrollTo.
/**
* Scroll contact list to specified account.
*
* @param account
*/
void scrollTo(String account) {
long count = listView.getCount();
for (int position = 0; position < (int) count; position++) {
BaseEntity baseEntity = (BaseEntity) listView.getItemAtPosition(position);
if (baseEntity != null && baseEntity instanceof AccountConfiguration && baseEntity.getAccount().equals(account)) {
stopMovement();
listView.setSelection(position);
break;
}
}
}
use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class ContactList 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(String user, String text) {
String bareAddress = Jid.getBareAddress(user);
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();
for (RosterContact check : RosterManager.getInstance().getContacts()) {
if (check.isEnabled() && check.getUser().equals(bareAddress)) {
entities.add(check);
}
}
if (entities.size() == 1) {
openChat(entities.get(0), text);
return;
}
Collection<String> accounts = AccountManager.getInstance().getAccounts();
if (accounts.isEmpty()) {
return;
}
if (accounts.size() == 1) {
openChat(new BaseEntity(accounts.iterator().next(), bareAddress), text);
return;
}
AccountChooseDialogFragment.newInstance(bareAddress, text).show(getFragmentManager(), "OPEN_WITH_ACCOUNT");
}
use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class ChatViewer method restoreInstanceState.
private void restoreInstanceState(Bundle savedInstanceState) {
isRecentChatsSelected = savedInstanceState.getBoolean(SAVED_IS_RECENT_CHATS_SELECTED);
if (isRecentChatsSelected) {
selectedChat = null;
} else {
selectedChat = new BaseEntity(savedInstanceState.getString(SAVED_SELECTED_ACCOUNT), savedInstanceState.getString(SAVED_SELECTED_USER));
}
exitOnSend = savedInstanceState.getBoolean(SAVED_EXIT_ON_SEND);
String initialAccount = savedInstanceState.getString(SAVED_INITIAL_ACCOUNT);
String initialUser = savedInstanceState.getString(SAVED_INITIAL_USER);
if (initialAccount != null && initialUser != null) {
initialChat = new BaseEntity(initialAccount, initialUser);
}
}
Aggregations