@Test public void testGetAddedTokens() throws Exception { Collection<CharSequence> diff = getAddedTokens(Collections.emptySet(), Collections.emptySet()); assertThat(diff.size(), is(0)); diff = getAddedTokens(Collections.singleton("test"), (Collections.singleton("test"))); assertThat(diff.size(), is(0)); diff = getAddedTokens(Collections.singleton("test1"), Collections.singleton("test2")); assertThat(diff.size(), is(1)); assertThat(diff, hasItem("test2")); Set<CharSequence> diff1 = new HashSet<>(Arrays.asList("existing1", "existing2", "existing3")); Set<CharSequence> diff2 = new HashSet<>(Arrays.asList("new1", "new2", "existing2")); diff = getAddedTokens(diff1, diff2); assertThat(diff, hasItems("new1", "new2")); }
@VisibleForTesting static Collection<CharSequence> getAddedTokens(Set<CharSequence> existingSet, Set<CharSequence> newSet) { Set<CharSequence> added = new HashSet<>(newSet); added.removeAll(existingSet); return added; }
BaseTypeAdapterDelegate extends BaseAdapter implements TypeAdapterDelegate<M>, AutoCompleteTypeAdapter<M> { @VisibleForTesting static Collection<CharSequence> getAddedTokens(Set<CharSequence> existingSet, Set<CharSequence> newSet) { Set<CharSequence> added = new HashSet<>(newSet); added.removeAll(existingSet); return added; } }
BaseTypeAdapterDelegate extends BaseAdapter implements TypeAdapterDelegate<M>, AutoCompleteTypeAdapter<M> { @VisibleForTesting static Collection<CharSequence> getAddedTokens(Set<CharSequence> existingSet, Set<CharSequence> newSet) { Set<CharSequence> added = new HashSet<>(newSet); added.removeAll(existingSet); return added; } BaseTypeAdapterDelegate(@NonNull AutoCompleteViewBinder<M> viewBinder, @NonNull TokenFilter<M> tokenFilter); @VisibleForTesting  BaseTypeAdapterDelegate(@NonNull Executor computationExecutor,
                                               @NonNull Handler mainThreadHandler,
                                               @NonNull AutoCompleteViewBinder<M> viewBinder,
                                               @NonNull TokenFilter<M> tokenFilter); }
BaseTypeAdapterDelegate extends BaseAdapter implements TypeAdapterDelegate<M>, AutoCompleteTypeAdapter<M> { @VisibleForTesting static Collection<CharSequence> getAddedTokens(Set<CharSequence> existingSet, Set<CharSequence> newSet) { Set<CharSequence> added = new HashSet<>(newSet); added.removeAll(existingSet); return added; } BaseTypeAdapterDelegate(@NonNull AutoCompleteViewBinder<M> viewBinder, @NonNull TokenFilter<M> tokenFilter); @VisibleForTesting  BaseTypeAdapterDelegate(@NonNull Executor computationExecutor,
                                               @NonNull Handler mainThreadHandler,
                                               @NonNull AutoCompleteViewBinder<M> viewBinder,
                                               @NonNull TokenFilter<M> tokenFilter); @Override @NonNull TokenFilter<M> getFilter(); @Override @CallSuper void setItems(@NonNull List<M> items); @Override final void setFilteredItems(@NonNull List<M> filteredItems); @Override final int getCount(); @Override final @NonNull M getItem(int position); @Override long getItemId(int position); @Override @NonNull View getView(@NonNull LayoutInflater inflater,
                                 int position,
                                 @Nullable View convertView,
                                 @NonNull ViewGroup parent,
                                 @Nullable CharSequence constraint); @Override View getView(int position, View convertView, ViewGroup parent); @Override @WorkerThread final @NonNull List<M> performFiltering(@NonNull CharSequence constraint); @Override final void setOnTokensChangedListener(@Nullable OnTokensChangedListener<M> listener); @Override final void onTextChanged(@NonNull CharSequence text); }
BaseTypeAdapterDelegate extends BaseAdapter implements TypeAdapterDelegate<M>, AutoCompleteTypeAdapter<M> { @VisibleForTesting static Collection<CharSequence> getAddedTokens(Set<CharSequence> existingSet, Set<CharSequence> newSet) { Set<CharSequence> added = new HashSet<>(newSet); added.removeAll(existingSet); return added; } BaseTypeAdapterDelegate(@NonNull AutoCompleteViewBinder<M> viewBinder, @NonNull TokenFilter<M> tokenFilter); @VisibleForTesting  BaseTypeAdapterDelegate(@NonNull Executor computationExecutor,
                                               @NonNull Handler mainThreadHandler,
                                               @NonNull AutoCompleteViewBinder<M> viewBinder,
                                               @NonNull TokenFilter<M> tokenFilter); @Override @NonNull TokenFilter<M> getFilter(); @Override @CallSuper void setItems(@NonNull List<M> items); @Override final void setFilteredItems(@NonNull List<M> filteredItems); @Override final int getCount(); @Override final @NonNull M getItem(int position); @Override long getItemId(int position); @Override @NonNull View getView(@NonNull LayoutInflater inflater,
                                 int position,
                                 @Nullable View convertView,
                                 @NonNull ViewGroup parent,
                                 @Nullable CharSequence constraint); @Override View getView(int position, View convertView, ViewGroup parent); @Override @WorkerThread final @NonNull List<M> performFiltering(@NonNull CharSequence constraint); @Override final void setOnTokensChangedListener(@Nullable OnTokensChangedListener<M> listener); @Override final void onTextChanged(@NonNull CharSequence text);  }