Skip to content

Commit 5dc3766

Browse files
committed
update doc
1 parent 01e4126 commit 5dc3766

File tree

14 files changed

+246
-8
lines changed

14 files changed

+246
-8
lines changed

README.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# NSPtrLayout
1+
# android-nest-scroll-ptr
22

3-
This component implements pull-to-refresh logic and work with nested-scroll. It is easy to use and extend.
3+
[中文介绍](https://github.com/s1rius/android-nest-scroll-ptr/blob/master/README_CN.md)
4+
5+
This library implements pull-to-refresh logic and work with nested-scroll. It is easy to use and extend.
46

57
### Requirements
68

@@ -9,12 +11,80 @@ This component implements pull-to-refresh logic and work with nested-scroll. It
911

1012
### Features
1113

12-
- multi headers
13-
- nested-scroll
14+
- work with nested-scroll
15+
- easy to customize the child widget
16+
1417

1518
### Demo
1619

1720
- Ins
21+
22+
![avatar](doc/ins.gif)
23+
1824
- Wechat
25+
26+
![avatar](doc/wechat.gif)
27+
1928
- Wechat Moment
20-
- NestedScroll Sample
29+
30+
![avatar](doc/moment.gif)
31+
32+
- NestedScroll Sample
33+
34+
![avatar](doc/tab.gif)
35+
36+
![avatar](doc/nestedscroll.gif)
37+
38+
### Use NSPtr in your application
39+
40+
- add the dependency
41+
42+
```
43+
dependencies {
44+
...
45+
implementation "wtf.s1.ptr:nsptr:x.x.x"
46+
...
47+
}
48+
```
49+
50+
- add a layout to view hierarchy
51+
52+
```
53+
addView(
54+
NSPtrEZLayout(context).apply {
55+
addView(
56+
RecyclerView(context).apply {
57+
// add data and adapter
58+
},
59+
NSPtrLayout.LayoutParams(
60+
LayoutParams.MATCH_PARENT,
61+
LayoutParams.MATCH_PARENT
62+
)
63+
)
64+
65+
addPtrListener(object : NSPtrListener {
66+
override fun onRefreshing(ptrLayout: NSPtrLayout) {
67+
super.onRefreshing(ptrLayout)
68+
// do refresh logic
69+
}
70+
})
71+
// auto refresh
72+
isRefreshing = true
73+
},
74+
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
75+
)
76+
```
77+
78+
- or use in XML layouts
79+
80+
```
81+
<wtf.s1.android.ptr.NSPtrEZLayout
82+
android:layout_width="match_parent"
83+
android:layout_height="match_parent">
84+
85+
<androidx.recyclerview.widget.RecyclerView
86+
android:layout_width="match_parent"
87+
android:layout_height="match_parent"/>
88+
89+
</wtf.s1.android.ptr.NSPtrEZLayout>
90+
```

README_CN.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# android-nest-scroll-ptr
2+
3+
本库实现了下拉刷新的逻辑,且实现了嵌套滑动接口。在嵌套滑动机制下正常工作。易于扩展和自定义。
4+
5+
### 支持环境
6+
7+
- minsdk 14
8+
- kotlin
9+
10+
### 特性
11+
12+
- 支持嵌套滑动
13+
- 易于扩展
14+
15+
16+
### Demo
17+
18+
- instagram 刷新样式
19+
20+
![avatar](doc/ins.gif)
21+
22+
- 微信首页小程序下拉
23+
24+
![avatar](doc/wechat.gif)
25+
26+
- 微信朋友圈下拉
27+
28+
![avatar](doc/moment.gif)
29+
30+
- Android 官方嵌套滑动 demo 适配
31+
32+
![avatar](doc/tab.gif)
33+
34+
![avatar](doc/nestedscroll.gif)
35+
36+
37+
### 开始使用
38+
39+
- 添加依赖
40+
41+
```
42+
dependencies {
43+
...
44+
implementation "wtf.s1.ptr:nsptr:x.x.x"
45+
...
46+
}
47+
```
48+
49+
- 用代码实现
50+
51+
```
52+
addView(
53+
NSPtrEZLayout(context).apply {
54+
addView(
55+
RecyclerView(context).apply {
56+
// 添加数据和adapter
57+
},
58+
NSPtrLayout.LayoutParams(
59+
LayoutParams.MATCH_PARENT,
60+
LayoutParams.MATCH_PARENT
61+
)
62+
)
63+
64+
addPtrListener(object : NSPtrListener {
65+
override fun onRefreshing(ptrLayout: NSPtrLayout) {
66+
super.onRefreshing(ptrLayout)
67+
// 下拉刷新开始,请求网路
68+
}
69+
})
70+
// 自动刷新
71+
isRefreshing = true
72+
},
73+
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
74+
)
75+
```
76+
77+
- 用XML实现
78+
79+
```
80+
<wtf.s1.android.ptr.NSPtrEZLayout
81+
android:layout_width="match_parent"
82+
android:layout_height="match_parent">
83+
84+
<androidx.recyclerview.widget.RecyclerView
85+
android:layout_width="match_parent"
86+
android:layout_height="match_parent"/>
87+
88+
</wtf.s1.android.ptr.NSPtrEZLayout>
89+
```

buildSrc/src/main/java/wtf/s1rius/ptr/buildsrc/Configs.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ object Versions {
1111
const val versionCode = 1
1212
const val versionName = "1.0.0"
1313
const val bytex = "0.2.7"
14+
const val nsptr = "0.0.1"
15+
const val nsptrDev = "0.0.1"
1416
}
1517

1618
object Plugins {
1719
const val androidLib = "com.android.library"
1820
}
1921

2022
object Deps {
23+
const val nsptr = "wtf.s1.ptr:nsptr:${Versions.nsptr}"
24+
const val nsptrDev = "wtf.s1.ptr:nsptr:${Versions.nsptrDev}"
2125
object Kotlin {
2226
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${Versions.kotlin}"
2327
const val coroutines =

doc/ins.gif

975 KB
Loading

doc/moment.gif

1.58 MB
Loading

doc/nestedscroll.gif

2.03 MB
Loading

doc/tab.gif

2.99 MB
Loading

doc/wechat.gif

630 KB
Loading

ptr-demo/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ android {
2727
}
2828

2929
dependencies {
30+
// implementation Deps.nsptrDev
3031
implementation(project(":ptr-lib"))
3132
implementation Deps.AndroidX.appcompat
3233
implementation Deps.AndroidX.constraintLayout

ptr-demo/src/main/java/wtf/s1/android/ptr/demo/InstagramView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class InstagramView @JvmOverloads constructor(
4545
}, 3000)
4646
}
4747
})
48+
49+
isRefreshing = true
4850
},
4951
LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
5052
)

0 commit comments

Comments
 (0)