Code Monkey home page Code Monkey logo

statuswarplayout's Introduction

StatusWrapLayout【Chinese

ui library to wrap your page to handle different states(like error,empty,others)

feature

there are default status to use for your page error,empty,others. when there no data to display ,u can use default empty status page to cover ur page, like above

image

by the way ,if u think deafult status page can not satisfy your request, ni can alse use custom page like this. to dispaly error status

image

and this all is easy to use.

Usage

get it

 dependencies {
     compile 'com.yich.libary.layout:statuswraplayout:1.0.2'
}

use

first use it in layout xml

<com.yich.libary.layout.StatusWrapLayout
  android:id="@+id/maskLay"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
<TextView
  android:textSize="30sp"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="this is content!!!"
  android:layout_centerInParent="true"
  android:textColor="@android:color/black"/></com.yich.libary.layout.StatusWrapLayout>

second

in your java code when u are loading data u can use showLoading (and more others status ,please refer to other api)

  // befor process data show loading status
          mStatusWrapLayout.showLoading(null);

Advanced Features

when there are default status can not satisfy your requirement,u can use custom status view to wrap your page. u first create your custom status view must implement IStatusView

public interface IStatusView {
 /**
  * init view
  */
 public boolean initView(Context context);

 /**
  * get current chunk of view
  * @return  view
  */
 public View getView();

 /**
  * {@link StatusWrapLayout}
  * @return get current  view status
  */
 public StatusWrapLayout.State getViewType();

 /**
  *  when view show  call back
  * @param listener user click current status view listener
  * @param params input params
  */
 public void onShowStatusView(OnUserClickListener listener, Object... params);

 /**
  *when view gone  call back
  * @param params   input params
  */
 public void onGoneStatusView(Object... params);

 /**
   * @param listener user click current status view listener
  * @param param  input params
  */
 public void updataStatusView(OnUserClickListener listener, Object... param);}

then u can easily add your status view to StatusWrapLayout by this code change to your custome view

          StatusWrapLayout.Builder builder=new StatusWrapLayout.Builder();
          //change interest status  to replace this status view
          builder.setLoadingView(new MyloadingView())
                  .setErrorView(new MyErrorView())
                  .setOhterView(new MyOtherView())
                  .setEmptyView(new MyEmptyView())
                  .build(mStatusWrapLayout);

NOTES

This library is inspired by progress-activity library from vlonjatg.

statuswarplayout's People

Contributors

pmotato avatar

Stargazers

 avatar

Watchers

 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.