Package dagger.hilt.android.migration
Class OptionalInjectCheck
java.lang.Object
dagger.hilt.android.migration.OptionalInjectCheck
Utility methods for validating if an
AndroidEntryPoint
-annotated
class that is also annotated with OptionalInject
was injected by Hilt.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
wasInjectedByHilt
(android.app.Service service) Returns true if the Service was injected by Hilt.static boolean
wasInjectedByHilt
(android.content.BroadcastReceiver broadcastReceiver) Returns true if the BroadcastReceiver was injected by Hilt.static boolean
wasInjectedByHilt
(android.view.View view) Returns true if the View was injected by Hilt.static boolean
wasInjectedByHilt
(androidx.activity.ComponentActivity activity) Returns true if the Activity was injected by Hilt.static boolean
wasInjectedByHilt
(androidx.fragment.app.Fragment fragment) Returns true if the Fragment was injected by Hilt.
-
Method Details
-
wasInjectedByHilt
public static boolean wasInjectedByHilt(@NonNull androidx.activity.ComponentActivity activity) Returns true if the Activity was injected by Hilt.- Throws:
IllegalArgumentException
- if the given instance is not an AndroidEntryPoint nor is annotated withOptionalInject
.
-
wasInjectedByHilt
public static boolean wasInjectedByHilt(@NonNull android.content.BroadcastReceiver broadcastReceiver) Returns true if the BroadcastReceiver was injected by Hilt.- Throws:
IllegalArgumentException
- if the given instance is not an AndroidEntryPoint nor is annotated withOptionalInject
.
-
wasInjectedByHilt
public static boolean wasInjectedByHilt(@NonNull androidx.fragment.app.Fragment fragment) Returns true if the Fragment was injected by Hilt.- Throws:
IllegalArgumentException
- if the given instance is not an AndroidEntryPoint nor is annotated withOptionalInject
.
-
wasInjectedByHilt
public static boolean wasInjectedByHilt(@NonNull android.app.Service service) Returns true if the Service was injected by Hilt.- Throws:
IllegalArgumentException
- if the given instance is not an AndroidEntryPoint nor is annotated withOptionalInject
.
-
wasInjectedByHilt
public static boolean wasInjectedByHilt(@NonNull android.view.View view) Returns true if the View was injected by Hilt.- Throws:
IllegalArgumentException
- if the given instance is not an AndroidEntryPoint nor is annotated withOptionalInject
.
-