コード例 #1
0
 private void maybeGetOrCreateConversation() {
   final ArrayList<ParticipantData> participants =
       mRecipientTextView.getRecipientParticipantDataForConversationCreation();
   if (ContactPickerData.isTooManyParticipants(participants.size())) {
     UiUtils.showToast(R.string.too_many_participants);
   } else if (participants.size() > 0 && mMonitor == null) {
     mMonitor = GetOrCreateConversationAction.getOrCreateConversation(participants, null, this);
   }
 }
コード例 #2
0
  /**
   * Watches changes in contact chips to determine possible state transitions (e.g. creating the
   * initial conversation, adding more participants or finish the current conversation)
   */
  @Override
  public void onContactChipsChanged(final int oldCount, final int newCount) {
    Assert.isTrue(oldCount != newCount);
    if (mContactPickingMode == MODE_PICK_INITIAL_CONTACT) {
      // Initial picking mode. Start a conversation once a recipient has been picked.
      maybeGetOrCreateConversation();
    } else if (mContactPickingMode == MODE_CHIPS_ONLY) {
      // oldCount == 0 means we are restoring from savedInstanceState to add the existing
      // chips, don't switch to "add more participants" mode in this case.
      if (oldCount > 0 && mRecipientTextView.isFocused()) {
        // Chips only mode. The user may have picked an additional contact or deleted the
        // only existing contact. Either way, switch to picking more participants mode.
        mHost.onInitiateAddMoreParticipants();
      }
    }
    mHost.onParticipantCountChanged(ContactPickerData.getCanAddMoreParticipants(newCount));

    // Refresh our local copy of the selected chips set to keep it up-to-date.
    mSelectedPhoneNumbers = mRecipientTextView.getSelectedDestinations();
    invalidateContactLists();
  }