code: private void insertSpan(TokenImageSpan tokenSpan) {
          CharSequence ssb = tokenizer.wrapTokenValue(tokenToString(tokenSpan.token));
  
          Editable editable = getText();
          if (editable == null) return;
  
          // If we haven't hidden any objects yet, we can try adding it
          if (hiddenContent == null) {
              internalEditInProgress = true;
              int offset = editable.length();
              //There might be a hint visible...
              if (hintVisible) {
                  //...so we need to put the object in in front of the hint
                  offset = prefix.length();
              } else {
                  Range currentRange = getCurrentCandidateTokenRange();
                  if (currentRange.length() > 0) {
                      // The user has entered some text that has not yet been tokenized.
                      // Find the beginning of this text and insert the new token there.
                      offset = currentRange.start;
                  }
              }
              editable.insert(offset, ssb);
              editable.insert(offset  + ssb.length(), " ");
              editable.setSpan(tokenSpan, offset, offset + ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
              internalEditInProgress = false;
          } else {
              CharSequence tokenText = tokenizer.wrapTokenValue(tokenToString(tokenSpan.getToken()));
              int start = hiddenContent.length();
              hiddenContent.append(tokenText);
              hiddenContent.append(" ");
              hiddenContent.setSpan(tokenSpan, start, start + tokenText.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
              updateCountSpan();
          }
      }
docs: Insert a new span for an Object
  
  @param tokenSpan span to insert