Ejemplo n.º 1
0
  /**
   * Called by a system to indicated that a command has been invoked on a particular displayable.
   *
   * @param command the Command that was invoked
   * @param displayable the Displayable where the command was invoked
   */
  public void commandAction(
      Command command, Displayable displayable) { // GEN-END:|7-commandAction|0|7-preCommandAction
    // write pre-action user code here
    if (displayable == LoginForm) { // GEN-BEGIN:|7-commandAction|1|65-preAction
      if (command == CreateAgentandJoin) { // GEN-END:|7-commandAction|1|65-preAction
        // write pre-action user code here
        String name = UserAgentNameTF.getString();
        String strAgentClassName = "au.edu.latrobe.placecomm.agents.MobileUserAgent";
        try {
          MicroRuntime.startAgent(name, strAgentClassName, null);
          // write post-action user code here
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        // GEN-LINE:|7-commandAction|2|65-postAction
        // write post-action user code here
      } else if (command == CreateContainer) { // GEN-LINE:|7-commandAction|3|63-preAction
        // write pre-action user code here

        Thread t =
            new Thread() {
              public void run() {
                myStartGoOnline();
              }
            };
        t.start();

        // GEN-LINE:|7-commandAction|4|63-postAction
        // write post-action user code here
      } else if (command == OfflineMode) { // GEN-LINE:|7-commandAction|5|28-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|6|28-postAction
        // write post-action user code here
      } else if (command == exitCommand) { // GEN-LINE:|7-commandAction|7|17-preAction
        // write pre-action user code here
        exitMIDlet(); // GEN-LINE:|7-commandAction|8|17-postAction
        // write post-action user code here
      } else if (command == okCommand) { // GEN-LINE:|7-commandAction|9|20-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|10|20-postAction
        // write post-action user code here
      } // GEN-BEGIN:|7-commandAction|11|7-postCommandAction
    } // GEN-END:|7-commandAction|11|7-postCommandAction
    // write post-action user code here
  } // GEN-BEGIN:|7-commandAction|12|
Ejemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      nickname = extras.getString("nickname");
    }

    try {
      chatClientInterface =
          MicroRuntime.getAgent(nickname).getO2AInterface(ChatClientInterface.class);
    } catch (StaleProxyException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ControllerException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    myReceiver = new MyReceiver();

    IntentFilter refreshParticipantsFilter = new IntentFilter();
    refreshParticipantsFilter.addAction("jade.demo.chat.REFRESH_PARTICIPANTS");
    registerReceiver(myReceiver, refreshParticipantsFilter);

    setContentView(R.layout.participants);

    setListAdapter(
        new ArrayAdapter<String>(
            this, R.layout.participant, chatClientInterface.getParticipantNames()));

    ListView listView = getListView();
    listView.setTextFilterEnabled(true);
    listView.setOnItemClickListener(listViewtListener);
  }