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 booleanwasInjectedByHilt(android.app.Service service) Returns true if the Service was injected by Hilt.static booleanwasInjectedByHilt(android.content.BroadcastReceiver broadcastReceiver) Returns true if the BroadcastReceiver was injected by Hilt.static booleanwasInjectedByHilt(android.view.View view) Returns true if the View was injected by Hilt.static booleanwasInjectedByHilt(androidx.activity.ComponentActivity activity) Returns true if the Activity was injected by Hilt.static booleanwasInjectedByHilt(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.
-