use of com.xabber.android.data.account.AccountManager in project xabber-android by redsolution.
the class ClientStateManager method sendClientState.
protected static void sendClientState(PlainStreamElement element) {
AccountManager accountManager = AccountManager.getInstance();
for (String accountName : accountManager.getAccounts()) {
AccountItem account = accountManager.getAccount(accountName);
if (account == null) {
continue;
}
ConnectionThread connectionThread = account.getConnectionThread();
if (connectionThread == null) {
continue;
}
AbstractXMPPConnection xmppConnection = connectionThread.getXMPPConnection();
if (xmppConnection == null) {
continue;
}
if (xmppConnection.hasFeature("csi", ClientStateIndication.NAMESPACE))
try {
xmppConnection.send(element);
} catch (SmackException.NotConnectedException e) {
// not connected
}
}
}
use of com.xabber.android.data.account.AccountManager in project xabber-android by redsolution.
the class AccountChooseAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View view;
final AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = activity.getLayoutInflater().inflate(R.layout.account_choose_item, parent, false);
} else {
view = convertView;
}
final String account = (String) getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
return view;
}
use of com.xabber.android.data.account.AccountManager in project xabber-android by redsolution.
the class AccountListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = getActivity().getLayoutInflater().inflate(R.layout.account_list_item, parent, false);
} else {
view = convertView;
}
final String account = getItem(position);
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(ColorManager.getInstance().getAccountPainter().getAccountMainColor(account)));
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager.getVerboseName(account));
SwitchCompat accountSwitch = (SwitchCompat) view.findViewById(R.id.account_switch);
final AccountItem accountItem = accountManager.getAccount(account);
accountSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
AccountManager.getInstance().setEnabled(account, isChecked);
}
});
ConnectionState state;
if (accountItem == null) {
state = ConnectionState.offline;
accountSwitch.setChecked(false);
} else {
state = accountItem.getState();
accountSwitch.setChecked(accountItem.isEnabled());
}
((TextView) view.findViewById(R.id.status)).setText(getActivity().getString(state.getStringId()));
return view;
}
use of com.xabber.android.data.account.AccountManager in project xabber-android by redsolution.
the class ConnectionManager method updateConnections.
/**
* Update connection state.
* <p/>
* Start connections in waiting states and stop invalidated connections.
*
* @param userRequest
*/
public void updateConnections(boolean userRequest) {
LogManager.i(this, "updateConnections");
AccountManager accountManager = AccountManager.getInstance();
for (String account : accountManager.getAccounts()) {
final ConnectionItem connectionItem = accountManager.getAccount(account);
if (connectionItem.updateConnection(userRequest)) {
AccountManager.getInstance().onAccountChanged(account);
}
}
}
use of com.xabber.android.data.account.AccountManager in project xabber-android by redsolution.
the class ConnectionManager method forceReconnect.
/**
* Disconnect and connect using new network.
*/
public void forceReconnect() {
LogManager.i(this, "forceReconnect");
AccountManager accountManager = AccountManager.getInstance();
for (String account : accountManager.getAccounts()) {
accountManager.getAccount(account).forceReconnect();
AccountManager.getInstance().onAccountChanged(account);
}
}
Aggregations