All Projects → o0o0oo00 → FancyDialog

o0o0oo00 / FancyDialog

Licence: other
Kotlin + DSL风格代替传统的Builder模式 诸多可配置项 高阶函数代替自定义回调接口 书写起来超级顺手

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to FancyDialog

aws-lambda-scheduler
aws-lambda-scheduler is EventBridge Rule manager that lets you call any existing AWS Lambda Function you have in a set future time with pre-set parameters. Allows more rule creation than AWS limit.
Stars: ✭ 58 (+141.67%)
Mutual labels:  lambda
angular-custom-modal
Angular2+ Modal / Dialog (with inner component support).
Stars: ✭ 30 (+25%)
Mutual labels:  dialog
aws-is-how
Know How Guide and Hands on Guide for AWS
Stars: ✭ 27 (+12.5%)
Mutual labels:  lambda
shelvery-aws-backups
Automating EBS RDS EC2 backups on lambda
Stars: ✭ 31 (+29.17%)
Mutual labels:  lambda
lambdakiq
ActiveJob on SQS & Lambda
Stars: ✭ 131 (+445.83%)
Mutual labels:  lambda
netlify-lambda-function-example
An example Netlify Lambda function that processes payments with Stripe.
Stars: ✭ 93 (+287.5%)
Mutual labels:  lambda
docker-selenium-lambda
The simplest demo of chrome automation by python and selenium in AWS Lambda
Stars: ✭ 172 (+616.67%)
Mutual labels:  lambda
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (+37.5%)
Mutual labels:  lambda
podcast-app
Podcast App
Stars: ✭ 291 (+1112.5%)
Mutual labels:  android-kotlin
serverless-lumigo-plugin
Serverless monitoring and troubleshooting plugin to easily apply distributed tracing
Stars: ✭ 59 (+145.83%)
Mutual labels:  lambda
github-task-manager
receive github hook, notify agent, receive task results, notify github
Stars: ✭ 13 (-45.83%)
Mutual labels:  lambda
leaderboard-app
GitHub leaderboard for your organisation or repo (Serverless SPA)
Stars: ✭ 64 (+166.67%)
Mutual labels:  lambda
flickabledialog
This dialog can flick and make it easy to dismiss sensuously.
Stars: ✭ 84 (+250%)
Mutual labels:  dialog
website-honestly
🦄 The Red Badger website. Honestly.
Stars: ✭ 26 (+8.33%)
Mutual labels:  lambda
aws-node-custom-user-pool
Serverless AWS Cognito Custom User Pool Example
Stars: ✭ 15 (-37.5%)
Mutual labels:  lambda
terraform-aws-lambda-function
A Terraform module for deploying and managing Lambda functions on Amazon Web Services (AWS). https://aws.amazon.com/lambda/
Stars: ✭ 37 (+54.17%)
Mutual labels:  lambda
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+283.33%)
Mutual labels:  lambda
spark-java8
Java 8 and Spark learning through examples
Stars: ✭ 40 (+66.67%)
Mutual labels:  lambda
ebs-snapshot-lambda
AWS lambda function to snapshot EBS volumes and purge old snapshots.
Stars: ✭ 37 (+54.17%)
Mutual labels:  lambda
imprenta
An AWS lambda in python 3 that generates PDF files from HTML using jinja, pdfkit and wkhtmltopdf.
Stars: ✭ 18 (-25%)
Mutual labels:  lambda

FancyDialog

Usage

allprojects {
    repositories {
    ...
     maven { url 'https://jitpack.io' }
 implementation 'com.github.o0o0oo00:FancyDialog:version'

DSL风格代替Builder模式

domain specific language / DSL 一组特定的语言结构

DSL风格或者也可以说是函数式风格

Java使用Builder来构建复杂对象。

而Kotlin中配合lambad 使用DSL风格 将使复杂对象的构建更加可读,更清晰,更简洁

书写起来舒服顺手

FancyDialog 拥有诸多的配置选项、基本上涵盖了日常开发使用的方方面面

配置项为更简洁的代码、用多少写多少、不用不写,岂不美哉~

安排!

首先我们要明白lambda的几个特性

  • 如果lambda是函数的最后一个参数,可以放在括号外面
  • 如果lambda是函数的唯一参数,它可以放在括号外面并且省略括号
  • 指定接收者的lambda
  • 高阶函数代替传统的自定义回调接口

通过**apply(block)** 来配置dialog所需要的参数。而不需要通过不断的**.setXXX**来设置

Tips :
使用高阶函数会带来一些运行时的效率损失:每一个函数都是一个对象,并且会捕获一个闭包。 即那些在函数体内会访问到的变量。 内存分配(对于函数对象和类)和虚拟调用会引入运行时间开销。
进而使用 inline 修饰函数

使用姿势

关键属性解析

  • mWidth / mHeight 宽度和高度
  • mGravity 居中/居*
  • mOffsetX / mOffsetY 位置偏移量
  • touchOutside 触摸外部消失
  • lowerBackground 降级dialog背景,配合newToast可实现 Alert警告框不会被Dialog阴影覆盖掉

下面提供几种常见的dialog使用形式

如果需要其他使用类型,请自行继承Base,相信我,它超级简单的 ! (* ̄3 ̄)╭

askDialog

normal

askDialog(supportFragmentManager) {
    mTitle = "标题"
    sureClick {
        Toast.makeText(this@MainActivity, "sure", Toast.LENGTH_SHORT).show()
    }
    cancelClick {
        Toast.makeText(this@MainActivity, "cancel", Toast.LENGTH_SHORT).show()
    }
}

onlySure

askDialog(supportFragmentManager) {
    mTitle = "标题"
    mMessage = "摘要vv摘要摘要摘要摘要摘要"
    mGravity = Gravity.TOP
    onlySure = true
    sureClick {
        Toast.makeText(this@MainActivity, "sure", Toast.LENGTH_SHORT).show()
    }
}

askMoreDialog

askMoreDialog(supportFragmentManager) {
    mTitle = "标题"
    mMessage = "摘要vv摘要摘要摘要摘要摘要摘要vv摘要摘要摘要摘要摘要"
    mColor = Color.RED
    sureClick(key = "第一个") {
        Toast.makeText(this@MainActivity, "第一个", Toast.LENGTH_SHORT).show()
    }
    cancelClick(key = "第二个") {
        Toast.makeText(this@MainActivity, "第二个", Toast.LENGTH_SHORT).show()
    }
    button3Clicks(key = "第三个", color = Color.GRAY) {
        Toast.makeText(this@MainActivity, "第三个", Toast.LENGTH_SHORT).show()
    }
}

editDialog

editDialog(supportFragmentManager) {
    rightClick {
        Toast.makeText(this@MainActivity, it, Toast.LENGTH_SHORT).show()
    }
}

listDialog

fun list(view: View) {
	lateinit var dialog: ListDialog
	val click: (View, Int) -> Unit = { v, position ->
	    dialog.dismiss()
	    Toast.makeText(this@MainActivity, (v.tag as String), Toast.LENGTH_SHORT).show()
	}
	val longClick: (View, Int) -> Unit = { v, position ->
	//            dialog.dismiss()
	    Toast.makeText(this@MainActivity, "longClick" + (v.tag as String), Toast.LENGTH_SHORT).show()
	}
	dialog = listDialog {
	    listSetting(click, longClick) {
	        add("第一头条")
	        add("第二头条")
	        add("_(:з」∠)_")
	    }
	}
	dialog.show(supportFragmentManager, "dialog")
}

### customDialog 待续...
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].