Skip to content

Commit e1b4623

Browse files
Prepare for release 4.0.0
1 parent 7716e14 commit e1b4623

15 files changed

+143
-355
lines changed

README.md

+25-116
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# LoadingStateView
22

3-
English | [中文](README_ZH_CN.md)
3+
English | [中文](README_ZH.md)
44

55
[![](https://www.jitpack.io/v/DylanCaiCoding/LoadingStateView.svg)](https://www.jitpack.io/#DylanCaiCoding/LoadingLoadingStateView) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/LICENSE)
66

7-
`LoadingStateView` is a highly expandable Android library for showing loading status view on the low-coupling way, it is implemented with a Kotlin code of less than 300 lines without comment statement . it not only **shows different view like loading, content, error, empty and customized view** when loading network data, but also **manages title bar.**
7+
`LoadingStateView` is a highly expandable Android library for showing loading status view on the low-coupling way, the core function is implemented with a [Kotlin file](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/loadingstateview/src/main/java/com/dylanc/loadingstateview/LoadingStateView.kt) of about 200 lines without comment statement . it not only shows different view like loading, content, error, empty and customized view when loading network data, but also manages title bar.
8+
9+
**Major update: With the Kotlin feature, you can quickly add all functionality to the base class without affecting existing code. The overall usage is further simplified with removing the `ViewHolder`. It is recommended to upgrade!**
810

911
## Feature
1012

1113
- No need to add view code to the layout.
12-
- Support for show custom views.
14+
- Quickly add all functionality to the base class without affecting existing code. (Kotlin)
1315
- Support for use for Activity, Fragment, RecyclerView, View.
16+
- Support for show custom views.
1417
- Support for managing the title bar and add multiple headers.
1518
- Support for set reload event.
1619
- Support for update views anytime.
@@ -20,25 +23,28 @@ English | [中文](README_ZH_CN.md)
2023

2124
Click or scan QR code to download
2225

23-
[![QR code](img/app_download_qr_code.png)](https://www.pgyer.com/loadinghelper)
26+
[![QR code](docs/img/app_download_qr_code.png)](https://www.pgyer.com/loadinghelper)
2427

25-
| [Activity(error)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/ActErrorActivity.java) | [View(placeholder)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/ViewPlaceholderActivity.java) | [ViewPager(timeout)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/ViewPagerActivity.java) | [RecyclerView(cool loading)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/RecyclerViewActivity.java) |
28+
| [Activity(error)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ActErrorActivity.java) | [View(placeholder)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ViewPlaceholderActivity.java) | [ViewPager(timeout)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ViewPagerActivity.java) | [RecyclerView(cool loading)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/RecyclerViewActivity.java) |
2629
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
27-
| ![](gif/activity_error.gif) | ![](gif/view_placeholder.gif) | ![](gif/viewpager_timeout.gif) | ![](gif/recyclerview_loading.gif) |
30+
| ![](docs/gif/activity_error.gif) | ![](docs/gif/view_placeholder.gif) | ![](docs/gif/viewpager_timeout.gif) | ![](docs/gif/recyclerview_loading.gif) |
2831

29-
| [SpecialHeader(custom)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/CustomHeaderActivity.java) | [MultipleHeader(search)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/MultipleHeaderActivity.java) | [SpecialDecorView(scrolling)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/ScrollingToolbarActivity.java) | [BottomDecorView(editor)](app/src/main/java/com/dylanc/loadingstateview/sample/ui/BottomEditorActivity.java) |
32+
| [SpecialHeader(custom)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/CustomHeaderActivity.java) | [MultipleHeader(search)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/MultipleHeaderActivity.java) | [SpecialDecorView(scrolling)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ScrollingToolbarActivity.java) | [BottomDecorView(editor)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/BottomEditorActivity.java) |
3033
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
31-
| ![](gif/special_header_custom.gif) | ![](gif/multiple_header_search.gif) | ![](gif/special_decor_scrolling.gif) | ![](gif/bottom_decor_editor.gif) |
34+
| ![](docs/gif/special_header_custom.gif) | ![](docs/gif/multiple_header_search.gif) | ![](docs/gif/special_decor_scrolling.gif) | ![](docs/gif/bottom_decor_editor.gif) |
3235

36+
## Usage
3337

34-
## Getting started
38+
:pencil: **[>> Usage documentation <<](https://dylancaicoding.github.io/LoadingStateView)**
39+
40+
## Gradle
3541

3642
Add it in your root `build.gradle` at the end of repositories:
3743

3844
```groovy
3945
allprojects {
4046
repositories {
41-
...
47+
// ...
4248
maven { url 'https://www.jitpack.io' }
4349
}
4450
}
@@ -48,124 +54,27 @@ Add dependencies in your module `build.gradle` :
4854

4955
```groovy
5056
dependencies {
51-
implementation 'com.github.DylanCaiCoding:LoadingStateView:3.0.1'
52-
}
53-
```
54-
55-
### Usage
56-
57-
#### Step 1. Create a class extends `LoadingStateView.ViewDelegate<VH extends ViewHolder>`, for example:
58-
59-
```java
60-
public class LoadingViewDelegate extends LoadingStateView.ViewDelegate<LoadingStateView.ViewHolder> {
61-
62-
@NonNull
63-
@Override
64-
public LoadingStateView.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
65-
return new LoadingStateView.ViewHolder(inflater.inflate(R.layout.layout_loading_view, parent, false));
66-
}
67-
68-
@Override
69-
public void onBindViewHolder(@NonNull LoadingStateView.ViewHolder holder) {
70-
}
71-
}
72-
```
73-
74-
#### Step 2. Register `ViewDelegate` with a view type, for example:
75-
76-
```java
77-
LoadingStateView loadingStateView = new LoadingStateView(this);
78-
loadingStateView.register(ViewType.LOADING, new LoadingViewDelegate());
79-
```
80-
81-
##### Or if you want to register a global `ViewDelegate`.
82-
83-
```java
84-
loadingStateView.setViewDelegatePool(pool -> {
85-
pool.register(ViewType.LOADING, new LoadingViewDelegate());
86-
});
87-
```
88-
89-
#### Step 3. Show view by view type, for example:
57+
// java
58+
implementation 'com.github.DylanCaiCoding.LoadingStateView:loadingstateview:4.0.0'
9059
91-
```java
92-
loadingStateView.showView(viewType);
93-
loadingStateView.showLoadingView(); // view type is ViewType.LOADING
94-
loadingStateView.showContentView(); // view type is ViewType.CONTENT
95-
loadingStateView.showErrorView(); // view type is ViewType.ERROR
96-
loadingStateView.showEmptyView(); // view type is ViewType.EMPTY
97-
```
98-
99-
#### When you need to reload data.
100-
101-
```java
102-
loadingStateView.setOnReloadListener(new LoadingStateView.OnReloadListener() {
103-
@Override
104-
public void onReload() {
105-
// request data again
106-
}
107-
});
108-
109-
//In the adapter
110-
holder.getOnReloadListener.onReload();
111-
```
112-
113-
#### When you need to change view after view showed.
114-
115-
```java
116-
loadingStateView.updateView(ViewType.ERROR, (ErrorViewDelegate delegate) -> {
117-
delegate.msg = "Fail to load, please wait";
118-
});
119-
```
120-
121-
### Advanced usage
122-
123-
#### Add title view
124-
125-
If you want to add an ordinary title bar above the content.
126-
127-
Similar to the previous usage, create a class extends `LoadingStateView.ViewDelegate<VH extends ViewHolder>` and set header.
128-
129-
```java
130-
loadingStateView.setDecorHeader(new TitleViewDelegate("title"), new SearchHeaderViewDelegate());
131-
```
132-
133-
If you want to add an special title bar with linkage effect.
134-
135-
Create a class extends `LoadingStateView.DecorViewDelegate` to create a decorated view and specify a loading container.
136-
137-
```java
138-
class ScrollingDecorViewDelegate : LoadingStateView.DecorViewDelegate() {
139-
@NotNull
140-
override fun onCreateDecorView(@NotNull inflater: LayoutInflater): View {
141-
return inflater.inflate(R.layout.layout_scrolling, null)
142-
}
143-
144-
@NotNull
145-
fun getContentParent(@NotNull decorView: View): ViewGroup {
146-
return decorView.findViewById(R.id.content_parent)
147-
}
60+
// kotlin
61+
implementation 'com.github.DylanCaiCoding.LoadingStateView:loadingstateview-ktx:4.0.0'
14862
}
14963
```
15064

151-
Then set it up.
152-
153-
```java
154-
loadingStateView.setDecorView(new ScrollingDecorViewDelegate());
155-
```
15665

157-
## LoadingHelper's migration Guide
66+
## Change log
15867

159-
The original name of this library is `LoadingHelper`, and some class and method names should be changed later. Old users can check the [migration guide](https://github.com/DylanCaiCoding/LoadingHelper) and change it to the latest usage. If you feel troublesome and are not obsessive-compulsive, you can also not migrate.
68+
[Releases](https://github.com/DylanCaiCoding/LoadingStateView/releases)
16069

16170
## Author's other libraries
16271

16372
| Library | Description |
16473
| ------------------------------------------------------------ | ------------------------------------------------------------ |
165-
| [Longan](https://github.com/DylanCaiCoding/Longan) | A collection of Kotlin utils which makes Android application development faster and easier. |
74+
| [Longan](https://github.com/DylanCaiCoding/Longan) | Probably the best Kotlin utils library for Android. |
16675
| [ViewBindingKTX](https://github.com/DylanCaiCoding/ViewBindingKTX) | The most comprehensive utils of ViewBinding. |
167-
| [MMKV-KTX](https://github.com/DylanCaiCoding/MMKV-KTX) | Easier to use the MMKV. |
168-
| [ActivityResultLauncher](https://github.com/DylanCaiCoding/ActivityResultLauncher) | Perfect replacement for `startActivityForResult()` |
76+
| [MMKV-KTX](https://github.com/DylanCaiCoding/MMKV-KTX) | Use MMKV with property delegates. |
77+
| [Tracker](https://github.com/DylanCaiCoding/Tracker) | A lightweight tracking framework based on the tracking idea of Buzzvideo.|
16978

17079
## Thanks
17180

README_ZH.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# LoadingStateView
2+
3+
[English](README.md) | 中文
4+
5+
[![](https://www.jitpack.io/v/DylanCaiCoding/LoadingStateView.svg)](https://www.jitpack.io/#DylanCaiCoding/LoadingLoadingStateView) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/LICENSE)
6+
7+
`LoadingStateView` 是一个深度解耦缺省页和标题栏的工具,核心功能的实现代码只有一个 200 行左右(不算注释)的 [Kotlin 文件](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/loadingstateview/src/main/java/com/dylanc/loadingstateview/LoadingStateView.kt)。不仅能在请求网络数据时显示加载中、加载成功、加载失败、无数据的视图或自定义视图,还可以对标题栏进行解耦。
8+
9+
**重大更新:结合 Kotlin 语法特性能快速将所有功能集成到基类,不会影响已有代码。移除了 `ViewHolder`,整体用法得到进一步简化,建议升级!**
10+
11+
- 无需在布局添加视图代码
12+
- 支持快速集成到基类,并且不影响有代码(仅 Kotlin)
13+
- 支持 Activity、Fragment、列表或指定的 View
14+
- 支持显示自定义视图
15+
- 支持添加多个头部控件
16+
- 支持设置重新请求数据的事件
17+
- 支持动态更新视图样式
18+
- 可结合绝大部分第三方控件使用
19+
20+
## 示例
21+
22+
点击或者扫描二维码下载
23+
24+
[![QR code](docs/img/app_download_qr_code.png)](https://www.pgyer.com/loadinghelper)
25+
26+
动态添加加载状态的布局:
27+
28+
| [Activity(error)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ActErrorActivity.java) | [View(placeholder)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ViewPlaceholderActivity.java) | [ViewPager(timeout)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ViewPagerActivity.java) | [RecyclerView(cool loading)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/RecyclerViewActivity.java) |
29+
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
30+
| ![](docs/gif/activity_error.gif) | ![](docs/gif/view_placeholder.gif) | ![](docs/gif/viewpager_timeout.gif) | ![](docs/gif/recyclerview_loading.gif) |
31+
32+
动态添加标题栏或装饰容器:
33+
34+
| [SpecialHeader(custom)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/CustomHeaderActivity.java) | [MultipleHeader(search)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/MultipleHeaderActivity.java) | [SpecialDecorView(scrolling)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/ScrollingToolbarActivity.java) | [BottomDecorView(editor)](https://github.com/DylanCaiCoding/LoadingStateView/blob/master/sample-java/src/main/java/com/dylanc/loadingstateview/sample/java/ui/BottomEditorActivity.java) |
35+
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
36+
| ![](docs/gif/special_header_custom.gif) | ![](docs/gif/multiple_header_search.gif) | ![](docs/gif/special_decor_scrolling.gif) | ![](docs/gif/bottom_decor_editor.gif) |
37+
38+
## 用法
39+
40+
:pencil: **[>> 使用文档 <<](https://dylancaicoding.github.io/LoadingStateView)**
41+
42+
## Gradle
43+
44+
在根目录的 `build.gradle` 添加:
45+
46+
```groovy
47+
allprojects {
48+
repositories {
49+
// ...
50+
maven { url 'https://www.jitpack.io' }
51+
}
52+
}
53+
```
54+
55+
在模块的 `build.gradle` 添加依赖:
56+
57+
```groovy
58+
dependencies {
59+
// java
60+
implementation 'com.github.DylanCaiCoding.LoadingStateView:loadingstateview:4.0.0'
61+
62+
// kotlin
63+
implementation 'com.github.DylanCaiCoding.LoadingStateView:loadingstateview-ktx:4.0.0'
64+
}
65+
```
66+
67+
## 更新日志
68+
69+
[Releases](https://github.com/DylanCaiCoding/LoadingStateView/releases)
70+
71+
## 作者其它的库
72+
73+
|| 简介 |
74+
| ------------------------------------------------------------ | ---------------------------------------------- |
75+
| [Longan](https://github.com/DylanCaiCoding/Longan) | 可能是最好用的 Kotlin 工具库 |
76+
| [ViewBindingKTX](https://github.com/DylanCaiCoding/ViewBindingKTX) | 最全面的 ViewBinding 工具 |
77+
| [MMKV-KTX](https://github.com/DylanCaiCoding/MMKV-KTX) | 用属性委托的方式使用 MMKV |
78+
| [Tracker](https://github.com/DylanCaiCoding/Tracker) | 基于西瓜视频的责任链埋点思路实现的轻量级埋点框架 |
79+
80+
## 感谢
81+
82+
- [luckbilly/Gloading](https://github.com/luckybilly/Gloading) 站在了巨人肩膀上优化了本库,非常感谢!
83+
- [drakeet/MultiType](https://github.com/drakeet/MultiType) 参考了注册配置多适配器的思想和用法
84+
- [dinuscxj/LoadingDrawable](https://github.com/dinuscxj/LoadingDrawable) 示例中的自定义加载动画
85+
86+
## License
87+
88+
```
89+
Copyright (C) 2019. Dylan Cai
90+
91+
Licensed under the Apache License, Version 2.0 (the "License");
92+
you may not use this file except in compliance with the License.
93+
You may obtain a copy of the License at
94+
95+
http://www.apache.org/licenses/LICENSE-2.0
96+
97+
Unless required by applicable law or agreed to in writing, software
98+
distributed under the License is distributed on an "AS IS" BASIS,
99+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
100+
See the License for the specific language governing permissions and
101+
limitations under the License.
102+
```

0 commit comments

Comments
 (0)