show different Android views by various status
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app Fix error in BottomNavigationView demo Nov 3, 2017
art
gradle/wrapper init projetc Oct 22, 2017
lib Fix the method of setting margin Jan 12, 2018
.gitignore Feat: fix some code Oct 23, 2017
LICENSE
README.md Update README.md Jan 12, 2018
build.gradle Feat: fix some code Oct 23, 2017
gradle.properties init projetc Oct 22, 2017
gradlew init projetc Oct 22, 2017
gradlew.bat init projetc Oct 22, 2017
settings.gradle

README.md

StatusView

This is a library to help you show the different status of view such as loading , empty and error easily.

Features

  • Support both in Activity and Fragment.
  • Support the custom view of different status.
  • Support the way to retry request by default button in error status.
  • Easily use.
  • With a delay loading by default avoid the too fast loading.
  • Support the Toolbar、NavigationBottomBar and etc.
  • Can use it with my forked SpringView gracefully.

Demo

Download Demo

  • It is the different status of Dialog, Error and Empty.

Usage

  • Use it with BaseStatusActivity or BaseStatusFragment :
public class LoadingActivity extends BaseStatusActivity {
  	// use it just by two line of code
  	// when you want to load something 
  	mStatusView.setStatus(Status.LOADING);
	// after loading finish 
  	mStatusView.setStatus(Status.Normal);
  	
 	// add a DefaultToolbar by default and you can setTitle or setCenterTitle for it.
  	setTitle("Loading in Activity");
}
  • Use it without BaseStatusActivity or BaseStatusFragment :
// init StatusView in Activity 
mStatusView = StatusView.initInActivity(this);
// setup btn click in Error View
mStatusView.setOnRetryBtnClickListener(new OnRetryBtnClickListener() {
	@Override
	public void onClick(View view) {
		onNormalLoadingClick(view);
	}
});
  • Besides, you can set the code in your BaseActivity or BaseFragment by copying the code from BaseStatusActivity or BaseStatusFragment
// init StatusView with default ToolBar in BasseFragment
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
	super.onViewCreated(view, savedInstanceState);
	StatusManager statusManager = StatusManager
		// Should be this and not set getActivity in it.
		.get(this)
		// Set your ContentView and it is usually the view that created in OnCreateView().
		.setContentView(view)
		// Set true to add a StatusView in your view and set false to avoid loading the unnecessary setting.
		.isAddStatusView(true)
		// Set true to add a Toolbar and set false the setToolbar() will be invalid.
		.isAddToolbar(true)
		// There will create a DefaultToolbar if you set null in it.
		.setToolbar(onCreateToolbar())
		.launch();

		mStatusView = statusManager.getStatusView();
		mToolbar = statusManager.getToolbar();
}

The code is so simple and you can set your custom attributes by using StatusManager.

More ways of usage can be found in my demo.

Dependency

Step 1. Add the JitPack repository to your build file

allprojects {
   repositories {
      ...
      maven { url 'https://jitpack.io' }
   }
}

Step 2. Add the dependency

dependencies {
   compile 'com.github.wenqin-231:StatusView:v0.35'
}

More

The default empty view and error view are from dribbble.

BTW, I write a blog in Chinese about it.

At last , if you have an idea or others, you can contact with me by my Email : wenqin231@gmail.com .

Hope you will like it.

LICENSE

Copyright (c) 2017 wenqin-231

Licensed 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.0

Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.