コード例 #1
0
  /** On Invite */
  @Override
  protected void onInvite(
      String targetNick,
      String sourceNick,
      String sourceLogin,
      String sourceHostname,
      String target) {
    if (targetNick.equals(this.getNick())) {
      // We are invited
      Message message =
          new Message(service.getString(R.string.message_invite_you, sourceNick, target));
      server.getConversation(server.getSelectedConversation()).addMessage(message);

      Intent intent =
          Broadcast.createConversationIntent(
              Broadcast.CONVERSATION_MESSAGE, server.getId(), server.getSelectedConversation());
      service.sendBroadcast(intent);
    } else {
      // Someone is invited
      Message message =
          new Message(
              service.getString(R.string.message_invite_someone, sourceNick, targetNick, target));
      server.getConversation(target).addMessage(message);

      Intent intent =
          Broadcast.createConversationIntent(
              Broadcast.CONVERSATION_MESSAGE, server.getId(), target);
      service.sendBroadcast(intent);
    }
  }
コード例 #2
0
  /** On Notice */
  @Override
  protected void onNotice(
      String sourceNick, String sourceLogin, String sourceHostname, String target, String notice) {
    // Post notice to currently selected conversation
    Conversation conversation;

    if (service.getSettings().showNoticeInServerWindow()) {
      conversation = server.getConversation(ServerInfo.DEFAULT_NAME);
    } else {
      conversation = server.getConversation(server.getSelectedConversation());

      if (conversation == null) {
        // Fallback: Use ServerInfo view
        conversation = server.getConversation(ServerInfo.DEFAULT_NAME);
      }
    }

    Message message = new Message("-" + sourceNick + "- " + notice);
    message.setIcon(R.drawable.info);
    conversation.addMessage(message);

    Intent intent =
        Broadcast.createConversationIntent(
            Broadcast.CONVERSATION_MESSAGE, server.getId(), conversation.getName());
    service.sendBroadcast(intent);
  }