Coder Social home page Coder Social logo

pagestatushelper's Introduction

1、什么是PageStatusHelper

一款简单的、方便,解决页面各种状态的框架。

与其他方案的区别、优点

-几乎每个页面都需要加载中、加载失败、没有数据、没有网络。( 而普遍套一层的方案麻烦这里提出一种贴的方案 “贴”? 哪个View上要出现加载状态哪里贴,比如现在在ListView没有数据的时候加载一个提示数据为空的view,这时候我们就往ListView上贴,而不再套一层,而且使用方便 )

-单页面存在多个加载状态的时候,极其便利,因为他针对的是view

-杜绝数据未加载出来,出现点击错误显示异常

少废话先看效果

单页面多个接口

demo3 demo4

绑定部分区域加载

demo2

防止页面数据未加载出来点击错误 或者数据不雅

demo1

2、版本依赖

//添加jitpack仓库
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
//添加库
dependencies {
  implementation 'com.github.YuJunKui1995:PageStatusHelper:v1.1.0'
}

3、使用

1、简单使用 三行代码(简单模式下所有的状态view皆为TextView)

statusHelper = new PageStatusHelper(Context context)
//需要把加载状态绑定到那个view
statusHelper.bindView(View contentView);
statusHelper.refreshPageStatus(@PageStatusValue int pageStatusValue)

refreshPageStatus方法有如下类型
ERRORNO_LOGIN =、 LOADINGNET_WORK(网络异常)、 EMPTYCONTENT(正常内容)

2、定制使用使用

//可通过Builder对象对各个状态进行定制,text image layout view 等等都可以
statusHelper = new PageStatusHelper(Context context
                 , new Builder(Context context)
                 .setErrorImage(int imageId)
                 .setLoadingView(View view)
                 .setEmptyImage(int imageId)
                 .setNetworkLayout(int layoutId)
                 .setNoLoginText(String text)
         );

4、目前已知的问题

1、bindView的父布局为ViewPage下异常

2、在Fragment使用时bindView是根布局,而这个Fragment使用的地方需要show hide Fragment(常见为主页tab) 以上两个问题都可以通过在bindView包裹一层父布局解决

5、版本优化

1.0.0 版本 重构view的绘制流程用来支持对根布局的属性支持

约束布局使用不在需要每个view都设置id

约束布局中属性不全的优化支持,约束布局自定义view或layout的优化支持

相对布局的完成支持

瞬间多次调用(断网状态)的绘制优化

License MIT

Copyright (c) 2017-2020 YuJunKui

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

pagestatushelper's People

Contributors

yujunkui1995 avatar juniniho avatar wardenlzr 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.