use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class VCardManager method onStanza.
@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
if (!(connection instanceof AccountItem)) {
return;
}
AccountJid account = connection.getAccount();
if (stanza instanceof Presence && ((Presence) stanza).getType() != Presence.Type.error) {
Jid from = stanza.getFrom();
if (from == null) {
return;
}
Jid addressForVcard = from;
if (MUCManager.getInstance().hasRoom(account, from.asEntityBareJidIfPossible())) {
addressForVcard = from;
}
// Request vCard for new users
if (!names.containsKey(addressForVcard)) {
if (SettingsManager.connectionLoadVCard()) {
request(account, addressForVcard);
}
}
}
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ConferenceSelectFragment method onItemSelected.
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
AccountJid newAccount = (AccountJid) accountView.getSelectedItem();
if (account != null && account.equals(newAccount)) {
return;
}
if (account != null) {
hostedConferencesAdapter.clear();
}
account = newAccount;
listener.onAccountSelected(account);
nextButton.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountTextColor(account));
serverView.setText(getString(R.string.domen_part, account.getFullJid().getDomain().toString()));
onRequestHostedRoomsClick();
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ContactAddFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_contact_add, container, false);
if (savedInstanceState != null) {
name = savedInstanceState.getString(SAVED_NAME);
setAccount((AccountJid) savedInstanceState.getParcelable(SAVED_ACCOUNT));
setUser((UserJid) savedInstanceState.getParcelable(SAVED_USER));
} else {
if (getAccount() == null || getUser() == null) {
name = null;
} else {
name = RosterManager.getInstance().getName(getAccount(), getUser());
if (getUser().getJid().asBareJid().toString().equals(name)) {
name = null;
}
}
}
if (getAccount() == null) {
Collection<AccountJid> accounts = AccountManager.getInstance().getEnabledAccounts();
if (accounts.size() == 1) {
setAccount(accounts.iterator().next());
}
}
setUpAccountView((Spinner) view.findViewById(R.id.contact_account));
userView = (EditText) view.findViewById(R.id.contact_user);
nameView = (EditText) view.findViewById(R.id.contact_name);
if (getUser() != null) {
userView.setText(getUser().toString());
}
if (name != null) {
nameView.setText(name);
}
return view;
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class ContactAddFragment method addContact.
@Override
public void addContact() {
if (getAccount() == null) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
return;
}
String contactString = userView.getText().toString();
if (TextUtils.isEmpty(contactString)) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_USER_NAME), Toast.LENGTH_LONG).show();
return;
}
UserJid user;
try {
user = UserJid.from(contactString);
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
return;
}
LogManager.i(this, "user: " + user);
AccountJid account = (AccountJid) accountView.getSelectedItem();
if (account == null) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
return;
}
try {
RosterManager.getInstance().createContact(account, user, nameView.getText().toString(), getSelected());
PresenceManager.getInstance().requestSubscription(account, user);
MessageManager.getInstance().openChat(account, user);
} catch (SmackException.NotLoggedInException | SmackException.NotConnectedException e) {
Application.getInstance().onError(R.string.NOT_CONNECTED);
} catch (XMPPException.XMPPErrorException e) {
Application.getInstance().onError(R.string.XMPP_EXCEPTION);
} catch (SmackException.NoResponseException e) {
Application.getInstance().onError(R.string.CONNECTION_FAILED);
} catch (NetworkException e) {
Application.getInstance().onError(e);
} catch (InterruptedException e) {
LogManager.exception(this, e);
}
getActivity().finish();
}
use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.
the class RecentChatFragment 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);
}
}
Aggregations