android10 / android10/Android-CleanArchitecture

Why there is no activity context injection?

Offen
#130 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
discussion question
Vorherrschende Sprache
Java
Sterne
15.5k
Forks
3.3k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I don't know this is a bug or just my misunderstanding?

``` java
@Inject
public UsersAdapter(Context context) {
this.layoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.usersCollection = Collections.emptyList();
}
```

Here you have injected an adapter. This adapter has a Context type parameter. Apparently this should be an activity context. Because application context lacks the app theme and so on.
But there is no activity context provided in your di. Only application context has been provided.

``` java
@Provides @Singleton Context provideApplicationContext() {
return this.application;
}

```

And I found an activity dependancy provided in ActivityModule.

``` java
@Provides @PerActivity Activity activity() {
return this.activity;
}
```

My question is:
Do you replace activity context with application context? Or with an acitivity casted by di automatically? Or this is just a bug?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.