Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
IdioticMadman opened this issue Sep 24, 2024 · 1 comment
Open

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

IdioticMadman opened this issue Sep 24, 2024 · 1 comment
Labels
bug bug

Comments

@IdioticMadman
Copy link

// 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
Copy link
Author

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

@kymjs kymjs added the bug bug label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug
Projects
None yet
Development

No branches or pull requests

2 participants