Skip to content
This repository was archived by the owner on Jun 22, 2022. It is now read-only.
This repository was archived by the owner on Jun 22, 2022. It is now read-only.

Not working in combination with dagger hilt #128

@Berki2021

Description

@Berki2021

I wanted to use this library in combination with dagger-hilt, but that does not seem to work. To be more specific:

There is a dagger-hilt annotation called @ApplicationContext, with which we can inject the application context inside every possible non-android-class. Here is an example:

class MyRepository(
    @ApplicationContext private val context: Context
) {
   fun getData() =  myService.collection(context.getString(R.string.stuff)).get().await()
}

Now comes the problem: When switching languages, this ApplicationContext does not seem to update. For example, let's say we have two versions of the above string:

German "R.string.stuff" -> Hallo
English "R.string.stuff" -> Hello

When you now change the language from german to english in Fragment with (requireActivity as LocaleAwareCompatActivity).updateLocal(Locale.EN), then the following happens:

Calling requireContext().getString(R.string.stuff) in Fragment gives "Hello" (language was updated correctly). But inside my Repository "R.string.stuff" is still "Hallo" (language was not updated correctly)

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