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

FilterableList with data from external sources #10

Open
marconi1992 opened this issue May 3, 2017 · 6 comments
Open

FilterableList with data from external sources #10

marconi1992 opened this issue May 3, 2017 · 6 comments

Comments

@marconi1992
Copy link
Contributor

marconi1992 commented May 3, 2017

For example I want to provide suggestions on the FilteredListView with data from a REST API , but not is possible because the method filterList into the class ChipsInput is called before of provide the external suggestions.

 mProductTags.addChipsListener(new ChipsInput.ChipsListener() {
            Handler handler = new Handler(Looper.getMainLooper());
            Runnable workRunnable;

            @Override
            public void onChipAdded(ChipInterface chipInterface, int i) {

            }

            @Override
            public void onChipRemoved(ChipInterface chipInterface, int i) {

            }

            @Override
            public void onTextChanged(final CharSequence charSequence) {

                handler.removeCallbacks(workRunnable);
                workRunnable = new Runnable() {
                    @Override
                    public void run() {
                        queryTags(charSequence);
                    }
                };
                handler.postDelayed(workRunnable, 500);
            }
        });
@pchmn
Copy link
Owner

pchmn commented May 3, 2017

You want to make a request to your REST API based on what the users typed, and populate the filterable list with that ? So each time the user types, you make your request to your API and get a list already filtered ?

If this is what your want, for now this is not possible, and you have to make the view that shows the suggestions on your own. Because, for now, the FilterableList is supposed to be all the suggestions, and not a list of suggestions already filtered.

But It can be a good thing to add this feature in the library. I will look into it.

@marconi1992
Copy link
Contributor Author

Yes I want populate the filterable list with that. I forked your library and I'm working in implement it, I'm going to make a pull request when the changes are available.

Thanks for the quick reply.

@janakagamini
Copy link

Hi @marconi1992, this would be quite useful as most of the time, the data required to populate the list is supplied by an external API, and the dataset could be very large to pre-load it when setting up the view.

What's your strategy for implementing this?

@or-else
Copy link

or-else commented May 30, 2017

It would also be useful if the dataset is local but too large to load into memory at once.

@marconi1992
Copy link
Contributor Author

Hi, In my case I used an AutocompleteTextView instead of the default list, therefore you can implement a custom adapter to get the data on-demand.
marconi1992@565a92d

        mBusinessTags.setFilterableList(new ArrayList<ChipInterface>()); // init empty default list

        mTagSuggestionsAdapter = new TagSuggestionsAdapter(getContext(), TagRepository.BUSINESS_SCOPE);

        mBusinessTags.getEditText().setAdapter(mTagSuggestionsAdapter);
        mBusinessTags.getEditText().setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                mBusinessTags.addChip(mTagSuggestionsAdapter.getItem(position));
            }
        });

If someone wants to implement it needs replace the official dependency by this

compile 'com.github.marconi1992:MaterialChipsInput:1.1.2'

it's just a temporary fix, I hope we might find a better solution.

@VexGod
Copy link

VexGod commented Jul 31, 2018

@marconi1992 can you link the TagSuggestionAdapter ??

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

5 participants