{"id":13832027,"url":"https://github.com/ribot/easy-adapter","last_synced_at":"2025-10-23T22:56:55.923Z","repository":{"id":43485870,"uuid":"16842589","full_name":"ribot/easy-adapter","owner":"ribot","description":"[DEPRECATED] Easy Adapters library for Android","archived":false,"fork":false,"pushed_at":"2022-02-28T06:38:32.000Z","size":824,"stargazers_count":420,"open_issues_count":9,"forks_count":50,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-05-25T18:06:42.011Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ribot.github.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ribot.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":"2014-02-14T16:22:52.000Z","updated_at":"2024-12-10T11:27:49.000Z","dependencies_parsed_at":"2022-09-12T10:10:57.374Z","dependency_job_id":null,"html_url":"https://github.com/ribot/easy-adapter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/ribot/easy-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ribot%2Feasy-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ribot%2Feasy-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ribot%2Feasy-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ribot%2Feasy-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ribot","download_url":"https://codeload.github.com/ribot/easy-adapter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ribot%2Feasy-adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280706833,"owners_count":26376980,"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","status":"online","status_checked_at":"2025-10-23T02:00:06.710Z","response_time":142,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-04T10:01:48.314Z","updated_at":"2025-10-23T22:56:55.890Z","avatar_url":"https://github.com/ribot.png","language":"Java","funding_links":[],"categories":["Java","Libs"],"sub_categories":["\u003cA NAME=\"Adapter\"\u003e\u003c/A\u003eAdapter"],"readme":"Deprecated\n===========\n\nDue to the growing use of the [RecyclerView](http://developer.android.com/reference/android/support/v7/widget/RecyclerView.html) and the [RecyclerView.Adapter](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html) provided adapter class, Easy-Adapter is now deprecated. Whilst the current version still remains usable, there will no longer be any new development taking place.\n\nEasyAdapter For Android\n===========\n\nUsing `ListView` and `RecyclerView` has never been so easy. Inspired by the [view holder](http://developer.android.com/training/improving-layouts/smooth-scrolling.html#ViewHolder) design pattern, this library provides an easier way of linking `ListView` and `RecyclerView` with the underlying data for that view without having to implement your own Adapter. EasyAdapter will do the tedious work for you.\n\n###### Why to use EasyAdapter?\n* __Simpler than implementing your own Adapter__. You just have to extend `ItemViewHolder` and use annotations to link your code to views and layouts. See examples below or demo app.\n* __Ensure performance__. It reuses the view holders so helps your ListViews scroll smoothly.\n* __Easy to switch between `ListView` and `RecyclerView`__. Once you implement your `ItemViewHolder` this can be used with both widgets. By just changing a couple of lines you can easily switch between a `ListView` and a `RecyclerView`.\n* __Cleaner code__. By keeping the view fields inside the view holders your code becomes cleaner an more understandable.\n\nEasyAdapter supports Android 2.1 and above.\n\nSetup\n--------------\n#### 1. Gradle\n```groovy\ndependencies {\n    compile 'uk.co.ribot:easyadapter:1.5.0@aar'\n}\n```\n#### 2. Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003euk.co.ribot\u003c/groupId\u003e\n    \u003cartifactId\u003eeasyadapter\u003c/artifactId\u003e\n    \u003cversion\u003e1.5.0\u003c/version\u003e\n    \u003ctype\u003eaar\u003c/type\u003e\n\u003c/dependency\u003e\n```\n#### 3. Manual\n\nDownload the __[latest Jar](https://raw.github.com/ribot/EasyAdapter/master/downloads/easyadapter-1.5.0.jar)__\n\nSample\n--------------\n\nThis example shows how to implement a `ListView` and a `RecyclerView` that displays a list of people. Every item on the list is a person with an image, name and phone number. The item's layout is `person_item_layout.xml` and it contains an `ImageView` and two `TextViews`. The `Person` class contains data about a person.\n\n#### 1. Extend ItemViewHolder\n\n```java\n//Annotate the class with the layout ID of the item.\n@LayoutId(R.layout.person_item_layout)\npublic class PersonViewHolder extends ItemViewHolder\u003cPerson\u003e {\n\n    //Annotate every field with the ID of the view in the layout.\n    //The views will automatically be assigned to the fields.\n    @ViewId(R.id.image_view_person)\n    ImageView imageViewPerson;\n\n    @ViewId(R.id.text_view_name)\n    TextView textViewName;\n\n    @ViewId(R.id.text_view_phone)\n    TextView textViewPhone;\n\n    //Extend ItemViewHolder and call super(view)\n    public PersonViewHolder(View view) {\n        super(view);\n    }\n\n    //Override onSetValues() to set the values of the items in the views.\n    @Override\n    public void onSetValues(Person person, PositionInfo positionInfo) {\n        imageViewPerson.setImageResource(person.getResDrawableId());\n        textViewName.setText(person.getName());\n        textViewPhone.setText(person.getPhoneNumber());\n    }\n}\n```\nIf you define the `ViewHolder` as an inner class, it must be `static` so that the `EasyAdapter` can instantiate it.\n\n#### 2. Link the view holder to your ListView or RecyclerView\n\n##### ListView\n\n```java\n/*\nCreate an EasyAdapter by passing a Context, your ItemViewHolder class and the list of items.\nAlternatively, you can create an EasyAdapter only with a Context and an ItemViewHolder class and set\nthe list of items later on.\n*/\nmListView.setAdapter(new EasyAdapter\u003cPerson\u003e(\n        this,\n        PersonViewHolder.class,\n        DataProvider.getListPeople()));\n```\n\n##### RecyclerView\n\n```java\n//Same as above but use a EasyRecyclerAdapter instead of EasyAdapter\nmRecyclerView.setAdapter(new EasyRecyclerAdapter\u003cPerson\u003e(\n        this,\n        PersonViewHolder.class,\n        DataProvider.getListPeople()));\n```\n\nSee demo app for a full working example.\n\n### Pass a callback or listener to the view holder. \n\nSometimes you need to notify your `Activity` or `Fragment` about an action that happened in your view holder, for example, you need to set the title of the `Activity` when a button that is in the view holder is clicked. From version 1.4.+ this is quite easy to implement by passing a listener or callback to the view holder through the adapter. See the example below:\n\n##### In your Activity create an easy adapter with a listener.  \n```java\n//Implement the listener. \nprivate PersonViewHolder.PersonListener mListener = new PersonViewHolder.PersonListener() {\n    public onButtonClicked(Person person) {\n        setTitle(person.getName());\n    }\n}\n\n//Set the listener when creating the EasyRecyclerAdapter (same for EasyAdapter)\nmRecyclerView.setAdapter(new EasyRecyclerAdapter\u003cPerson\u003e(\n        this,\n        PersonViewHolder.class,\n        DataProvider.getListPeople(),\n        mListener));\n```\n\n##### Get your listener from the ItemViewHolder\n```java\n@LayoutId(R.layout.person_item_layout)\npublic class PersonViewHolder extends ItemViewHolder\u003cPerson\u003e {\n\n    @ViewId(R.id.button)\n    Button button;\n    \n    //Implement onSetListeners and set a click listener in the button.  \n    @Override\n    public void onSetListeners() {\n        button.setOnClickListener(new View.OnClickListener() {\n            @Override\n            public void onClick(View v) {\n                //Get your custom listener and call the method. \n                PersonListener listener = getListener(PersonListener.class);\n                if (listener != null) {\n                    listener.onButtonClicked(getItem());\n                }\n            }\n        }\n    }\n    \n    //Define your custom interface \n    public interface PersonListener {\n        public void onButtonClicked(Person person);\n    }\n}\n```\nProguard \n--------------\nIf you are using Proguard you need to add the following rules to `proguard-rules.pro`:\n```\n-keepattributes *Annotation*\n-keepclassmembers class * extends uk.co.ribot.easyadapter.ItemViewHolder {\n    public \u003cinit\u003e(...);\n }\n```\n\nBuild\n--------------\n##### The demo app\n```\n./gradlew :demo:installDebug\n```\n##### The library\n```\n./gradlew :library:build\n```\n\n\nLicense\n--------------\n\n    Copyright 2014 Ribot Ltd.\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\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fribot%2Feasy-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fribot%2Feasy-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fribot%2Feasy-adapter/lists"}