Need help with StatusLayout?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

chenpengfei88
208 Stars 33 Forks 39 Commits 0 Opened issues

Description

让你的布局飞起来

Services available

!
?

Need anything else?

Contributors list

# 290,918
Java
19 commits

StatusLayout (让你的布局飞起来)

版本 V1.0

image

引用

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

compile 'com.github.chenpengfei88:StatusLayout:1.0'

使用

 StatusLayoutManager statusLayoutManager = StatusLayoutManager.newBuilder(this)
                .contentView(getContentView())
                .emptyDataView(R.layout.activity_emptydata)
                .errorView(R.layout.activity_error)
                .loadingView(R.layout.activity_loading)
                .netWorkErrorView(R.layout.activity_networkerror)
                .retryViewId(R.id.button_try)
                .onShowHideViewListener(new OnShowHideViewListener() {
                    @Override
                    public void onShowView(View view, int id) {
                    }

                @Override
                public void onHideView(View view, int id) {
                }
            }).onRetryListener(new OnRetryListener() {
                @Override
                public void onRetry() {
                    statusLayoutManager.showLoading();

                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(1000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }

                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    statusLayoutManager.showContent();
                                }
                            });
                        }
                    }).start();

                }
            }).build();

    mainLinearLayout.addView(statusLayoutManager.getRootLayout(), 1);

方法

StatusLayoutManager提供了一系列的方法来显示不同布局View之间的切换

   statusLayoutManager.showLoading();  显示loading加载view
   statusLayoutManager.showContent();  显示你的内容view
   statusLayoutManager.showEmptyData();  显示空数据view
   statusLayoutManager.showEmptyData(R.mipmap.empty_nodata, "暂时没有数据");
   statusLayoutManager.showError();  显示error view
   statusLayoutManager.showError(R.mipmap.empty_nodata, "服务器异常");
   statusLayoutManager.showNetWorkError();   显示网络异常view

#### 源码逻辑解析 http://www.jianshu.com/p/9d53893b3eda

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.