コード例 #1
0
  /**
   * Method fired when "add" button is clicked.
   *
   * @param v add button's <tt>View</tt>
   */
  public void onAddClicked(View v) {
    Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner);

    Account selectedAcc = (Account) accountsSpiner.getSelectedItem();
    if (selectedAcc == null) {
      logger.error("No account selected");
      return;
    }

    ProtocolProviderService pps = selectedAcc.getProtocolProvider();
    if (pps == null) {
      logger.error("No provider registered for account " + selectedAcc.getAccountName());
      return;
    }

    View content = findViewById(android.R.id.content);
    String contactAddress = ViewUtil.getTextViewValue(content, R.id.editContactName);

    String displayName = ViewUtil.getTextViewValue(content, R.id.editDisplayName);
    if (displayName != null && displayName.length() > 0) {
      addRenameListener(pps, null, contactAddress, displayName);
    }

    Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);
    ContactListUtils.addContact(
        pps, (MetaContactGroup) groupSpinner.getSelectedItem(), contactAddress);
    finish();
  }
コード例 #2
0
  /** {@inheritDoc} */
  @Override
  protected void onDestroy() {
    super.onDestroy();

    if (flagPaused) {
      return;
    }

    if (ViewUtil.isCompoundChecked(getContentView(), R.id.addToContacts)
        && responseCode.equals(AuthorizationResponse.ACCEPT)) {
      // Add to contacts
      Spinner groupSpinner = (Spinner) findViewById(R.id.selectGroupSpinner);

      ContactListUtils.addContact(
          request.contact.getProtocolProvider(),
          (MetaContactGroup) groupSpinner.getSelectedItem(),
          request.contact.getAddress());
    }

    request.notifyResponseReceived(responseCode);
  }