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

chore(#264): add support for Hilt dependency injection #321

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jkuester
Copy link
Contributor

@jkuester jkuester commented Jun 21, 2023

Closes #264

  • ChtAndroidApplication - By default an Android app uses the base android.app.Application class, but if you need to add any application-level hooks (as with the HiltAndroidApp annotation, you just need to extend Application with a custom class.
  • SettingsDialogActivity - I decided to make this the example case for using Hilt dependency injection
    • Move class into components/settings_dialog package
    • Extract inner classes into their own files
    • No logic was changed in any of these classes besides updating the constructors/fields to work with Hilt
  • SettingsStore:
    • Move various top-level classes in the file to instead be public inner-classes of SettingsStore
      • Cannot have multiple public top-level classes in the same file (honestly multiple top-level classes is an anti-pattern in Java anyway). But, to be able to access those classes from outside the base package, they need to be public.
      • To reduce the number of new files (and try to avoid the temptation for scope-creep) I have just moved these classes to be static inner classes of SettingsStore (these can be refactored more later).
      • Nothing was changed in these classes besides the visibility
    • Add SettingsStoreModule as a Hilt module to provide SettingsStore instances using Hilt. (Hilt does not understand, by default, how to call the SettingsStore.in method).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Dependency Injection Framework
1 participant