Skip to content

Commit 1406707

Browse files
Merge remote-tracking branch 'origin/master'
2 parents d2824f2 + da499f9 commit 1406707

File tree

2 files changed

+95
-9
lines changed

2 files changed

+95
-9
lines changed

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
English | [中文](README_ZH_CN.md)
44

5+
>The original library name was [LoadingHelper](https://github.com/DylanCaiCoding/LoadingHelper)
6+
57
[![](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)
68

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 or customized view** when loading network data, but also **manages title bar.**
9+
`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.**
810

911
## Feature
1012

@@ -136,7 +138,17 @@ If you want to add an special title bar with linkage effect.
136138
Create a class extends `LoadingStateView.DecorViewDelegate` to create a decorated view and specify a loading container.
137139

138140
```java
139-
public class ScrollingDecorViewDelegate extends LoadingStateView.DecorViewDelegate { @NotNull @Override public View onCreateDecorView(@NotNull LayoutInflater inflater) { return inflater.inflate(R.layout.layout_scrolling, null); } @NotNull @Override public ViewGroup getContentParent(@NotNull View decorView) { return decorView.findViewById(R.id.content_parent); }}
141+
class ScrollingDecorViewDelegate : LoadingStateView.DecorViewDelegate() {
142+
@NotNull
143+
override fun onCreateDecorView(@NotNull inflater: LayoutInflater): View {
144+
return inflater.inflate(R.layout.layout_scrolling, null)
145+
}
146+
147+
@NotNull
148+
fun getContentParent(@NotNull decorView: View): ViewGroup {
149+
return decorView.findViewById(R.id.content_parent)
150+
}
151+
}
140152
```
141153

142154
Then set it up.
@@ -159,5 +171,18 @@ loadingStateView.setDecorView(new ScrollingDecorViewDelegate());
159171
## License
160172

161173
```
162-
Copyright (C) 2019. Dylan CaiLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
163-
```
174+
175+
Copyright (C) 2019. Dylan Cai
176+
177+
Licensed under the Apache License, Version 2.0 (the "License");
178+
you may not use this file except in compliance with the License.
179+
You may obtain a copy of the License at
180+
181+
http://www.apache.org/licenses/LICENSE-2.0
182+
183+
Unless required by applicable law or agreed to in writing, software
184+
distributed under the License is distributed on an "AS IS" BASIS,
185+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186+
See the License for the specific language governing permissions and
187+
limitations under the License.
188+
```

README_ZH_CN.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
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+
>原库名 [LoadingHelper](https://github.com/DylanCaiCoding/LoadingHelper/blob/main/README_CN.md)
8+
79
`LoadingStateView` 是一个深度解耦加载界面和标题栏的工具,只用了一个 Kotlin 文件实现,不算上注释少于 300 行代码。不仅能在请求网络数据时**显示加载中、加载成功、加载失败、无数据的视图或自定义视图**,还可以**对标题栏进行管理**
810

911
详细的标题栏用法可以查看这篇文章[《史上耦合度最低的添加标题栏方式》](https://juejin.im/post/5ef01e22e51d4573eb40dab1)
@@ -130,13 +132,60 @@ loadingStateView.setDecorHeader(new TitleViewDelegate("标题名"), new SearchHe
130132
先实现一个不含内容的布局。
131133

132134
```xml
133-
<?xml version="1.0" encoding="utf-8"?><androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:fitsSystemWindows="true" android:theme="@style/AppTheme.AppBarOverlay"> <com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:toolbarId="@+id/toolbar"> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/AppTheme.PopupOverlay" /> </com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.AppBarLayout> <FrameLayout android:id="@+id/content_parent" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /></androidx.coordinatorlayout.widget.CoordinatorLayout>
135+
<?xml version="1.0" encoding="utf-8"?>
136+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
137+
xmlns:app="http://schemas.android.com/apk/res-auto"
138+
android:layout_width="match_parent"
139+
android:layout_height="match_parent"
140+
android:fitsSystemWindows="true">
141+
142+
<com.google.android.material.appbar.AppBarLayout
143+
android:id="@+id/app_bar"
144+
android:layout_width="match_parent"
145+
android:layout_height="@dimen/app_bar_height"
146+
android:fitsSystemWindows="true"
147+
android:theme="@style/AppTheme.AppBarOverlay">
148+
149+
<com.google.android.material.appbar.CollapsingToolbarLayout
150+
android:id="@+id/toolbar_layout"
151+
android:layout_width="match_parent"
152+
android:layout_height="match_parent"
153+
android:fitsSystemWindows="true"
154+
app:contentScrim="?attr/colorPrimary"
155+
app:layout_scrollFlags="scroll|exitUntilCollapsed"
156+
app:toolbarId="@+id/toolbar">
157+
158+
<androidx.appcompat.widget.Toolbar
159+
android:id="@+id/toolbar"
160+
android:layout_width="match_parent"
161+
android:layout_height="?attr/actionBarSize"
162+
app:layout_collapseMode="pin"
163+
app:popupTheme="@style/AppTheme.PopupOverlay" />
164+
</com.google.android.material.appbar.CollapsingToolbarLayout>
165+
</com.google.android.material.appbar.AppBarLayout>
166+
167+
<FrameLayout
168+
android:id="@+id/content_parent"
169+
android:layout_width="match_parent"
170+
android:layout_height="match_parent"
171+
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
172+
</androidx.coordinatorlayout.widget.CoordinatorLayout>
134173
```
135174

136-
创建一个类继承另一个适配器 `LoadingStateView.DecorViewDelegate` ,加载实现的布局,并指定一个添加内容的容器。
175+
创建一个类继承 `LoadingStateView.DecorViewDelegate` ,加载实现的布局,并指定一个添加内容的容器。
137176

138177
```java
139-
public class ScrollingDecorViewDelegate extends LoadingStateView.DecorViewDelegate { @NotNull @Override public View onCreateDecorView(@NotNull LayoutInflater inflater) { return inflater.inflate(R.layout.layout_scrolling, null); } @NotNull @Override public ViewGroup getContentParent(@NotNull View decorView) { return decorView.findViewById(R.id.content_parent); }}
178+
class ScrollingDecorViewDelegate : LoadingStateView.DecorViewDelegate() {
179+
@NotNull
180+
override fun onCreateDecorView(@NotNull inflater: LayoutInflater): View {
181+
return inflater.inflate(R.layout.layout_scrolling, null)
182+
}
183+
184+
@NotNull
185+
fun getContentParent(@NotNull decorView: View): ViewGroup {
186+
return decorView.findViewById(R.id.content_parent)
187+
}
188+
}
140189
```
141190

142191
最后设置一下就可以了。
@@ -161,5 +210,17 @@ loadingStateView.setDecorView(new ScrollingDecorViewDelegate());
161210
## License
162211

163212
```
164-
Copyright (C) 2019. Dylan CaiLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
165-
```
213+
Copyright (C) 2019. Dylan Cai
214+
215+
Licensed under the Apache License, Version 2.0 (the "License");
216+
you may not use this file except in compliance with the License.
217+
You may obtain a copy of the License at
218+
219+
http://www.apache.org/licenses/LICENSE-2.0
220+
221+
Unless required by applicable law or agreed to in writing, software
222+
distributed under the License is distributed on an "AS IS" BASIS,
223+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
224+
See the License for the specific language governing permissions and
225+
limitations under the License.
226+
```

0 commit comments

Comments
 (0)