Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Content of MainActivity.kt in the code block is wrong #69

@KunalDhyani

Description

@KunalDhyani

class MainActivity : AppCompatActivity() {

// 1) Remove userManager field
@Inject
lateinit var userManager: UserManager

@Inject
lateinit var mainViewModel: MainViewModel

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_settings) <<<<<<<<<<<<< Not Supposed to be here <<<<<<<<<<

    // 2) Grab userManager from appComponent to check if the user is logged in or not
    val userManager = (application as MyApplication).appComponent.userManager()
    if (!userManager.isUserLoggedIn()) { ... }
    else {
        setContentView(R.layout.activity_main)
        // 3) If the MainActivity needs to be displayed, we get the UserComponent
        // from the application graph and gets this Activity injected
        userManager.userComponent!!.inject(this)
        setupViews()
    }
}
...

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions