Git Product home page Git Product logo

statusview-1's Introduction

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 : [email protected] .

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.

statusview-1's People

Contributors

wenqin-231 avatar

Watchers

James Cloos avatar Yongfeng Zhang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.