private void updateVisibleRows(int mask) {
   if (listView == null) {
     return;
   }
   int count = listView.getChildCount();
   for (int a = 0; a < count; a++) {
     View child = listView.getChildAt(a);
     if (child instanceof ChatOrUserCell) {
       ((ChatOrUserCell) child).update(mask);
     }
   }
 }
    @Override
    public View getItemView(int section, int position, View convertView, ViewGroup parent) {
      TLRPC.User user = MessagesController.getInstance().users.get(selectedContacts.get(position));

      if (convertView == null) {
        convertView = new ChatOrUserCell(mContext);
        ((ChatOrUserCell) convertView).usePadding = false;
      }

      ((ChatOrUserCell) convertView).setData(user, null, null, null, null);
      ((ChatOrUserCell) convertView).useSeparator = position != selectedContacts.size() - 1;

      return convertView;
    }
  @Override
  public View getItemView(int section, int position, View convertView, ViewGroup parent) {

    TLRPC.User user = null;
    int count = 0;
    if (usersAsSections) {
      if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
        ArrayList<TLRPC.TL_contact> arr =
            ContactsController.getInstance()
                .usersSectionsDict
                .get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
        user = MessagesController.getInstance().getUser(arr.get(position).user_id);
        count = arr.size();
      }
    } else {
      if (section == 0) {
        if (position == 0) {
          if (convertView == null) {
            LayoutInflater li =
                (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = li.inflate(R.layout.contacts_invite_row_layout, parent, false);
            TextView textView = (TextView) convertView.findViewById(R.id.messages_list_row_name);
            textView.setText(LocaleController.getString("InviteFriends", R.string.InviteFriends));
          }
          View divider = convertView.findViewById(R.id.settings_row_divider);
          if (ContactsController.getInstance().contacts.isEmpty()) {
            divider.setVisibility(View.INVISIBLE);
          } else {
            divider.setVisibility(View.VISIBLE);
          }
          return convertView;
        }
        user =
            MessagesController.getInstance()
                .getUser(ContactsController.getInstance().contacts.get(position - 1).user_id);
        count = ContactsController.getInstance().contacts.size();
      }
    }
    if (user != null) {
      if (convertView == null) {
        convertView = new ChatOrUserCell(mContext);
        ((ChatOrUserCell) convertView).usePadding = false;
      }

      ((ChatOrUserCell) convertView).setData(user, null, null, null, null);

      if (ignoreUsers != null) {
        if (ignoreUsers.containsKey(user.id)) {
          ((ChatOrUserCell) convertView).drawAlpha = 0.5f;
        } else {
          ((ChatOrUserCell) convertView).drawAlpha = 1.0f;
        }
      }

      ((ChatOrUserCell) convertView).useSeparator = position != count - 1;

      return convertView;
    }

    TextView textView;
    if (convertView == null) {
      LayoutInflater li =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      convertView = li.inflate(R.layout.settings_row_button_layout, parent, false);
      textView = (TextView) convertView.findViewById(R.id.settings_row_text);
    } else {
      textView = (TextView) convertView.findViewById(R.id.settings_row_text);
    }

    View divider = convertView.findViewById(R.id.settings_row_divider);
    ArrayList<ContactsController.Contact> arr =
        ContactsController.getInstance()
            .contactsSectionsDict
            .get(ContactsController.getInstance().sortedContactsSectionsArray.get(section - 1));
    ContactsController.Contact contact = arr.get(position);
    if (divider != null) {
      if (position == arr.size() - 1) {
        divider.setVisibility(View.INVISIBLE);
      } else {
        divider.setVisibility(View.VISIBLE);
      }
    }
    if (contact.first_name != null && contact.last_name != null) {
      textView.setText(contact.first_name + " " + contact.last_name);
    } else if (contact.first_name != null && contact.last_name == null) {
      textView.setText(contact.first_name);
    } else {
      textView.setText(contact.last_name);
    }
    return convertView;
  }