Ejemplo n.º 1
0
  private void populateMenuItems(List<ContextMenuItem> menuItems, BufferEventItem item) {
    menuItems.add(new CopyContextMenuItem(item));

    BufferEventMessage message = item.getMessage();

    final String nick = TextUtils.isEmpty(message.from) ? message.nick : message.from;
    if (!TextUtils.isEmpty(nick)) {
      if (mBuffer instanceof ChannelBuffer) {
        if (((ChannelBuffer) mBuffer).isInChannel(nick)) {
          menuItems.add(new MessageUserContextMenuItem(nick));
          menuItems.add(new MentionUserContextMenuItem(nick));
        }
      } else {
        menuItems.add(new MessageUserContextMenuItem(nick));
      }
    }

    if (!TextUtils.isEmpty(message.getMsgString())) {
      Matcher matcher = URL_PATTERN.matcher(message.getMsgString());
      while (matcher.find()) {
        menuItems.add(new URLContextMenuItem(matcher.group(0)));
      }
    }
  }