|
15 | 15 | - 可设置重新请求数据的事件
|
16 | 16 | - 可动态更新视图样式
|
17 | 17 | - 可结合绝大部分第三方控件使用
|
18 |
| -- 可对内容进行预处理 |
19 | 18 |
|
20 | 19 | ## 示例
|
21 | 20 |
|
@@ -53,7 +52,7 @@ allprojects {
|
53 | 52 |
|
54 | 53 | ```
|
55 | 54 | dependencies {
|
56 |
| - implementation 'com.github.DylanCaiCoding:LoadingHelper:2.2.0' |
| 55 | + implementation 'com.github.DylanCaiCoding:LoadingHelper:2.3.0' |
57 | 56 | }
|
58 | 57 | ```
|
59 | 58 |
|
@@ -124,9 +123,7 @@ errorAdapter.notifyDataSetChanged();
|
124 | 123 | 和前面的用法类似,先创建一个继承 `LoadingHelper.Adapter<VH extends ViewHolder>` 的标题栏适配器,然后就能在内容的上方添加标题栏了,可以添加多个头部。
|
125 | 124 |
|
126 | 125 | ```java
|
127 |
| -loadingHelper.register(ViewType.TITLE, new TitleAdapter("标题名")); |
128 |
| -loadingHelper.register(VIEW_TYPE_SEARCH, new SearchHeaderAdapter(onSearchListener)); |
129 |
| -loadingHelper.setDecorHeader(ViewType.TITLE, VIEW_TYPE_SEARCH); |
| 126 | +loadingHelper.setDecorHeader(new TitleAdapter("标题名"), new SearchHeaderAdapter(onSearchListener)); |
130 | 127 | ```
|
131 | 128 |
|
132 | 129 | 如果是**特殊的标题栏**,比如有联动效果,就不能直接使用上面的方式了。这时我们要给内容增加个装饰的容器。
|
@@ -202,30 +199,6 @@ loadingHelper.setDecorAdapter(new ScrollDecorAdapter());
|
202 | 199 |
|
203 | 200 | 上述的两种使用方式都是可以进行多次设置,不过每次设置会把上一次设置的样式给替换掉。
|
204 | 201 |
|
205 |
| -#### 预处理内容视图 |
206 |
| - |
207 |
| -创建一个适配器继承 `LoadingHelper.ContentAdapter<VH extends ViewHolder>`。如果想要使用 Activity 对象,可以在构造方法传入或者通过 contentView 获得。 |
208 |
| - |
209 |
| -```java |
210 |
| -public class CommonContentAdapter extends LoadingHelper.ContentAdapter<LoadingHelper.ViewHolder> { |
211 |
| - @Override |
212 |
| - public LoadingHelper.ViewHolder onCreateViewHolder(@NonNull View contentView) { |
213 |
| - return new LoadingHelper.ViewHolder(contentView); |
214 |
| - } |
215 |
| - |
216 |
| - @Override |
217 |
| - public void onBindViewHolder(@NonNull LoadingHelper.ViewHolder holder) { |
218 |
| - View contentView = holder.getRootView(); |
219 |
| - } |
220 |
| -} |
221 |
| -``` |
222 |
| - |
223 |
| -在创建 `LoadingHelper` 对象时传入 `ContentAdapter` 对象,就会立即对内容视图进行处理。 |
224 |
| - |
225 |
| -```java |
226 |
| -loadingHelper= new LoadingHelper(this, new CommonContentAdapter()); |
227 |
| -``` |
228 |
| - |
229 | 202 | ## 感谢
|
230 | 203 |
|
231 | 204 | - [luckbilly/Gloading](https://github.com/luckybilly/Gloading) 站在了巨人肩膀上优化了本库,非常感谢!
|
|
0 commit comments