1- # LoadingHelper
1+ # LoadingStateView
22
33English | [ 中文] ( README_ZH_CN.md )
44
5- [ ![ ] ( https://www.jitpack.io/v/DylanCaiCoding/LoadingHelper .svg )] ( https://www.jitpack.io/#DylanCaiCoding/LoadingHelper ) [ ![ ] ( https://img.shields.io/badge/License-Apache--2.0-blue.svg )] ( https://github.com/DylanCaiCoding/LoadingHelper /blob/master/LICENSE )
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 )
66
7- ` LoadingHelper ` 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.**
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.**
88
99## Feature
1010
@@ -22,18 +22,19 @@ Click or scan QR code to download
2222
2323[ ![ QR code] ( img/app_download_qr_code.png )] ( https://www.pgyer.com/loadinghelper )
2424
25- | [ Activity(error)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/ActErrorActivity.java ) | [ View(placeholder)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/ViewPlaceholderActivity.java ) | [ ViewPager(timeout)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/ViewPagerActivity.java ) | [ RecyclerView(cool loading)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/RecyclerViewActivity.java ) |
26- | :---: | :----: | :---: | :---: |
27- | ![ ] ( gif/activity_error.gif ) | ![ ] ( gif/view_placeholder.gif ) | ![ ] ( gif/viewpager_timeout.gif ) | ![ ] ( gif/recyclerview_loading.gif ) |
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 ) |
26+ | :---------------------------------------------------------- : | :---------------------------------------------------------- : | :---------------------------------------------------------- : | :------------------------------------------------------- ---: |
27+ | ![ ] ( gif/activity_error.gif ) | ![ ] ( gif/view_placeholder.gif ) | ![ ] ( gif/viewpager_timeout.gif ) | ![ ] ( gif/recyclerview_loading.gif ) |
2828
29- | [ SpecialHeader(custom)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/CustomHeaderActivity.java ) | [ MultipleHeader(search)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/MultipleHeaderActivity.java ) | [ SpecialDecorView(scrolling)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/ScrollingToolbarActivity.java ) | [ BottomDecorView(editor)] ( app/src/main/java/com/dylanc/loadinghelper /sample/ui/BottomEditorActivity.java ) |
30- | :---: | :---: | :---: | :---: |
31- | ![ ] ( gif/special_header_custom.gif ) | ![ ] ( gif/multiple_header_search.gif ) | ![ ] ( gif/special_decor_scrolling.gif ) | ![ ] ( gif/bottom_decor_editor.gif ) |
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 ) |
30+ | :---------------------------------------------------------- : | :---------------------------------------------------------- : | :---------------------------------------------------------- : | :------------------------------------------------------- ---: |
31+ | ![ ] ( gif/special_header_custom.gif ) | ![ ] ( gif/multiple_header_search.gif ) | ![ ] ( gif/special_decor_scrolling.gif ) | ![ ] ( gif/bottom_decor_editor.gif ) |
3232
3333
3434## Getting started
3535
3636Add it in your root ` build.gradle ` at the end of repositories:
37+
3738``` groovy
3839allprojects {
3940 repositories {
@@ -45,62 +46,61 @@ allprojects {
4546
4647Add dependencies in your module ` build.gradle ` :
4748
48- ```
49+ ``` groovy
4950dependencies {
50- implementation 'com.github.DylanCaiCoding:LoadingHelper:2. 3.0'
51+ implementation 'com.github.DylanCaiCoding:LoadingStateView: 3.0.0-alpha '
5152}
5253```
5354
5455### Usage
5556
56- #### Step 1. Create a class extends ` LoadingHelper.Adapter <VH extends ViewHolder>` , for example:
57+ #### Step 1. Create a class extends ` LoadingStateView.ViewDelegate <VH extends ViewHolder>` , for example:
5758
5859``` java
59- public class LoadingAdapter extends LoadingHelper . Adapter< LoadingHelper .ViewHolder > {
60+ public class LoadingViewDelegate extends LoadingStateView . ViewDelegate< LoadingStateView .ViewHolder > {
6061
6162 @NonNull
6263 @Override
63- public LoadingHelper .ViewHolder onCreateViewHolder (@NonNull LayoutInflater inflater , @NonNull ViewGroup parent ) {
64- return new LoadingHelper .ViewHolder (inflater. inflate(R . layout. layout_loading_view, parent, false ));
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 ));
6566 }
6667
6768 @Override
68- public void onBindViewHolder (@NonNull LoadingHelper .ViewHolder holder ) {
69-
69+ public void onBindViewHolder (@NonNull LoadingStateView .ViewHolder holder ) {
7070 }
7171}
7272```
7373
74- #### Step 2. Register your adapter with a view type, for example:
74+ #### Step 2. Register ` ViewDelegate ` with a view type, for example:
7575
7676``` java
77- LoadingHelper loadingHelper = new LoadingHelper (this );
78- loadingHelper . register(ViewType . LOADING , new LoadingAdapter ());
77+ LoadingStateView loadingStateView = new LoadingStateView (this );
78+ loadingStateView . register(ViewType . LOADING , new LoadingViewDelegate ());
7979```
8080
81- ##### Or if you want to register a global adapter .
81+ ##### Or if you want to register a global ` ViewDelegate ` .
8282
8383``` java
84- LoadingHelper . setDefaultAdapterPool(adapterPool - > {
85- adapterPool . register(ViewType . LOADING , new LoadingAdapter ());
86- return Unit . INSTANCE ;
84+ loadingStateView . setViewDelegatePool(pool - > {
85+ pool . register(ViewType . LOADING , new LoadingViewDelegate ());
86+ return null ;
8787});
8888```
8989
9090#### Step 3. Show view by view type, for example:
9191
9292``` java
93- loadingHelper . showView(viewType);
94- loadingHelper . showLoadingView(); // view type is ViewType.LOADING
95- loadingHelper . showContentView(); // view type is ViewType.CONTENT
96- loadingHelper . showErrorView(); // view type is ViewType.ERROR
97- loadingHelper . showEmptyView(); // view type is ViewType.EMPTY
93+ loadingStateView . showView(viewType);
94+ loadingStateView . showLoadingView(); // view type is ViewType.LOADING
95+ loadingStateView . showContentView(); // view type is ViewType.CONTENT
96+ loadingStateView . showErrorView(); // view type is ViewType.ERROR
97+ loadingStateView . showEmptyView(); // view type is ViewType.EMPTY
9898```
9999
100100#### When you need to reload data.
101101
102102``` java
103- loadingHelper . setOnReloadListener(new LoadingHelper .OnReloadListener () {
103+ loadingStateView . setOnReloadListener(new LoadingStateView .OnReloadListener () {
104104 @Override
105105 public void onReload () {
106106 // request data again
@@ -114,9 +114,9 @@ holder.getOnReloadListener.onReload();
114114#### When you need to change view after view showed.
115115
116116``` java
117- ErrorAdapter adapter = loadingHelper . getAdapter (ViewType . Error );
118- adapter . errorText = " Fail to load, please wait" ;
119- adapter . notifyDataSetChanged();
117+ ErrorViewDelegate errorViewDelegate = loadingStateView . getViewDelegate (ViewType . ERROR );
118+ errorViewDelegate . errorText = " Fail to load, please wait" ;
119+ loadingStateView . notifyDataSetChanged(ViewType . ERROR );
120120```
121121
122122### Advanced usage
@@ -125,42 +125,30 @@ adapter.notifyDataSetChanged();
125125
126126If you want to add an ordinary title bar above the content.
127127
128- Similar to the previous usage, create a class extends ` LoadingHelper.Adapter <VH extends ViewHolder>` and set header.
128+ Similar to the previous usage, create a class extends ` LoadingStateView.ViewDelegate <VH extends ViewHolder>` and set header.
129129
130130``` java
131- loadingHelper . setDecorHeader(new TitleAdapter (" title" ), new SearchHeaderAdapter (onSearchListener ));
131+ loadingStateView . setDecorHeader(new TitleViewDelegate (" title" ), new SearchHeaderViewDelegate ( ));
132132```
133133
134134If you want to add an special title bar with linkage effect.
135135
136- Create a class extends ` LoadingHelper.DecorAdapter ` to create a decorated view and specify a loading container.
136+ Create a class extends ` LoadingStateView.DecorViewDelegate ` to create a decorated view and specify a loading container.
137137
138138``` java
139- public class ScrollDecorAdapter extends LoadingHelper .DecorAdapter {
140- @NotNull
141- @Override
142- public View onCreateDecorView (@NotNull LayoutInflater inflater ) {
143- return inflater. inflate(R . layout. layout_scrolling, null );
144- }
145-
146- @NotNull
147- @Override
148- public ViewGroup getContentParent (@NotNull View decorView ) {
149- return decorView. findViewById(R . id. content_parent);
150- }
151- }
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); }}
152140```
153141
154142Then set it up.
155143
156144``` java
157- loadingHelper . setDecorAdapter (new ScrollDecorAdapter ());
145+ loadingStateView . setDecorView (new ScrollingDecorViewDelegate ());
158146```
159147
160148## Author's other libraries
161149
162- - [ LoadingHelper] ( https://github.com/DylanCaiCoding/LoadingHelper ) , a highly expandable Android library for decoupling the code of toolbar or loading status view.
163150- [ ViewBindingKTX] ( https://github.com/DylanCaiCoding/ViewBindingKTX ) , the most comprehensive utils of ViewBinding.
151+ - [ ActivityResultLauncher] ( https://github.com/DylanCaiCoding/ActivityResultLauncher ) , perfect replacement for ` startActivityForResult() `
164152
165153## Thanks
166154
@@ -171,17 +159,5 @@ loadingHelper.setDecorAdapter(new ScrollDecorAdapter());
171159## License
172160
173161```
174- Copyright (C) 2019. Dylan Cai
175-
176- Licensed under the Apache License, Version 2.0 (the "License");
177- you may not use this file except in compliance with the License.
178- You may obtain a copy of the License at
179-
180- http://www.apache.org/licenses/LICENSE-2.0
181-
182- Unless required by applicable law or agreed to in writing, software
183- distributed under the License is distributed on an "AS IS" BASIS,
184- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
185- See the License for the specific language governing permissions and
186- limitations under the License.
187- ```
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+ ```
0 commit comments