コード例 #1
0
  public void commandAction(Command c, Displayable d) {
    if (c == cmdOk) {
      String jid = getString(tJid);
      if (jid != null) {
        String name = getString(tNick);
        String group = group(tGrpList.getSelectedIndex());
        if (group == null) group = getString(tGroup);

        try {
          int gSel = tGrpList.getSelectedIndex();
          if (gSel != tGrpList.size() - 1) {
            group = (gSel > 0) ? tGrpList.getString(gSel) : null; // nokia fix
          }
        } catch (Exception e) {
        } // nokia fix

        // сохранение контакта
        boolean ask[] = new boolean[1];
        tAskSubscrCheckBox.getSelectedFlags(ask);
        roster.storeContact(jid, name, group, ask[0]);
        destroyView();
        return;
      }
    }

    if (c == cmdCancel) destroyView();
  }
コード例 #2
0
  public void commandAction(Command c, Displayable d) {
    if (c == cmdCancel) {
      destroyView();
      return;
    }
    if (c == cmdOk) {
      try {
        int type = choiseType.getSelectedIndex();
        String value = textValue.getString();
        if (type == 2) value = PrivacyItem.subscrs[choiceSubscr.getSelectedIndex()];
        if (type != PrivacyItem.ITEM_ANY) if (value.length() == 0) return;
        // int order=Integer.parseInt(textOrder.getString());

        item.action = choiceAction.getSelectedIndex();
        item.type = type;
        item.value = value;
        // item.order=order;
        choiseStanzas.getSelectedFlags(item.stanzasSet);

        if (targetList != null)
          if (!targetList.rules.contains(item)) {
            targetList.addRule(item);
            item.order = targetList.rules.indexOf(item) * 10;
          }
        destroyView();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }