Giter VIP home page Giter VIP logo

kotlinx-android's People

Contributors

yaqingzhang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

kotlinx-android's Issues

反射执行起来太慢了

使用例子:

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

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.