{"id":19608625,"url":"https://github.com/teamwork/android-multiautocomplete","last_synced_at":"2025-04-27T20:32:58.797Z","repository":{"id":52676891,"uuid":"81201685","full_name":"Teamwork/android-multiautocomplete","owner":"Teamwork","description":"A lightweight and powerful abstraction over MultiAutoCompleteTextView and Tokenizer","archived":false,"fork":false,"pushed_at":"2021-04-21T11:12:36.000Z","size":759,"stargazers_count":10,"open_issues_count":5,"forks_count":6,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-05T03:22:20.042Z","etag":null,"topics":["adapter","android","autocompletetextview","filter","multiautocompletetextview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Teamwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-07T11:38:24.000Z","updated_at":"2024-09-09T03:34:24.000Z","dependencies_parsed_at":"2022-08-20T14:20:42.646Z","dependency_job_id":null,"html_url":"https://github.com/Teamwork/android-multiautocomplete","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teamwork%2Fandroid-multiautocomplete","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teamwork%2Fandroid-multiautocomplete/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teamwork%2Fandroid-multiautocomplete/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Teamwork%2Fandroid-multiautocomplete/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Teamwork","download_url":"https://codeload.github.com/Teamwork/android-multiautocomplete/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251204691,"owners_count":21552267,"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":["adapter","android","autocompletetextview","filter","multiautocompletetextview"],"created_at":"2024-11-11T10:16:01.879Z","updated_at":"2025-04-27T20:32:58.350Z","avatar_url":"https://github.com/Teamwork.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android MultiAutoComplete\n\n[![Download](https://api.bintray.com/packages/teamwork/com.teamwork/android-multiautocomplete/images/download.svg) ](https://bintray.com/teamwork/com.teamwork/android-multiautocomplete/_latestVersion)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.teamwork.multiautocomplete/android-multiautocomplete/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.teamwork.multiautocomplete/android-multiautocomplete)\n\nA library that provides a layer of abstraction over the Android `MultiAutoCompleteTextView` standard component,\nto simplify showing a drop down menu with suggestions for auto complete when the user is typing into an editable text view.\n\n* Built-in support for multiple data types in the same `MultiAutoCompleteTextView`\n* Built-in support for different token types: prefix handles (i.e. _@johndoe_) or comma-separated values\n* Built-in support for a simple image/text data type with standard layout\n* Fully customizable item layout management, view binders and view holders included\n* Fully customizable data filtering strategy and data sorting policies\n* Type-specific listeners to detect when a full token is added/removed from the text\n* High performance data indexing on a background thread to reduce filtering overhead\n\n\n![](docs/multiautocomplete_demo_screenshot_1.png)\u0026nbsp;\u0026nbsp;\u0026nbsp;![](docs/multiautocomplete_demo_screenshot_2.png)\n\nUsing **MultiAutoComplete** can be as easy as this:\n\n```java\n    List\u003cSimpleItem\u003e itemsList = ...\n    MultiAutoComplete autoComplete = MultiAutoComplete.Build.from(itemsList);\n    autoComplete.onViewAttached(autoCompleteEditText);\n```\n\n### Advantages over using MultiAutoCompleteTextView directly\n* No need to write your own `Tokenizer` implementation for handles\n* No need to write the drop down ListView adapter boilerplate code\n* No need to write a (_thread-safe_) `Filter` subclass for the adapter\n* No need to write an adapter composition pattern to support multiple types\n* No need to write decorator objects to merge different data types in a single adapter\n* Support for the hidden Android API `Filter$Delayer` through reflection (new in _0.2.5_)\n* (coming soon) Ability to easily swap between `AutoCompleteTextView` and `MultiAutoCompleteTextView`\n\n## Download\nDue to the announced shutdown of JCenter this library has been migrated to [Maven Central](https://search.maven.org/search?q=g:com.teamwork.multiautocomplete%20AND%20a:android-multiautocomplete) repository.\n**At the same time its Group ID has been changed from `com.teamwork` to `com.teamwork.multiautocomplete`**.\n\nAdd dependency via **Gradle**:\nIn your project's `build.gradle`:\n```groovy\nallprojects {\n  repositories {\n      mavenCentral()\n      ...\n  }\n  ...\n}\n```\nthen in the module's `build.gradle`:\n```groovy\ndependencies {\n    implementation 'com.teamwork.multiautocomplete:android-multiautocomplete:0.4.0'\n}\n```\nor **Maven**:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.teamwork.multiautocomplete\u003c/groupId\u003e\n  \u003cartifactId\u003eandroid-multiautocomplete\u003c/artifactId\u003e\n  \u003cversion\u003e0.4.0\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n##### Previous versions of the library can still be found on Bintray (complete shutdown is planned on February 2022).\nAdd dependency via **Gradle** (please note the different `groupId`):\n```groovy\ncompile 'com.teamwork:android-multiautocomplete:0.3.0'\n```\nor **Maven**:\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.teamwork\u003c/groupId\u003e\n  \u003cartifactId\u003eandroid-multiautocomplete\u003c/artifactId\u003e\n  \u003cversion\u003e0.3.0\u003c/version\u003e\n  \u003ctype\u003epom\u003c/type\u003e\n\u003c/dependency\u003e\n```\n\n## Documentation\nJavadoc documentation is available here: https://teamwork.github.io/android-multiautocomplete/\n\n### Domain language\nTo understand how to use the library quickly, keep in mind the definition of those recurring words in the API:\n\n* **Type adapter:** Just like Android adapters (and the Adapter design pattern),\na type adapter is used to display and filter a single data type (also called _model_).\nEach model requires a separate type adapter.\n\n* **Token:** A text token is a string that is processed by a filter and recognized as valid for triggering auto completion.\nA token can be prefixed by a char **handle** (i.e. _@johndoe_, where '_@_' is the handle) or can be a single word with a\nseparator (i.e. a space, or a comma).\n\n* **Constraint:** a text constraint is similar to a token, but it's used to filter contents from the type adapters.\nIf the token has a handle, i.e. _@johndoe_, its constraint will be _johndoe_.\n\n### Components\nIn order to customize **MultiAutoComplete** to suit your needs, you're going to need to use or implement some or all of these interfaces:\n* `MultiAutoComplete`: The main library component, it manages the type adapters and holds a reference to the `MultiAutoCompleteTextView`.\nIt provides lifecycle methods to attach/detach the view itself.\nIt holds an \"adapter of adapters\" internally, with which the presenter can handle multiple data types in the same instance and decide which\nadapter to use for filtering depending on what kind of token is being typed in.\n\nTo create an instance use one of the static factory methods in `MultiAutoComplete.Builder` or, for full customization,\nuse the _Builder_ itself:\n```java\n    MultiAutoComplete autoComplete = new MultiAutoComplete.Builder()\n        .tokenizer(tokenizer)\n        .addTypeAdapter(typeAdapter1)\n        .addTypeAdapter(typeAdapter2)\n        .build();\n```\n\n* `AutoCompleteTypeAdapter`: A typed adapter, used to provide a layout, data binding and filter options for a single data type.\nIt holds a _ViewBinder_ and a _TokenFilter_.\n\nTo create an instance use the static factory method `AutoCompleteTypeAdapter.Build.from()`:\n```java\n        AutoCompleteViewBinder\u003cMyDataType\u003e viewBinder = new MyViewBinder();\n        TokenFilter\u003cMyDataType\u003e tokenFilter = new MyTokenFilter();\n        AutoCompleteTypeAdapter\u003cMyDataType\u003e myTypeAdapter = AutoCompleteTypeAdapter.Build.from(viewBinder, tokenFilter);\n```\n\nTo set (or replace) the items for the type adapter, even after `MultiAutoComplete` was created, just call:\n```java\n        List\u003cMyDataType\u003e myItemsList = ...\n        myTypeAdapter.setItems(myItemsList);\n```\n\n* `AutoCompleteViewBinder`: A typed component used by a type adapter to bind the data from an item to the appropriate layout.\n`SimpleItemViewBinder` is a concrete implementation provided for the `SimpleItem` data type.\n\n* `TokenFilter`: A typed component used by a type adapter that takes care of the filtering strategy for the adapter elements.\nIt also determines whether the type adapter supports the text token that's being currently typed in. Concrete implementations\nfor basic usage are `HandleTokenFilter`, which support a single handle prefix (like '_@_'), and `SimpleTokenFilter`, which just\nmatches any token. Both filter items by matching the current text constraint with the value returned by the item's `toString()` method.\n\n* `Tokenizer`: Defined by the `MultiAutoCompleteTextView.Tokenizer` interface (see [javadoc](https://developer.android.com/reference/android/widget/MultiAutoCompleteTextView.Tokenizer.html)),\na tokenizer is used by a `MultiAutoCompleteTextView` to detect the beginning and ending of a token within a text sequence.\nUsing `PrefixTokenizer` allows you to match all tokens with a handle which are supported by the type adapters you provide:\n```java\n        MultiAutoCompleteTextView.Tokenizer tokenizer = new PrefixTokenizer('@',':');\n```\nAlternatively, you can use the Android built-in `MultiAutoCompleteTextView.CommaTokenizer` (see [javadoc](https://developer.android.com/reference/android/widget/MultiAutoCompleteTextView.CommaTokenizer.html)) to detect comma-separated words\nor write your own `Tokenizer` for full customization of the token detection, including which characters and separators to support.\n\n#### Class diagram\n![](docs/MultiAutoComplete_class_diagram_v0.2.0.png)\n\n### Demo App\nThe module `demo` contains simple usage examples of **MultiAutoComplete**.\nPull the source code and run the app to check it out.\n\n## License\n\n    Copyright 2017-2021 Teamwork.com\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamwork%2Fandroid-multiautocomplete","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteamwork%2Fandroid-multiautocomplete","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteamwork%2Fandroid-multiautocomplete/lists"}