Package dagger.hilt.android.flags
Class FragmentGetContextFix
- java.lang.Object
-
- dagger.hilt.android.flags.FragmentGetContextFix
-
public final class FragmentGetContextFix extends java.lang.Object
Runtime flag for the Fragment.getContext() fix. See https://github.com/google/dagger/pull/2620 for this change. Controls if fragment code should use the fixed getContext() behavior where it correctly returns null after a fragment is removed. This fixed behavior matches the behavior of a regular, non-Hilt fragment and can help catch issues where a removed or leaked fragment is incorrectly used.In order to set the flag, bind a boolean value qualified with
FragmentGetContextFix.DisableFragmentGetContextFix
into a set in theSingletonComponent
. A set is used instead of an optional binding to avoid a dependency on Guava. Only one value may be bound into the set within a given app. If this is not set, the default is to not use the fix. Example for binding the value:@Module @InstallIn(SingletonComponent.class) public final class DisableFragmentGetContextFixModule { @Provides @IntoSet @FragmentGetContextFix.DisableFragmentGetContextFix static Boolean provideDisableFragmentGetContextFix() { return // true or false depending on some rollout logic for your app } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
FragmentGetContextFix.DisableFragmentGetContextFix
Qualifier annotation to bind disable the Fragment.getContext() fix at runtime.static interface
FragmentGetContextFix.FragmentGetContextFixEntryPoint
Entry point for getting the flag.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isFragmentGetContextFixDisabled(android.content.Context context)
-