Search in sources :

Example 96 with AccountItem

use of com.xabber.android.data.account.AccountItem in project xabber-android by redsolution.

the class NavigationDrawerAccountAdapter 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.contact_list_drawer_account_item, parent, false);
    } else {
        view = convertView;
    }
    AccountJid 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 accountName = (TextView) view.findViewById(R.id.name);
    try {
        accountName.setText(RosterManager.getInstance().getBestContact(account, UserJid.from(accountManager.getVerboseName(account))).getName());
    } catch (UserJid.UserJidCreateException e) {
        LogManager.exception(this, e);
    }
    accountName.setTextColor(ColorManager.getInstance().getAccountPainter().getAccountTextColor(account));
    ((TextView) view.findViewById(R.id.account_jid)).setText(accountManager.getVerboseName(account));
    AccountItem accountItem = accountManager.getAccount(account);
    ConnectionState state;
    if (accountItem == null) {
        state = ConnectionState.offline;
    } else {
        state = accountItem.getState();
    }
    ((TextView) view.findViewById(R.id.status)).setText(getActivity().getString(state.getStringId()));
    return view;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) XabberAccountManager(com.xabber.android.data.xaccount.XabberAccountManager) AccountManager(com.xabber.android.data.account.AccountManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ConnectionState(com.xabber.android.data.connection.ConnectionState) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

AccountItem (com.xabber.android.data.account.AccountItem)96 AccountJid (com.xabber.android.data.entity.AccountJid)24 UserJid (com.xabber.android.data.entity.UserJid)14 View (android.view.View)12 NetworkException (com.xabber.android.data.NetworkException)11 ArrayList (java.util.ArrayList)11 SmackException (org.jivesoftware.smack.SmackException)11 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)11 Message (org.jivesoftware.smack.packet.Message)11 Presence (org.jivesoftware.smack.packet.Presence)10 TextView (android.widget.TextView)9 XMPPException (org.jivesoftware.smack.XMPPException)9 Jid (org.jxmpp.jid.Jid)9 ImageView (android.widget.ImageView)8 StatusMode (com.xabber.android.data.account.StatusMode)6 ConnectionState (com.xabber.android.data.connection.ConnectionState)5 MessageItem (com.xabber.android.data.database.messagerealm.MessageItem)5 Realm (io.realm.Realm)5 ColorDrawable (android.graphics.drawable.ColorDrawable)4 AccountManager (com.xabber.android.data.account.AccountManager)4