{"id":26498936,"url":"https://github.com/todou/nestrefresh","last_synced_at":"2025-03-20T14:51:08.099Z","repository":{"id":47733296,"uuid":"189685177","full_name":"ToDou/nestrefresh","owner":"ToDou","description":"Android refresh kit by nest scroll. Pull-to-refresh and pull-to-load-more by behaviors","archived":false,"fork":false,"pushed_at":"2021-08-16T07:41:34.000Z","size":17455,"stargazers_count":107,"open_issues_count":6,"forks_count":20,"subscribers_count":5,"default_branch":"master","last_synced_at":"2023-11-07T22:08:41.905Z","etag":null,"topics":["appbarlayout","childcoordinatorlayout","loadmore","loadmoreandrefresh","nestrefresh","nestscroll","pull-to-refresh","spring"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/ToDou.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":"2019-06-01T03:19:46.000Z","updated_at":"2023-10-12T01:58:18.000Z","dependencies_parsed_at":"2022-08-23T09:21:30.067Z","dependency_job_id":null,"html_url":"https://github.com/ToDou/nestrefresh","commit_stats":null,"previous_names":[],"tags_count":6,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToDou%2Fnestrefresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToDou%2Fnestrefresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToDou%2Fnestrefresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ToDou%2Fnestrefresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ToDou","download_url":"https://codeload.github.com/ToDou/nestrefresh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244637056,"owners_count":20485445,"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":["appbarlayout","childcoordinatorlayout","loadmore","loadmoreandrefresh","nestrefresh","nestscroll","pull-to-refresh","spring"],"created_at":"2025-03-20T14:51:07.380Z","updated_at":"2025-03-20T14:51:08.093Z","avatar_url":"https://github.com/ToDou.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nest Refresh  \n[![](https://img.shields.io/bintray/v/todou/maven/nestrefresh.svg)](https://bintray.com/beta/#/todou/maven/nestrefresh?tab=overview)\n[![issues open](https://img.shields.io/github/issues-raw/ToDou/nestrefresh.svg)](https://github.com/ToDou/nestrefresh/issues)\n[![ci](https://img.shields.io/circleci/build/github/ToDou/nestrefresh.svg)](https://circleci.com/gh/ToDou/workflows/nestrefresh)\n[![sonar](https://img.shields.io/sonar/https/sonarcloud.io/ToDou_nestrefresh/quality_gate.svg)](https://sonarcloud.io/dashboard?id=ToDou_nestrefresh)\n[![LICENSE](https://img.shields.io/github/license/ToDou/nestrefresh.svg)](https://github.com/ToDou/nestrefresh/blob/master/LICENSE)\n[![Language: Kotlin](https://img.shields.io/github/languages/top/ToDou/nestrefresh.svg)](https://github.com/ToDou/nestrefresh/search?l=kotlin) \n\nOne pull refresh kit by nest scroll  \n\nBy this library, you can add Pull Refresh by behaviors for one groupview or view with nest child. You can add pull refresh for one top header and scroll top with sticky area. You can add CollapseToolbarLayout in the RefreshBarLayout to collapse when scroll up, pin tab layout on the top and pull refresh when pull down. \nYou can add load more footer behavoir for your recyclerview. When you pull up at last of the recyclerview, the footer will be pull up with spring effect. You can set no more result when data have no more.\n\n[Download Sample](https://github.com/ToDou/nestrefresh/releases)\n\nScreenshot\n====\n|RefreshBar with Collapse|Header Nest Scroll|RefreshBar|Single Refresh|\n|---|---|---|---|\n|![](/screenshot/nest_refresh_refreshbar_collapse.gif)|![](/screenshot/nest_refresh_header_nest_scroll.gif)|![](/screenshot/nest_refresh_refresh_bar.gif)|![](/screenshot/nest_refresh_single.gif)|\n\nInstallation\n====\n```groovy\ndependencies {\n    implementation 'com.github.todou:nestrefresh:0.0.8'\n}\n```\n\u003e AndroidX\n```groovy\ndependencies {\n    implementation 'com.github.todou:nestrefresh-androidx:0.0.8'\n}\n```\nUsages\n====\nAll behavoir as follows:\n* RefreshBarBehavior\n    ```\n    Defualt behavior for RefreshBarLayout\n    ```\n* RefreshBarScrollBehavior\n    ```xml\n    @string/nest_refresh_bar_scroll_behavior\n    ```\n* RefreshBehavior\n    ```xml\n    @string/nest_refresh_single_behavior\n    ```\n* LoadMoreBehavior\n    ```\n    # default to LoadMoreFooterView\n    @string/nest_refresh_load_more_behavior\n    ```\n* RefreshScrollBehavior\n    ```xml\n    @string/nest_refresh_scroll_behavior\n    ```\n\n### Single Nest Refresh with load more footer\n```xml\n\u003candroid.support.design.widget.CoordinatorLayout\n    ...\u003e\n\n    \u003ccom.todou.nestrefresh.RefreshHeaderView\n        ...\n        app:layout_behavior=\"@string/nest_refresh_single_behavior\"/\u003e\n\n    \u003candroid.support.v7.widget.RecyclerView\n        ...\n        app:layout_behavior=\"@string/nest_refresh_scroll_behavior\"/\u003e\n\n    \u003ccom.todou.nestrefresh.LoadMoreFooterView\n        .../\u003e\n\n\u003c/android.support.design.widget.CoordinatorLayout\u003e\n```\nLoadMoreFooterView's default behavior is LoadMoreBehavior, so don't need to add behavior by yourself. And you can write your custom refresh header and custom load more footer with the behavior in the lib.\n### RefreshBarLayout Refresh with sticky\n```xml\n\u003candroid.support.design.widget.CoordinatorLayout\n    ...\u003e\n\n    \u003ccom.todou.nestrefresh.RefreshBarLayout\n        ...\u003e\n\n        \u003ccom.todou.nestrefresh.RefreshHeaderView\n            ...\n            app:nr_layout_scrollFlags=\"flag_refresh_header\"/\u003e\n \n        ...\n        \n        \u003candroid.support.design.widget.TabLayout\n            ...\n            app:nr_layout_scrollFlags=\"flag_sticky\"/\u003e\n        \n    \u003c/com.todou.nestrefresh.RefreshBarLayout\u003e\n\n    \u003candroid.support.v4.view.ViewPager\n        ...\n        app:layout_behavior=\"@string/nest_refresh_bar_scroll_behavior\"/\u003e\n\n\u003c/android.support.design.widget.CoordinatorLayout\u003e\n\n```\n### RefreshBarLayout Refresh with collapse toolbar\nFor inset status bar effect, you must add fitsSystemWindows true. And RefreshHeaderView in the default lib support compat inset\n```xml\n\u003candroid.support.design.widget.CoordinatorLayout\n    ...\u003e\n\n    \u003ccom.todou.nestrefresh.RefreshBarLayout\n        android:fitsSystemWindows=\"true\"\u003e\n\n        \u003ccom.todou.nestrefresh.RefreshHeaderView\n            app:nr_layout_scrollFlags=\"flag_refresh_header\"/\u003e\n\n        \u003ccom.todou.nestrefresh.NRCollapsingToolbarLayout\n            android:fitsSystemWindows=\"true\"\n            app:nr_layout_scrollFlags=\"flag_collapse\"\u003e\n\n            \u003cImageView\n                ...\n                android:fitsSystemWindows=\"true\"\n                app:nr_layout_collapseMode=\"parallax\"/\u003e\n\n            \u003candroid.support.v7.widget.Toolbar\n                app:nr_layout_collapseMode=\"pin\"/\u003e\n\n        \u003c/com.todou.nestrefresh.NRCollapsingToolbarLayout\u003e\n\n    \u003c/com.todou.nestrefresh.RefreshBarLayout\u003e\n\n    \u003candroid.support.v4.widget.NestedScrollView\n        ...\n        app:layout_behavior=\"@string/nest_refresh_bar_scroll_behavior\"\u003e\n\n        ...\n\n    \u003c/android.support.v4.widget.NestedScrollView\u003e\n\n\u003c/android.support.design.widget.CoordinatorLayout\u003e\n```\n### Load More Footer\nIf you want to add load more footer for whole scroll child such as viewpager. You can add LoadMoreBehavior directly. If you want add load more footer for recyclerview in fragment of ViewPager, you must wrapper every recyclerview with **ChildCoordinatorLayout**. ChildCoordinatorLayout will send unconsumeY to parent and then send to child behavior to itself.\nLike this in fragment layout of viewpager:\n```xml\n\u003ccom.todou.nestrefresh.ChildCoordinatorLayout\n    ...\u003e\n\n    \u003candroid.support.v7.widget.RecyclerView\n        ...\n        app:layout_behavior=\"@string/nest_refresh_scroll_behavior\"/\u003e\n\n    \u003ccom.todou.nestrefresh.LoadMoreFooterView\n        .../\u003e\n\n\u003c/com.todou.nestrefresh.ChildCoordinatorLayout\u003e\n```\nBecause of onNestedScroll can't return consumes, I calculate that by target offsetInWindow. So if CoordinatorLayout's child consume some 'y' and has move with offset. The ChildCoordinatorLayout can get the consume from that and then send unconsume 'y' to child of ChildCoordinatorLayout to consume value.\n### Add refresh callback\n```java\nview_refresh_header.setOnRefreshListener(object : OnRefreshListener {\n    override fun onRefresh() {\n        //Todo test code when network finish, you muast stop refresh by view_refresh_header.stopRefresh()\n        view_refresh_header.postDelayed({\n            view_refresh_header.stopRefresh()\n        }, 2000)\n    }\n})\n        \n```\n### Add load more callback\n```java\nview_footer.setOnLoadMoreListener(object : OnLoadMoreListener {\n    override fun onLoadMore() {\n        //Todo test code when network finish stop load more\n        view_footer.postDelayed({\n            view_footer.stopLoadMore()\n        }, 2000)\n    }\n})\n\n//Set has more \nview_footer.setHasMore(hasMore)\n```\nLicense\n====\n\u003cpre\u003e\nCopyright 2019 ToDou\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\u003c/pre\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodou%2Fnestrefresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftodou%2Fnestrefresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftodou%2Fnestrefresh/lists"}