Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get token you are writing #6

Open
Fabio-Graciotti opened this issue Mar 22, 2021 · 5 comments
Open

How to get token you are writing #6

Fabio-Graciotti opened this issue Mar 22, 2021 · 5 comments

Comments

@Fabio-Graciotti
Copy link

How to get the token you are writing, so that you can make a remote call with that token?
I tried to add textWatcher to MultiAutoComplete EditText, but this way TokenChangedListener doesn't work

@marcosalis marcosalis self-assigned this Mar 23, 2021
@marcosalis
Copy link
Contributor

Hi Fabio, thank you for using the library and creating the issue.
Could you please describe more in detail what you mean with "the token you are writing"?

Right now, using OnTokensChangedListener.onTokenAdded() allows you to get notified when a token gets added (so after the user has fully typed the token itself, as recognised by the Tokenizer you provided).
You can set the listener with AutoCompleteTypeAdapter.setOnTokensChangedListener().
Do you have different requirements that aren't met by the above?

@Fabio-Graciotti
Copy link
Author

I fetch the users list from remote service that filters the list by name, eg: "/users?query="Ale" or "/users?query="Alexander".
So i need to intercept an event that returns me the token partially typed (as in previus example "@Ale" or "@alexander"). After, when i fetched the list i can use "setItems" of adapter for update the list (if i use setItems while dropDownList is showing this disappear).
Exist something for achieve this?

Thanks for your time!

@marcosalis
Copy link
Contributor

Got it, thanks for the details.
We don't currently support this, but it should still be possible to use your own TextWatcher for the purpose.

I tried to add textWatcher to MultiAutoComplete EditText, but this way TokenChangedListener doesn't work

Are you sure about this?
Make sure you use MultiAutoCompleteEditText.addTextChangedListener(...) to avoid overriding the library's own listener. Multiple TextWatcher listeners are supported by the view so they shouldn't impact other listeners set elsewhere.

We might consider adding a listener callback to notify of "partial matches" but unfortunately it's not in the plans for the time being.

@Aliendroid8045
Copy link

Aliendroid8045 commented Mar 27, 2021

I have successfully added textWatcher, I can make API call and add list into adapter, I wouldn't able to find the limiting character. I want to pop up list only when I type @ with only three char. Currently when I type @ with two char, it is popping up.

@vedraj360
Copy link

though I am late but you can change this value in xml android:completionThreshold="1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants