{"id":25518487,"url":"https://github.com/s1rius/android-nest-scroll-ptr","last_synced_at":"2025-04-10T23:42:35.844Z","repository":{"id":57743937,"uuid":"213023799","full_name":"s1rius/android-nest-scroll-ptr","owner":"s1rius","description":"android pull-to-refresh layout work with nested-scroll","archived":false,"fork":false,"pushed_at":"2022-02-24T15:22:47.000Z","size":16074,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T23:42:30.142Z","etag":null,"topics":["android","jetpack-compose","kotlin","nestedscroll","pull-to-refresh"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s1rius.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-10-05T15:30:53.000Z","updated_at":"2022-11-22T12:59:37.000Z","dependencies_parsed_at":"2022-08-31T09:31:24.888Z","dependency_job_id":null,"html_url":"https://github.com/s1rius/android-nest-scroll-ptr","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1rius%2Fandroid-nest-scroll-ptr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1rius%2Fandroid-nest-scroll-ptr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1rius%2Fandroid-nest-scroll-ptr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1rius%2Fandroid-nest-scroll-ptr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s1rius","download_url":"https://codeload.github.com/s1rius/android-nest-scroll-ptr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317726,"owners_count":21083527,"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","jetpack-compose","kotlin","nestedscroll","pull-to-refresh"],"created_at":"2025-02-19T16:40:42.237Z","updated_at":"2025-04-10T23:42:35.807Z","avatar_url":"https://github.com/s1rius.png","language":"Kotlin","readme":"# android-nest-scroll-ptr\n\n[中文介绍](https://github.com/s1rius/android-nest-scroll-ptr/blob/master/README_CN.md)\n\nThis library implements pull-to-refresh logic and work with nested-scroll. It is easy to use and extend.\n\nIt is driven by a [StateMachine](https://github.com/Tinder/StateMachine)\n\n\u003cimg src=\"images/transition.png\" width=\"480\" height=\"300\" /\u003e\n\n### Requirements\n\n- minsdk 14/21(compose)\n- kotlin | compose\n\n### Features\n\n- driven by a FSM\n- work with nested-scroll\n- Jetpack Compose implementation\n- easy to customize the layout\n\n\n### Demo\n\n- Ins\n- Wechat\n- Wechat Moment\n- NestedScroll Sample\n\n\u003cdiv\u003e\n\n\u003cimg src=\"images/ins.gif\" width=\"160\" height=\"346\" /\u003e\n\u003cimg src=\"images/wechat.gif\" width=\"160\" height=\"346\" /\u003e\n\u003cimg src=\"images/moment.gif\" width=\"160\" height=\"346\" /\u003e\n\u003cimg src=\"images/tab.gif\" width=\"160\" height=\"346\" /\u003e\n\u003cimg src=\"images/nestedscroll.gif\" width=\"160\" height=\"346\" /\u003e\n\t\n\u003c/div\u003e\t\n\n### Use NSPtr in your application\n\n- add the dependency\n\n```\nrepositories {\n    ...\n    mavenCentral()\n    ...\n}\n\ndependencies {\n    ...\n    // android view system implementation\n    implementation \"wtf.s1.ui:nsptr-view:x.x.x\"\n    // jetpack compose implementation\n    implementation \"wtf.s1.ui:nsptr-compose:x.x.x\"\n    ...\n}\n```\n\n- use in Compose\n\n```kotlin\nval coroutine = rememberCoroutineScope()\nval nsPtrState = remember {\n    NSPtrState(\n        coroutineScope = coroutine\n    ) {\n        // todo refresh block\n        it.dispatchPtrEvent(Event.RefreshComplete)\n    }\n}\nNSPtrLayout(\n    nsPtrState = nsPtrState,\n    modifier = Modifier.fillMaxSize(),\n) {\n    NSPtrEZHeader(\n        modifier = Modifier\n            .offset(0.dp, 12.dp),\n        nsPtrState = nsPtrState\n    )\n    LazyColumn(Modifier.ptrContent()) {\n        items(10) { index -\u003e\n            // todo\n        }\n    }\n}\n```\n\n- add a layout to view hierarchy\n\n```kotlin\naddView(\n    NSPtrEZLayout(context).apply {\n        addView(\n            RecyclerView(context).apply {\n                // add data and adapter\n            },\n            NSPtrLayout.LayoutParams(\n                LayoutParams.MATCH_PARENT, \n                LayoutParams.MATCH_PARENT\n            )\n        )\n\n        addPtrListener(object : NSPtrListener {\n            override fun onRefreshing(ptrLayout: NSPtrLayout) {\n                super.onRefreshing(ptrLayout)\n                // do refresh logic\n            }\n        })\n\t\t// auto refresh\n\t\tisRefreshing = true\n    },\n    LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)\n)\n```\n\n- or use in XML layouts\n\n```xml\n\u003cwtf.s1.ui.nsptr.view.NSPtrEZLayout\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n\n    \u003candroidx.recyclerview.widget.RecyclerView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"/\u003e\n\n\u003c/wtf.s1.ui.nsptr.view.NSPtrEZLayout\u003e\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1rius%2Fandroid-nest-scroll-ptr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs1rius%2Fandroid-nest-scroll-ptr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1rius%2Fandroid-nest-scroll-ptr/lists"}