我有下一个代码kotlin:
handler.postDelayed(object : Runnable {
            override fun run() {
                Timber.i("run post msg")
                handler.postDelayed(this, AppPrefs.SEARCH_DELAY)
            }
        },AppPrefs.SOCKET_INTERVAL)
你如何看待它是创建延迟任务的简单标准方法(with Runnable class).this对anonimus Object的值引用实现Runnable并编译并正常工作
但是当我为此制作lamdba时:
handler.postDelayed({
            Timber.i("run post msg")
            handler.postDelayed(this, AppPrefs.SOCKET_INTERVAL)
        },AppPrefs.SOCKET_INTERVAL)
值this引用外层类.
如何从内部的anonimus类引用自己?
| 归档时间: | 
 | 
| 查看次数: | 605 次 | 
| 最近记录: |