-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
907f6fd
commit 115cb61
Showing
11 changed files
with
195 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
列表动画只是实现列表Item出现的动画 | ||
列表动画即自定义列表Item出现时的动画 | ||
|
||
## 动画类型 | ||
通过函数快速设置BRV自带的几种动画类型 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<img src="https://s2.loli.net/2022/04/24/JgSrqjWAP26b8x5.gif" width="250"/> | ||
|
||
!!! Warning "多类型列表" | ||
1. 头/脚布局在RV中只是多类型item, 所以在计算`position`时应当考虑其中 | ||
2. 头/脚布局也需要使用`addType`函数添加类型 | ||
|
||
```kotlin | ||
BRV数据集 = Header + Models + Footer | ||
``` | ||
|
||
```kotlin | ||
binding.rv.linear().setup { | ||
addType<Model>(R.layout.item_simple) | ||
addType<Header>(R.layout.item_header) | ||
addType<Footer>(R.layout.item_footer) | ||
}.models = getData() | ||
|
||
binding.rv.bindingAdapter.run { | ||
addHeader(Header(), animation = true) | ||
addFooter(Footer(), animation = true) | ||
} | ||
``` | ||
|
||
其他头/脚布局实现 | ||
|
||
1. 可使用[ConcatAdapter](https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter)连接多个`BindingAdapter` | ||
1. `NestedScrollView`嵌套RV会导致RV一次性加载全部列表, 大量列表数据时会卡顿 | ||
|
||
<br> | ||
|
||
|
||
## 列表局部缺省页 | ||
|
||
如果使用`CoordinatorLayout`方案来解决列表缺省页覆盖头/脚布局问题, 但是期望从页面顶部开始下拉刷新动画 | ||
|
||
- [PagePartStateFragment](https://github.com/liangjingkanji/BRV/blob/5269ef245e7f312a0077194611f1c2aded647a3c/sample/src/main/java/com/drake/brv/sample/ui/fragment/PagePartStateFragment.kt#L27) | ||
|
||
```kotlin title="fragment_page_part_state_header.xml" | ||
<com.drake.brv.PageRefreshLayout | ||
android:id="@+id/page" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:page_rv="@id/rv" | ||
app:page_state="@id/state"> | ||
|
||
<androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
|
||
<com.google.android.material.appbar.AppBarLayout> | ||
|
||
// ... HEADER | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<com.drake.statelayout.StateLayout | ||
android:id="@+id/state" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"> | ||
|
||
<androidx.recyclerview.widget.RecyclerView | ||
android:id="@+id/rv" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
|
||
</com.drake.statelayout.StateLayout> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
|
||
</com.drake.brv.PageRefreshLayout> | ||
|
||
``` | ||
|
||
1. `app:page_rv` 指定嵌套的rv | ||
2. `app:page_state` 指定嵌套的缺省页 | ||
|
||
## 函数 | ||
|
||
| 函数 | 描述 | | ||
|-|-| | ||
| addHeader/addFooter | 添加头布局/脚布局 | | ||
| removeHeader/removeFooter | 删除头布局/脚布局 | | ||
| removeHeaderAt/removeFooterAt | 删除指定索引的头布局/脚布局 | | ||
| clearHeader/clearFooter | 清除全部头布局/脚布局 | | ||
| isHeader/isFooter | 指定索引是否是头布局/脚布局 | | ||
| headerCount/footerCount | 头布局/脚布局数量 | | ||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
`预加载`就是还没显示到列表末尾就会开始加载下一页, 执行上拉加载的逻辑, 前提是当前列表有下一页 | ||
|
||
`预拉取`就是提前拉取. 和上面预加载差不多理解. 不知道拉取是什么请阅读[拉取更多](upfetch.md) | ||
|
||
!!! question "预加载/预拉取" | ||
即列表末尾还未显示就会开始加载下一页 | ||
|
||
## 当前列表预加载索引 | ||
|
||
BRV默认开启预加载/预拉取. 通过函数可以指定成员属性`preloadIndex`可以控制显示到倒数第几个条目时就开始预加载 | ||
|
||
> 预拉取和预加载条件都是使用的同一个字段. 设置preloadIndex后两者都会生效 | ||
BRV默认开启预加载/预拉取, 指定字段`preloadIndex`控制显示到倒数第几个条目时开始预加载 | ||
|
||
默认值是: 3 | ||
以下为默认值 | ||
|
||
```kotlin | ||
var preloadIndex = 3 | ||
``` | ||
|
||
## 全局预加载索引 | ||
|
||
通过`PageRefreshLayout.preloadIndex`可以设置全局默认值. 这样所有列表都默认就是你指定的索引开始预加载 | ||
`PageRefreshLayout.preloadIndex`设置全局默认值, 所有列表都按照你指定的索引开始预加载 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.