Giter Site home page Giter Site logo

xaverkapeller / searchable-recyclerview-demo Goto Github PK

View Code? Open in Web Editor NEW
724.0 23.0 195.0 301 KB

An example app using a SearchView to filter items in a RecyclerView while taking full advantage of item animations!

License: MIT License

Java 100.00%
android recyclerview searchview recyclerview-item-animation

searchable-recyclerview-demo's Introduction

Searchable RecyclerView Demo

An example app using a SearchView to filter items in a RecyclerView while taking full advantage of item animations!

Build Status

You can find a walkthrough of how to implement an app with these features on Stack Overflow.

Or if you want to try out the app first you can download it from the Play Store:

Get it on Google Play

For more information visit the project homepage

searchable-recyclerview-demo's People

Contributors

wrdlbrnft avatar xaverkapeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

searchable-recyclerview-demo's Issues

throwIndexOutOfBoundsException

Hi

I have the same issue with this code.

The line where the code throws is the following

public void addItem(int position, Atividades model) {
        atividadesList.add(position, model);
        notifyItemInserted(position);
    }

The log

03-10 21:46:31.282 16422-16422/com.gilca.ebspma E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gilca.ebspma, PID: 16422
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.remove(ArrayList.java:403)
at adapter.AtividadesCardViewAdapter.addItem(AtividadesCardViewAdapter.java:87)
at adapter.AtividadesCardViewAdapter.applyAndAnimateAdditions(AtividadesCardViewAdapter.java:65)
at adapter.AtividadesCardViewAdapter.animateTo(AtividadesCardViewAdapter.java:48)
at fragments.AtividadesRecFragment$3.onQueryTextChange(AtividadesRecFragment.java:124)
at android.support.v7.widget.SearchView.onTextChanged(SearchView.java:1150)
at android.support.v7.widget.SearchView.access$2000(SearchView.java:103)
at android.support.v7.widget.SearchView$12.onTextChanged(SearchView.java:1665)
at android.widget.TextView.sendOnTextChanged(TextView.java:8599)
at android.widget.TextView.handleTextChanged(TextView.java:8681)
at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10897)
at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:968)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:519)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:456)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:691)
at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:447)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:340)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Any solution?

License?

Hi Xaver,

This is some amazing work! I was wondering if there was any license associated with it?

Please let me know when you get a chance, thanks!

Add Action doesn't work

Hello,
Why is that when I add element with
adapter.edit().add(object).commit();
it doesn't show in list ?
It looks like notifyItemInstered is not called :/

generate mBinding

hi
I found something in your project. your layout with data tag is item_example but in your main activity code you write private ActivityMainBinding mBinding;
but i found that it should be like this private ItemExampleBinding mBinding;
And becuz of that mBinding.recyclerView cant find recyclerView.
i think something is missing.
Thank you for your help
I'm waiting for the answer.

Do you really need to have 3 quadratic algorithms instead of notifyDataSetChanged()?

In your ExampleAdapter class you used 3 functions, that is quadratic

one of them is
`

private void applyAndAnimateAdditions(List<ExampleModel> newModels) {
    for (int i = 0, count = newModels.size(); i < count; i++) {
        final ExampleModel model = newModels.get(i);
        if (!mModels.contains(model)) {
            addItem(i, model);
        }
    }
}

`

Since mModels is a List, you have O(n) when use contains() method (so may be you should change it to HashSet).
Is it really beneficial to use your approach?
If you have 1000 items, you will have to go through 1000000 items two times.
But if you use notifyDataSetChanged(), you only need to redraw only visible items and walk through 1000 items only.
Or may be I don't understand something.

Slow algorithm with Big Array List

Hi! Great project, I really do appreciate your work!

I have a performance problem with your filtering algorithm if I use a big ArrayList (almost 400k words) to filter.

Precisely, it lags and it takes some time to filter the word I'm searching for.

Do you have any suggestion on that?
That might be useful for a lot of people dealing with a lot of entries.

Thank you and have a nice day!

Color Matching Characters

Nice job,pls can u show how to color matching characters as the user types? Thank you.Nice job once gain...I appreciate...

Searchable-RecyvlerView with GridView

Hello I implemented your demo and it works fine, but there are moments that the animation messes up...

I've done two screenshoots refering the problem take a look :

When I type something and the result is : http://i.imgur.com/Evsbf6i.png

BUT when I press back to hide the keyboard it goes : http://i.imgur.com/MoLJ8Lm.png

Do you know what exactly is the problem? Also I've oppened a post on Stackoverflow that is about your post : http://stackoverflow.com/questions/34889264/recyclerview-add-emptyview

Thanks.

Clicking items

Hi, I'm researching your Searchable-RecyclerView but I would like make clickable items (filtered o not filtered). So I implement View.OnClickListener in ExampleAdapter but I'm not sure if it is the best approach to your project. If you have to add, this feature what do you think is the right way make it possible?

Regards,

Extra items appear when searching and persist

Whenever I trigger the search view and type something in, items disappear as expected but then new items (regurgitated from the previous and visible ones) appear to replace them and don't go away after exiting the Search view.

These new items also refuse to disappear when I relaunch the Search view and type in a query that would hide them.

I have absolutely NO idea what code could be causing the problem.

Multiple comparators not possible

EDIT:
Changing my Google searches around a bit, I realised I don't need another comparator but additional filters - https://stackoverflow.com/a/37207601/956975


Hi, this is perhaps more a question than an issue - apologies if I'm messing with your Github stats by posting this as an "issue".

Thanks for this great solution to the problem of searching in a RecyclerView. It's easy, slick and just works!

BUT, I would like to be able to not just compare one field of a model.

In your example, you're comparing the text field of your Model class. The ALPHABETHICA_COMPARATOR does this in the activity and this comparator is sent to the Adapter.

How can I create a second comparator in the activity, which is then passed to the Adapter and then the user is able to search by text field of the model or id field of the model.

I hope this makes sense.

E.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.