{"id":13428129,"url":"https://github.com/Yalantis/SearchFilter","last_synced_at":"2025-03-16T01:31:58.787Z","repository":{"id":39617133,"uuid":"72092790","full_name":"Yalantis/SearchFilter","owner":"Yalantis","description":"Implementing Search Filter Animation in Kotlin for Quora Meets LinkedIn, Our App Design Concept","archived":false,"fork":false,"pushed_at":"2022-09-22T09:33:04.000Z","size":5682,"stargazers_count":1667,"open_issues_count":20,"forks_count":253,"subscribers_count":65,"default_branch":"master","last_synced_at":"2024-10-16T14:01:31.050Z","etag":null,"topics":["android","animation","search-filters"],"latest_commit_sha":null,"homepage":"https://yalantis.com","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yalantis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-27T09:29:02.000Z","updated_at":"2024-10-16T12:34:17.000Z","dependencies_parsed_at":"2023-01-17T16:16:08.806Z","dependency_job_id":null,"html_url":"https://github.com/Yalantis/SearchFilter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSearchFilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSearchFilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSearchFilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yalantis%2FSearchFilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yalantis","download_url":"https://codeload.github.com/Yalantis/SearchFilter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221631868,"owners_count":16855019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","animation","search-filters"],"created_at":"2024-07-31T01:00:46.924Z","updated_at":"2024-10-27T05:30:44.924Z","avatar_url":"https://github.com/Yalantis.png","language":"Kotlin","funding_links":[],"categories":["Libraries","开源库"],"sub_categories":["UI"],"readme":"# SearchFilter\n\n[![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)]()\n[![](https://jitpack.io/v/yalantis/searchfilter.svg)](https://jitpack.io/#yalantis/searchfilter)\n[![Yalantis](https://raw.githubusercontent.com/Yalantis/PullToRefresh/develop/PullToRefreshDemo/Resources/badge_dark.png)](https://yalantis.com/?utm_source=github)\n\n\u003ca href='https://play.google.com/store/apps/details?id=com.yalantis.fitfilter\u0026utm_source=global_co\u0026utm_medium=prtnr\u0026utm_content=Mar2515\u0026utm_campaign=PartBadge\u0026pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'\u003e\u003cimg alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' height=\"70\" width=\"180\"/\u003e\u003c/a\u003e\n\n[Live DEMO on appetize.io](https://appetize.io/app/3jke81pv6zuv9b4mt4gc53afc4)\n\nCheck this [project on dribbble](https://dribbble.com/shots/2818273-Female-in-IT-Filters)\n\nRead how we did it [on our blog](https://yalantis.com/blog/develop-filter-animation-kotlin-android/)\n\n\u003cimg src=\"gif/dribbble.gif\"/\u003e\n\n##Requirements\n- Android SDK 18+\n\n##Usage\n\nAdd to your root build.gradle:\n```Groovy\nallprojects {\n\trepositories {\n\t...\n\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\n\nAdd the dependency:\n```Groovy\ndependencies {\n\t  compile 'com.github.Yalantis:SearchFilter:v1.0.4'\n}\n```\n\n## How to use this library\n\nFirstly you need to place `Filter` above your `RecyclerView` in the layout file\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003candroid.support.design.widget.CoordinatorLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003candroid.support.design.widget.AppBarLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\u003e\n\n        \u003candroid.support.v7.widget.Toolbar\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"?attr/actionBarSize\"\n            android:background=\"@color/colorPrimary\"\n            android:elevation=\"4dp\"\n            android:paddingRight=\"16dp\"\u003e\n\n            \u003cRelativeLayout\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\u003e\n\n                \u003candroid.support.v7.widget.AppCompatImageView\n                    android:layout_width=\"24dp\"\n                    android:layout_height=\"24dp\"\n                    android:layout_centerVertical=\"true\"\n                    android:src=\"@drawable/ic_alarm\"\n                    android:tint=\"@android:color/white\" /\u003e\n\n                \u003cTextView\n                    android:layout_width=\"wrap_content\"\n                    android:layout_height=\"wrap_content\"\n                    android:layout_centerInParent=\"true\"\n                    android:text=\"Questions\"\n                    android:textColor=\"@android:color/white\"\n                    android:textSize=\"20sp\" /\u003e\n\n                \u003candroid.support.v7.widget.AppCompatImageView\n                    android:layout_width=\"24dp\"\n                    android:layout_height=\"24dp\"\n                    android:layout_alignParentRight=\"true\"\n                    android:layout_centerVertical=\"true\"\n                    android:src=\"@drawable/ic_search\"\n                    android:tint=\"@android:color/white\" /\u003e\n\n            \u003c/RelativeLayout\u003e\n\n        \u003c/android.support.v7.widget.Toolbar\u003e\n    \u003c/android.support.design.widget.AppBarLayout\u003e\n\n    \u003cFrameLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:background=\"#E4E6E3\"\n        app:layout_behavior=\"@string/appbar_scrolling_view_behavior\"\u003e\n\n        \u003candroid.support.v7.widget.RecyclerView\n            android:id=\"@+id/list\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"\n            android:layout_marginTop=\"@dimen/container_height\"\n            tools:listitem=\"@layout/item_list\" /\u003e\n\n        \u003ccom.yalantis.filter.widget.Filter\n            android:id=\"@+id/filter\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\" /\u003e\n\n    \u003c/FrameLayout\u003e\n\u003c/android.support.design.widget.CoordinatorLayout\u003e\n\n```\n\nAfter that you need to create a class that extends `FilterAdapter` and to pass your model class as a generic. \nHere you can easily customize the appearance of filter items. For the sample app I created `Tag` model to represent \nthe category of a question in the conversation.\n\n```java \n\nclass Adapter extends FilterAdapter\u003cTag\u003e {\n\n        Adapter(@NotNull List\u003c? extends Tag\u003e items) {\n            super(items);\n        }\n\n        @NotNull\n        @Override\n        public FilterItem createView(int position, Tag item) {\n            FilterItem filterItem = new FilterItem(ExampleActivity.this);\n\n            filterItem.setStrokeColor(mColors[0]);\n            filterItem.setTextColor(mColors[0]);\n            filterItem.setCheckedTextColor(ContextCompat.getColor(ExampleActivity.this, android.R.color.white));\n            filterItem.setColor(ContextCompat.getColor(ExampleActivity.this, android.R.color.white));\n            filterItem.setCheckedColor(mColors[position]);\n            filterItem.setText(item.getText());\n            filterItem.deselect();\n\n            return filterItem;\n        }\n    }\n\n```\n\nTo receive all the events from the `Filter` such as selection or deselection of a filter item it's necessary \nto add a `FilterListener` with the same model class passed as a generic\n\n```java\n\nprivate FilterListener\u003cTag\u003e mListener = new FilterListener\u003cTag\u003e() {\n\n        @Override\n        public void onFiltersSelected(@NotNull ArrayList\u003cTag\u003e filters) {\n            \n        }\n\n        @Override\n        public void onNothingSelected() {\n\n        }\n\n        @Override\n        public void onFilterSelected(Tag item) {\n\n        }\n\n        @Override\n        public void onFilterDeselected(Tag item) {\n\n        }\n\n    };\n\n```\n\nBasically `Filter` setup looks like that \n\n```java\n\n mFilter = (Filter\u003cTag\u003e) findViewById(R.id.filter);\n mFilter.setAdapter(new Adapter(getTags()));\n mFilter.setListener(this);\n\n //the text to show when there's no selected items\n mFilter.setNoSelectedItemText(getString(R.string.str_all_selected));\n mFilter.build();\n\n```\n\nFor more usage examples please review sample app\n\n## Let us know!\n\nWe’d be really happy if you sent us links to your projects where you use our component. Just send an email to github@yalantis.com And do let us know if you have any questions or suggestion regarding the animation. \n\nP.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned!\n\n## License\n\n\tThe MIT License (MIT)\n\n\tCopyright © 2016 Yalantis, https://yalantis.com\n\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the \"Software\"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\n\tTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYalantis%2FSearchFilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FYalantis%2FSearchFilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FYalantis%2FSearchFilter/lists"}