use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class ChatViewer method getInitialChatFromIntent.
private void getInitialChatFromIntent() {
Intent intent = getIntent();
String account = getAccount(intent);
String user = getUser(intent);
if (account != null && user != null) {
initialChat = new BaseEntity(account, user);
}
}
use of com.xabber.android.data.entity.BaseEntity in project xabber-android by redsolution.
the class MessageManager method onSettingsChanged.
/**
* Called on action settings change.
*/
public void onSettingsChanged() {
ChatsShowStatusChange showStatusChange = SettingsManager.chatsShowStatusChange();
Collection<BaseEntity> changedEntities = new ArrayList<>();
for (AbstractChat chat : chats.values()) {
if ((chat instanceof RegularChat && showStatusChange != ChatsShowStatusChange.always) || (chat instanceof RoomChat && showStatusChange == ChatsShowStatusChange.never)) {
// Remove actions with status change.
ArrayList<MessageItem> remove = new ArrayList<>();
for (MessageItem messageItem : chat.getMessages()) {
if (messageItem.getAction() != null && messageItem.getAction().isStatusChage()) {
remove.add(messageItem);
}
}
if (remove.isEmpty()) {
continue;
}
for (MessageItem messageItem : remove) {
chat.removeMessage(messageItem);
}
changedEntities.add(chat);
}
}
RosterManager.getInstance().onContactsChanged(changedEntities);
}
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;
}
}
}
Aggregations