{"id":13642602,"url":"https://github.com/Jude95/EasyRecyclerView","last_synced_at":"2025-04-20T16:32:52.383Z","repository":{"id":48826954,"uuid":"39298691","full_name":"Jude95/EasyRecyclerView","owner":"Jude95","description":"ArrayAdapter,pull to refresh,auto load more,Header/Footer,EmptyView,ProgressView,ErrorView","archived":false,"fork":false,"pushed_at":"2022-07-27T08:32:10.000Z","size":11336,"stargazers_count":2025,"open_issues_count":110,"forks_count":459,"subscribers_count":77,"default_branch":"master","last_synced_at":"2025-04-15T02:09:25.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","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/Jude95.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":"2015-07-18T13:11:48.000Z","updated_at":"2025-03-22T03:58:52.000Z","dependencies_parsed_at":"2022-09-01T09:12:29.764Z","dependency_job_id":null,"html_url":"https://github.com/Jude95/EasyRecyclerView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jude95%2FEasyRecyclerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jude95%2FEasyRecyclerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jude95%2FEasyRecyclerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jude95%2FEasyRecyclerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jude95","download_url":"https://codeload.github.com/Jude95/EasyRecyclerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249926637,"owners_count":21346596,"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":[],"created_at":"2024-08-02T01:01:33.733Z","updated_at":"2025-04-20T16:32:51.793Z","avatar_url":"https://github.com/Jude95.png","language":"Java","funding_links":[],"categories":["RecyclerView"],"sub_categories":[],"readme":"# EasyRecyclerView\n[中文](https://github.com/Jude95/EasyRecyclerView/blob/master/README_ch.md) ｜ [English](https://github.com/Jude95/EasyRecyclerView/blob/master/README.md)\n\nEncapsulate many API about RecyclerView into the library,such as arrayAdapter,pull to refresh,auto load more,no more and error in the end,header\u0026footer.  \nThe library uses a new usage of ViewHolder,decoupling the ViewHolder and Adapter.  \nAdapter will do less work,adapter only direct the ViewHolder,if you use MVP,you can put adapter into presenter.ViewHolder only show the item,then you can use one ViewHolder for many Adapter.   \nPart of the code modified from [Malinskiy/SuperRecyclerView](https://github.com/Malinskiy/SuperRecyclerView),make more functions handed by Adapter.    \n\n\n# Dependency\n```groovy\ncompile 'com.jude:easyrecyclerview:4.4.2'\n```\n\n# ScreenShot\n![recycler.gif](recycler3.gif)\n# Usage\n## EasyRecyclerView\n```xml\n\u003ccom.jude.easyrecyclerview.EasyRecyclerView\n  android:id=\"@+id/recyclerView\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"match_parent\"\n  app:layout_empty=\"@layout/view_empty\"\n  app:layout_progress=\"@layout/view_progress\"\n  app:layout_error=\"@layout/view_error\"\n  app:recyclerClipToPadding=\"true\"\n  app:recyclerPadding=\"8dp\"\n  app:recyclerPaddingTop=\"8dp\"\n  app:recyclerPaddingBottom=\"8dp\"\n  app:recyclerPaddingLeft=\"8dp\"\n  app:recyclerPaddingRight=\"8dp\"\n  app:scrollbarStyle=\"insideOverlay\"//insideOverlay or insideInset or outsideOverlay or outsideInset\n  app:scrollbars=\"none\"//none or vertical or horizontal\n  /\u003e\n```\n\n**Attention** EasyRecyclerView is not a RecyclerView just contain a RecyclerView.use 'getRecyclerView()' to get the RecyclerView;\n\n**EmptyView\u0026LoadingView\u0026ErrorView**  \nxml:  \n```xml\napp:layout_empty=\"@layout/view_empty\"\napp:layout_progress=\"@layout/view_progress\"\napp:layout_error=\"@layout/view_error\"\n```\n\ncode:  \n```java\nvoid setEmptyView(View emptyView)\nvoid setProgressView(View progressView)\nvoid setErrorView(View errorView)\n```\n\nthen you can show it by this whenever:  \n\n```java\nvoid showEmpty()\nvoid showProgress()  \nvoid showError()  \nvoid showRecycler()\n```\n\n**scrollToPosition**  \n```java\nvoid scrollToPosition(int position); // such as scroll to top\n```\n\n**control the pullToRefresh**  \n```java\nvoid setRefreshing(boolean isRefreshing);\nvoid setRefreshing(final boolean isRefreshing, final boolean isCallback); //second params is callback immediately\n```\n\n\n##RecyclerArrayAdapter\u003cT\u003e  \nthere is no relation between RecyclerArrayAdapter and EasyRecyclerView.you can user any Adapter for the EasyRecyclerView,and use the RecyclerArrayAdapter for any RecyclerView.\n\n**Data Manage**\n```java\nvoid add(T object);\nvoid addAll(Collection\u003c? extends T\u003e collection);\nvoid addAll(T ... items);\nvoid insert(T object, int index);\nvoid update(T object, int index);\nvoid remove(T object);\nvoid clear();\nvoid sort(Comparator\u003c? super T\u003e comparator);\n```\n\n**Header\u0026Footer**\n```java\nvoid addHeader(ItemView view)\nvoid addFooter(ItemView view)  \n```\n\nItemView is not a view but a view creator;  \n\n```java\npublic interface ItemView {\n     View onCreateView(ViewGroup parent);\n     void onBindView(View itemView);\n}\n```\n\nThe onCreateView and onBindView correspond the callback in RecyclerView's Adapter,so adapter will call `onCreateView` once and `onBindView` more than once;  \nIt recommend that add the ItemView to Adapter after the data is loaded,initialization View in onCreateView and nothing in onBindView. \n \n Header and Footer support `LinearLayoutManager`,`GridLayoutManager`,`StaggeredGridLayoutManager`.  \n In `GridLayoutManager` you must add this:\n```java         \n//make adapter obtain a LookUp for LayoutManager，param is maxSpan。\ngridLayoutManager.setSpanSizeLookup(adapter.obtainGridSpanSizeLookUp(2));\n```\n\n**OnItemClickListener\u0026OnItemLongClickListener**  \n```java\nadapter.setOnItemClickListener(new RecyclerArrayAdapter.OnItemClickListener() {\n    @Override\n    public void onItemClick(int position) {\n        //position not contain Header\n    }\n});\n\nadapter.setOnItemLongClickListener(new RecyclerArrayAdapter.OnItemLongClickListener() {\n    @Override\n    public boolean onItemLongClick(int position) {\n        return true;\n    }\n});\n```\nequal 'itemview.setOnClickListener()' in ViewHolder.  \nif you set listener after RecyclerView has layout.you should use 'notifyDataSetChange()';\n\n###the API below realized by add a Footer。\n\n**LoadMore**  \n```java\nvoid setMore(final int res,OnMoreListener listener);\nvoid setMore(final View view,OnMoreListener listener);\n```\nAttention when you add null or the length of data you add is 0 ,it will finish LoadMore and show NoMore;  \nalso you can show NoMore manually `adapter.stopMore();`  \n \n**LoadError**  \n```java\nvoid setError(final int res,OnErrorListener listener)\nvoid setError(final View view,OnErrorListener listener)\n```\nuse `adapter.pauseMore()` to show Error,when your loading throw an error;  \nif you add data when showing Error.it will resume to load more;  \nwhen the ErrorView display to screen again,it will resume to load more too,and callback the OnLoadMoreListener(retry).  \n`adapter.resumeMore()`you can resume to load more manually,it will callback the OnLoadMoreListener immediately.   \nyou can put resumeMore() into the OnClickListener of ErrorView to realize click to retry.  \n\n**NoMore**  \n```java\nvoid setNoMore(final int res,OnNoMoreListener listener)\nvoid setNoMore(final View view,OnNoMoreListener listener)\n```\nwhen loading is finished(add null or empty or stop manually),it while show in the end.  \n\n## BaseViewHolder\\\u003cM\\\u003e\ndecoupling the ViewHolder and Adapter,new ViewHolder in Adapter and inflate view in ViewHolder.  \nExample:\n\n```java\npublic class PersonViewHolder extends BaseViewHolder\u003cPerson\u003e {\n    private TextView mTv_name;\n    private SimpleDraweeView mImg_face;\n    private TextView mTv_sign;\n\n\n    public PersonViewHolder(ViewGroup parent) {\n        super(parent,R.layout.item_person);\n        mTv_name = $(R.id.person_name);\n        mTv_sign = $(R.id.person_sign);\n        mImg_face = $(R.id.person_face);\n    }\n\n    @Override\n    public void setData(final Person person){\n        mTv_name.setText(person.getName());\n        mTv_sign.setText(person.getSign());\n        mImg_face.setImageURI(Uri.parse(person.getFace()));\n    }\n}\n\n-----------------------------------------------------------------------\n\npublic class PersonAdapter extends RecyclerArrayAdapter\u003cPerson\u003e {\n    public PersonAdapter(Context context) {\n        super(context);\n    }\n\n    @Override\n    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {\n        return new PersonViewHolder(parent);\n    }\n}\n```\n\n## Decoration\nNow there are three commonly used decoration provide for you.  \n**DividerDecoration**  \nUsually used in LinearLayoutManager.add divider between items.\n```java\nDividerDecoration itemDecoration = new DividerDecoration(Color.GRAY, Util.dip2px(this,0.5f), Util.dip2px(this,72),0);//color \u0026 height \u0026 paddingLeft \u0026 paddingRight\nitemDecoration.setDrawLastItem(true);//sometimes you don't want draw the divider for the last item,default is true.\nitemDecoration.setDrawHeaderFooter(false);//whether draw divider for header and footer,default is false.\nrecyclerView.addItemDecoration(itemDecoration);\n```\nthis is the demo:  \n\u003cimage src=\"http://o84n5syhk.bkt.clouddn.com/divider.jpg?imageView2/2/w/300\" width=300/\u003e\n\n\n**SpaceDecoration**  \nUsually used in GridLayoutManager and StaggeredGridLayoutManager.add space between items.  \n```java\nSpaceDecoration itemDecoration = new SpaceDecoration((int) Utils.convertDpToPixel(8,this));//params is height\nitemDecoration.setPaddingEdgeSide(true);//whether add space for left and right adge.default is true.\nitemDecoration.setPaddingStart(true);//whether add top space for the first line item(exclude header).default is true.\nitemDecoration.setPaddingHeaderFooter(false);//whether add space for header and footer.default is false.\nrecyclerView.addItemDecoration(itemDecoration);\n```\nthis is the demo:  \n\u003cimage src=\"http://o84n5syhk.bkt.clouddn.com/space.jpg?imageView2/2/w/300\" width=300/\u003e\n\n**StickHeaderDecoration**  \nGroup the items,add a GroupHeaderView for each group.The usage of StickyHeaderAdapter is the same with RecyclerView.Adapter.\nthis part is modified from [edubarr/header-decor](https://github.com/edubarr/header-decor)\n```java\nStickyHeaderDecoration decoration = new StickyHeaderDecoration(new StickyHeaderAdapter(this));\ndecoration.setIncludeHeader(false);\nrecyclerView.addItemDecoration(decoration);\n```\nfor example:   \n\u003cimage src=\"http://7xkr5d.com1.z0.glb.clouddn.com/recyclerview_sticky.png?imageView2/2/w/300\" width=300/\u003e\n\n**for detail,see the demo**\n\nLicense\n-------\n\n    Copyright 2015 Jude\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\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJude95%2FEasyRecyclerView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJude95%2FEasyRecyclerView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJude95%2FEasyRecyclerView/lists"}