use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class XabberAccountManager method isAccountSynchronize.
public boolean isAccountSynchronize(String jid) {
boolean syncNotAllowed = false;
AccountJid accountJid = getExistingAccount(jid);
if (accountJid != null) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem != null)
syncNotAllowed = accountItem.isSyncNotAllowed();
}
if (accountsSyncState.containsKey(jid) && !syncNotAllowed)
return accountsSyncState.get(jid);
else
return false;
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class XMPPListPreference method update.
private void update() {
List<AccountItem> accountItems = new ArrayList<>();
for (AccountItem accountItem : AccountManager.getInstance().getAllAccountItems()) {
accountItems.add(accountItem);
}
accountListAdapter.setAccountItems(accountItems);
if (accountItems.size() > 1)
rlReorder.setVisibility(View.VISIBLE);
else
rlReorder.setVisibility(View.GONE);
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class AccountListReorderAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final AccountListReorderAdapter.AccountViewHolder accountHolder = (AccountListReorderAdapter.AccountViewHolder) holder;
AccountItem accountItem = accountItems.get(position);
accountHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(accountItem.getAccount()));
accountHolder.avatar.setBorderColor(ColorManager.getInstance().getAccountPainter().getAccountMainColor(accountItem.getAccount()));
accountHolder.name.setText(AccountManager.getInstance().getVerboseName(accountItem.getAccount()));
accountHolder.status.setText(accountItem.getState().getStringId());
accountHolder.ivAnchor.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
listener.onStartDrag(accountHolder);
}
return false;
}
});
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class VCardManager method getVCard.
@SuppressWarnings("WeakerAccess")
void getVCard(final AccountJid account, final Jid srcUser) {
final AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
onVCardFailed(account, srcUser);
return;
}
final CustomVCardManager vCardManager = CustomVCardManager.getInstanceFor(accountItem.getConnection());
if (!accountItem.getConnection().isAuthenticated()) {
onVCardFailed(account, srcUser);
return;
}
Collection<UserJid> blockedContacts = BlockingManager.getInstance().getBlockedContacts(account);
for (UserJid blockedContact : blockedContacts) {
if (blockedContact.getBareJid().equals(srcUser.asBareJid())) {
return;
}
}
final EntityBareJid entityBareJid = srcUser.asEntityBareJidIfPossible();
if (entityBareJid != null) {
vCardRequests.add(srcUser);
try {
vCardManager.sendVCardRequest(srcUser);
} catch (SmackException.NotConnectedException e) {
LogManager.exception(this, e);
LogManager.w(this, "Error getting vCard: " + e.getMessage());
} catch (ClassCastException e) {
LogManager.exception(this, e);
// http://stackoverflow.com/questions/31498721/error-loading-vcard-information-using-smack-emptyresultiq-cannot-be-cast-to-or
LogManager.w(this, "ClassCastException: " + e.getMessage());
// vCard = new VCard();
} catch (InterruptedException e) {
LogManager.exception(this, e);
}
vCardRequests.remove(srcUser);
}
}
use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.
the class PrivateStorageManager method getPrivateData.
@Nullable
private PrivateData getPrivateData(AccountJid accountJid, String namespace, String elementName) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem == null || !accountItem.isEnabled())
return null;
XMPPTCPConnection connection = accountItem.getConnection();
PrivateDataManager privateDataManager = PrivateDataManager.getInstanceFor(connection);
try {
if (!privateDataManager.isSupported())
return null;
return privateDataManager.getPrivateData(elementName, namespace);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | IllegalArgumentException e) {
e.printStackTrace();
return null;
}
}
Aggregations