Search in sources :

Example 1 with ShowOfflineMode

use of com.xabber.android.data.roster.ShowOfflineMode in project xabber-android by redsolution.

the class GroupedContactAdapter method getAccountView.

private View getAccountView(int position, View convertView, ViewGroup parent) {
    final View view;
    final ContactListAccountItemViewHolder viewHolder;
    if (convertView == null) {
        view = layoutInflater.inflate(R.layout.contact_list_account_group_item, parent, false);
        viewHolder = new ContactListAccountItemViewHolder(view);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            view.setElevation(accountElevation);
        }
        view.setTag(viewHolder);
    } else {
        view = convertView;
        viewHolder = (ContactListAccountItemViewHolder) view.getTag();
    }
    final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
    final String account = configuration.getAccount();
    viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onClickListener.onAccountMenuClick(v, account);
        }
    });
    final int level = AccountManager.getInstance().getColorLevel(account);
    view.setBackgroundDrawable(new ColorDrawable(accountGroupColors[level]));
    viewHolder.name.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
    viewHolder.smallRightText.setText(configuration.getOnline() + "/" + configuration.getTotal());
    AccountItem accountItem = AccountManager.getInstance().getAccount(account);
    String statusText = accountItem.getStatusText().trim();
    if (statusText.isEmpty()) {
        statusText = activity.getString(accountItem.getDisplayStatusMode().getStringID());
    }
    viewHolder.secondLineMessage.setText(statusText);
    if (SettingsManager.contactsShowAvatars()) {
        viewHolder.avatar.setVisibility(View.VISIBLE);
        viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
    } else {
        viewHolder.avatar.setVisibility(View.GONE);
    }
    viewHolder.avatar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
        }
    });
    viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
    ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
    if (showOfflineMode == ShowOfflineMode.normal) {
        if (SettingsManager.contactsShowOffline()) {
            showOfflineMode = ShowOfflineMode.always;
        } else {
            showOfflineMode = ShowOfflineMode.never;
        }
    }
    viewHolder.smallRightIcon.setImageLevel(showOfflineMode.ordinal());
    StatusMode statusMode = AccountManager.getInstance().getAccount(configuration.getAccount()).getDisplayStatusMode();
    if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
        viewHolder.offlineShadow.setVisibility(View.VISIBLE);
    } else {
        viewHolder.offlineShadow.setVisibility(View.GONE);
    }
    return view;
}
Also used : StatusMode(com.xabber.android.data.account.StatusMode) ColorDrawable(android.graphics.drawable.ColorDrawable) AccountItem(com.xabber.android.data.account.AccountItem) ShowOfflineMode(com.xabber.android.data.roster.ShowOfflineMode) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AccountItem (com.xabber.android.data.account.AccountItem)1 StatusMode (com.xabber.android.data.account.StatusMode)1 ShowOfflineMode (com.xabber.android.data.roster.ShowOfflineMode)1