コード例 #1
0
    @Override
    public View getGroupView(
        int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
      ViewHolderGroup holder = null;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.widget_nick_group, null);
        holder = new ViewHolderGroup();
        holder.nameView = (TextView) convertView.findViewById(R.id.nicklist_group_name_view);
        holder.countView = (TextView) convertView.findViewById(R.id.nicklist_group_count_view);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolderGroup) convertView.getTag();
      }
      Pair<IrcMode, List<IrcUser>> group = getGroup(groupPosition);
      convertView.setBackgroundColor(ThemeUtil.getNickBg(group.first));
      holder.nameView.setTextColor(ThemeUtil.getModeColor(group.first));
      holder.countView.setTextColor(ThemeUtil.getModeColor(group.first));

      if (group.second.size() < 1) {
        convertView.setVisibility(View.GONE);
        holder.nameView.setVisibility(View.GONE);
        holder.countView.setVisibility(View.GONE);
      } else {
        convertView.setVisibility(View.VISIBLE);
        holder.nameView.setVisibility(View.VISIBLE);
        holder.countView.setVisibility(View.VISIBLE);
        holder.nameView.setText(
            getResources().getQuantityString(group.first.modeName, group.second.size()));
        holder.countView.setText(group.first.icon + " " + group.second.size());
      }
      return convertView;
    }
コード例 #2
0
    @Override
    public View getRealChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      ViewHolderChild holder = null;

      if (convertView == null) {
        convertView = inflater.inflate(R.layout.widget_nick_single, null);
        holder = new ViewHolderChild();
        holder.nickView = (TextView) convertView.findViewById(R.id.nicklist_nick_view);
        convertView.setTag(holder);
      } else {
        holder = (ViewHolderChild) convertView.getTag();
      }
      final IrcUser entry = getChild(groupPosition, childPosition);
      final IrcMode mode = getGroup(groupPosition).first;
      convertView.setBackgroundColor(ThemeUtil.getNickBg(mode));

      holder.nickView.setText(entry.nick);
      if (entry.away) {
        holder.nickView.setTextColor(ThemeUtil.Color.bufferParted);
      } else {
        holder.nickView.setTextColor(ThemeUtil.Color.bufferRead);
      }

      holder.nickView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              queryUser(entry.nick);
            }
          });

      return convertView;
    }