HuolalaTech / hll-wp-therouter-android

A framework for assisting in the renovation of Android componentization(帮助 App 进行组件化改造的动态路由框架)
https://therouter.cn/
Apache License 2.0
1.11k stars 129 forks source link

注解 Autowired 中的 required为 true 时并未生效 #196

Open IdioticMadman opened 2 weeks ago

IdioticMadman commented 2 weeks ago
// MainActivity
findViewById<View>(R.id.tv_hello).setOnClickListener {
            TheRouter.build("second")
//                .withString("name", "zhangsan")
                .navigation(this)
 }

@Route(path = "second")
class SecondActivity : AppCompatActivity() {

    @Autowired(required = true)
    var name: String = ""

    override fun onCreate(savedInstanceState: Bundle?) {
        TheRouter.inject(this)
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_second)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        findViewById<TextView>(R.id.tv_result).text = name
    }
}
IdioticMadman commented 2 weeks ago

预期应该是会 crash,但是一切正常显示空字符串