use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.
the class RosterManager method getDisplayAuthorName.
public static String getDisplayAuthorName(MessageItem messageItem) {
UserJid jid = null;
try {
jid = UserJid.from(messageItem.getOriginalFrom());
} catch (UserJid.UserJidCreateException e) {
e.printStackTrace();
}
String author = null;
if (jid != null) {
EntityBareJid room = messageItem.getUser().getBareJid().asEntityBareJidIfPossible();
RoomChat roomChat = null;
if (room != null)
roomChat = MUCManager.getInstance().getRoomChat(messageItem.getAccount(), room);
if (roomChat != null) {
if (!messageItem.isIncoming())
author = MUCManager.getInstance().getNickname(messageItem.getAccount(), room).toString();
else
author = jid.getJid().getResourceOrEmpty().toString();
} else {
if (!messageItem.getAccount().getFullJid().asBareJid().equals(jid.getBareJid()))
author = RosterManager.getInstance().getNameOrBareJid(messageItem.getAccount(), jid);
else
author = AccountManager.getInstance().getNickName(messageItem.getAccount());
}
}
return author;
}
use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.
the class RosterManager method onPreInitialize.
public void onPreInitialize() {
List<ContactRealm> contacts = RosterCacheManager.loadContacts();
for (ContactRealm contactRealm : contacts) {
try {
AccountJid account = AccountJid.from(contactRealm.getAccount() + "/" + contactRealm.getAccountResource());
UserJid userJid = UserJid.from(contactRealm.getUser());
RosterContact contact = RosterContact.getRosterContact(account, userJid, contactRealm.getName());
for (ContactGroup group : contactRealm.getGroups()) {
contact.addGroupReference(new RosterGroupReference(new RosterGroup(account, group.getGroupName())));
}
rosterContacts.put(contact.getAccount().toString(), contact.getUser().getBareJid().toString(), contact);
MessageItem lastMessage = contactRealm.getLastMessage();
if (lastMessage != null) {
MessageManager.getInstance().getOrCreateChat(contact.getAccount(), contact.getUser(), lastMessage);
} else
MessageManager.getInstance().getOrCreateChat(contact.getAccount(), contact.getUser());
} catch (UserJid.UserJidCreateException e) {
e.printStackTrace();
} catch (XmppStringprepException e) {
e.printStackTrace();
}
}
onContactsChanged(Collections.<RosterContact>emptyList());
}
use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.
the class ContactListFragment method onContactAvatarClick.
@Override
public void onContactAvatarClick(int adapterPosition) {
IFlexible item = adapter.getItem(adapterPosition);
if (item != null && item instanceof ContactVO) {
Intent intent;
AccountJid accountJid = ((ContactVO) item).getAccountJid();
UserJid userJid = ((ContactVO) item).getUserJid();
if (MUCManager.getInstance().hasRoom(accountJid, userJid)) {
intent = ContactActivity.createIntent(getActivity(), accountJid, userJid);
} else {
intent = ContactEditActivity.createIntent(getActivity(), accountJid, userJid);
}
getActivity().startActivity(intent);
}
}
use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.
the class ContactListFragment method onItemContextMenu.
@Override
public void onItemContextMenu(int adapterPosition, ContextMenu menu) {
IFlexible item = adapter.getItem(adapterPosition);
if (item != null && item instanceof ContactVO) {
AccountJid accountJid = ((ContactVO) item).getAccountJid();
UserJid userJid = ((ContactVO) item).getUserJid();
AbstractContact abstractContact = RosterManager.getInstance().getAbstractContact(accountJid, userJid);
ContextMenuHelper.createContactContextMenu(getActivity(), presenter, abstractContact, menu);
return;
}
if (item != null && item instanceof GroupVO) {
AccountJid accountJid = ((GroupVO) item).getAccountJid();
ContextMenuHelper.createGroupContextMenu(getActivity(), presenter, accountJid, ((GroupVO) item).getGroupName(), menu);
return;
}
}
use of com.xabber.android.data.entity.UserJid in project xabber-android by redsolution.
the class BlockedListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
account = getAccount(getIntent());
if (account == null) {
finish();
return;
}
setContentView(R.layout.activity_with_toolbar_and_container);
toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
toolbar.inflateMenu(R.menu.toolbar_block_list);
toolbar.setOnMenuItemClickListener(this);
barPainter = new BarPainter(this, toolbar);
RecyclerView recyclerView = new RecyclerView(this);
((RelativeLayout) findViewById(R.id.fragment_container)).addView(recyclerView);
adapter = new BlockedListAdapter(account);
adapter.setListener(this);
if (savedInstanceState != null) {
final ArrayList<String> checkedContacts = savedInstanceState.getStringArrayList(SAVED_CHECKED_CONTACTS);
if (checkedContacts != null) {
List<UserJid> checkedJids = new ArrayList<>();
for (String contactString : checkedContacts) {
try {
checkedJids.add(UserJid.from(contactString));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
}
adapter.setCheckedContacts(checkedJids);
}
}
previousSize = -1;
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
Aggregations