public void addSuggestions(final @NonNull SuggestionsResult result,final @NonNull String bucket,final @NonNull TokenSource source){
  QueryToken query=result.getQueryToken();
synchronized (mLock) {
    mResultMap.put(bucket,result);
    Set<String> waitingForBuckets=mWaitingForResults.get(query);
    if (waitingForBuckets != null) {
      waitingForBuckets.remove(bucket);
      if (waitingForBuckets.size() == 0) {
        mWaitingForResults.remove(query);
      }
    }
  }
  String currentTokenString=source.getCurrentTokenString();
synchronized (mLock) {
    mSuggestions.clear();
    List<Suggestible> suggestions=mSuggestionsListBuilder.buildSuggestions(mResultMap,currentTokenString);
    if (suggestions.size() > 0) {
      mSuggestions.addAll(suggestions);
      mSuggestionsVisibilityManager.displaySuggestions(true);
    }
 else {
      hideSuggestionsIfNecessary(result.getQueryToken(),source);
    }
  }
  notifyDataSetChanged();
}

public void addSuggestions ( final @ NonNull SuggestionsResult result , final @ NonNull String bucket , final @ NonNull TokenSource source ) { QueryToken query = result . getQueryToken ( ) ; synchronized ( mLock ) { mResultMap . put ( bucket , result ) ; Set < String > waitingForBuckets = mWaitingForResults . get ( query ) ; if ( waitingForBuckets != null ) { waitingForBuckets . remove ( bucket ) ; if ( waitingForBuckets . size ( ) == 0 ) { mWaitingForResults . remove ( query ) ; } } } String currentTokenString = source . getCurrentTokenString ( ) ; synchronized ( mLock ) { mSuggestions . clear ( ) ; List < Suggestible > suggestions = mSuggestionsListBuilder . buildSuggestions ( mResultMap , currentTokenString ) ; if ( suggestions . size ( ) > 0 ) { mSuggestions . addAll ( suggestions ) ; mSuggestionsVisibilityManager . displaySuggestions ( true ) ; } else { hideSuggestionsIfNecessary ( result . getQueryToken ( ) , source ) ; } } notifyDataSetChanged ( ) ; }
add mention suggestions to a given bucket in the adapter . the adapter tracks the latest result for every given bucket , and passes this information to the suggestionsmanager to construct the list of suggestions in the appropriate order . < p > note : this should be called exactly once for every bucket returned from the query client .
