runningmessage / kotlinx-android Goto Github PK
View Code? Open in Web Editor NEWTo use kotlin easily !!!
To use kotlin easily !!!
使用例子:
val Builder = "android.app.AlertDialog${'$'}Builder"
val OnClickListener = "android.content.DialogInterface${'$'}OnClickListener"
Log.e("Reflect","11111")
Builder<Context>(this) // Like AlertDialog.Builder(context)
.calls("setTitle")("Hello World") // Call matched specific named function
.calls("setPositiveButton")("OK",
OnClickListener.createInners {
// Like object: DialogInterface.OnClickListener
/***
* Like:
* override fun onClick(dialog: Any, which: Int){
*
* }
*/
override<Any, Int>("onClick") { dialog, which ->
}
})
.calls("create").calls("show")() // Like builder.create().show()
Log.e("Reflect","22222")
2020-05-19 14:25:59.881 11753-11753/com.cc.test E/Reflect: 11111
2020-05-19 14:26:03.056 11753-11764/com.cc.test I/iesupportsampl: Background concurrent copying GC freed 95320(4MB) AllocSpace objects, 2(40KB) LOS objects, 65% free, 3MB/9MB, paused 493us total 126.728ms
2020-05-19 14:26:05.403 11753-11753/com.cc.test E/Reflect: 22222
2020-05-19 14:26:05.407 11753-11753/com.cc.test I/Choreographer: Skipped 331 frames! The application may be doing too much work on its main thread.
通过运行日志发现,执行这段代码产生了掉帧,主线程卡顿的问题。
如果是正常的创建Dialog,耗时很小。
Log.e("Reflect","33333")
AlertDialog.Builder(this)
.setTitle("Hello Word")
.setPositiveButton("OK", DialogInterface.OnClickListener { dialog, which ->
})
.create()
.show()
Log.e("Reflect","44444")
2020-05-19 14:25:56.320 11753-11753/com.cc.test E/Reflect: 33333
2020-05-19 14:25:56.465 11753-11753/com.cc.test E/Reflect: 44444
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.