Skip to content

[Question] Strange way to get reference the Application #26

@ericntd

Description

@ericntd

Thanks for sharing this repo archi.

This is unlikely related to the MVVM design pattern but just want to make sure I'm not missing anything important.

Why do you do:
MainViewModel.java

private void loadGithubRepos(String username) {
   // ...
   ArchiApplication application = ArchiApplication.get(context);
   // ...
}

why not simply:
MainViewModel.java

private void loadGithubRepos(String username) {
   // ...
   ArchiApplication application = (ArchiApplication) context.getApplicationContext();
   // ...
}

(I tried it and the app runs just fine)
Is it to prevent memory leak or sth? I can't seem to get my head around it
Sorry for the noob question

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions