Git Product home page Git Product logo

dialogchainhelper's Introduction

DialogChainHelper是为了解决多个弹窗同时弹出,影响体验的问题


效果图:


框架特性

  • 使用TreeMap存放弹窗,在当前弹窗消失时,自动弹出下一个弹窗
  • 同时支持DialogFragment和普通Dialog, 支持配置弹窗优先级
  • 不需要手动设置DismissListener,避免回调地狱,在多个弹窗的场景下,代码量依旧非常少
  • 不需要继承类和接口,接入方便

使用方法

  • 添加依赖
allprojects {repositories {...
		maven { url 'https://jitpack.io' }
}}
	
dependencies { implementation 'com.github.NByida:DialogChainHelper:V2.0'}	
	
  • 构建DialogChainHelper对象
        var dialogChainHelper = DialogChainHelper()
  • 添加Dialog
       dialogChainHelper.addDialog {
            level=7
            showDialog={
                 val dialog=mockDialog(7)
                dialog.show()
                dialog
            }
        }

  • 添加popwindow
        dialogChainHelper.addPopWindow {
            level=2
            showPopWindow={
                val imageView=ImageView(this@MainActivity)
                imageView.layoutParams=ViewGroup.LayoutParams(200,200)
                imageView.setImageResource(R.drawable.ic_launcher_background)
                val pop=PopupWindow(imageView)
                pop.width=300
                pop.height=300
                val view =findViewById<TextView>(R.id.layText)
                pop.isOutsideTouchable = true;
                pop.showAsDropDown( view)
                pop
            }
        }

  • 添加Dialogfragment
      dialogChainHelper.addDialogFragment {
            level=1
            showDialogFragment={
                val dialogFragment=DialogFragment1()
                dialogFragment.show(supportFragmentManager,"1")
                dialogFragment
            }
        }

  • 取消注册
    • 在activity destroy的时候,调用unRegister,清空dialog队列
   override fun onDestroy() {
       super.onDestroy()
       dialogChainHelper.unRegister()
   }

具体使用方法,可参照demo里com.yida.dialogchainhelper.MainActivity

dialogchainhelper's People

Contributors

nbyida avatar

Stargazers

Luke Wong avatar yangfeng avatar  avatar  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.