Code Monkey home page Code Monkey logo

stuatuspage's Introduction

好处

封装前:
    状态布局文件写在当前Activity的布局中
    在Activity中需要相应的点击事件和部分控件的隐藏和显示
封装后:
    不需要在Activity中写布局
    只需要当成一个组件,差不多10行代码搞写
    逻辑很清晰,适合用来做组件化

效果

Alt text

使用

 引用

  Step 1. Add the JitPack repository to your build file
    Add it in your root build.gradle at the end of repositories:

        allprojects {
            repositories {
                ...
                maven { url 'https://jitpack.io' }
            }
        }
        
  Step 2. Add the dependency

        dependencies {
                compile 'com.github.guixin567:StuatusPage:1.0'
        }

继承BaseStatusPage

1,实现getLayout方法,根据自己的状态类别进行视图的赋值
2,重写getClickId,指定每个控件可以点击控件的ID,每个布局文件这个ID必须一致

Activiti中的使用

1,初始化状态页
    1,设置状态要替换的视图(当显示状态页时,要隐藏的视图)
    2,添加状态事件
        根据相应的控件类型,完成相应的点击事件
2,在相应的地方设置相应的状态页类型,并展示
     mStatusDialog.setType(StatusDialog.TYPE_ERROR)
    .show(getSupportFragmentManager());

原理

使用DialogFragment,将每个状态页当成一个Diaog这样就不会跟Activity的逻辑混 在一起,再提供相应的接口用于处理事件
优点:
    组件化
    侵入性低
    使用简单,逻辑清晰

stuatuspage's People

Contributors

guixin567 avatar

Watchers

James Cloos avatar  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.