Version 1.1.0-alpha04
February 7, 2019
androidx.fragment:fragment 1.1.0-alpha04
, androidx.fragment:fragment-ktx 1.1.0-alpha04
, and androidx.fragment:fragment-testing 1.1.0-alpha04
are released.
New features
- Added support for the
@ContentView
class annotation that allows you to indicate which layout XML file should be inflated as an alternative to overridingonCreateView()
. It is recommended to do view related work inonViewCreated()
. (aosp/837619) fragment-testing
now depends onandroidx.test:core-ktx
1.1.0 stable (b/121209673)- You can now use
openActionBarOverflowOrOptionsMenu
withFragmentScenario
to test Fragment hosted options menus (b/121126668)
API changes
- Added a
requireArguments()
method which returns a@NonNull Bundle
or throws anIllegalStateException
(b/121196360) - Added a note that
getLifecycle()
,getViewLifecycleOwner()
, andgetViewLifecycleOwnerLiveData()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880714) - Added a note that
getViewModelStore()
should not be overridden and will be made final in a future release. Please file a feature request if you are currently overriding this method. (aosp/880713) - Fixed an issue with binary compatibility with previous releases of Fragments. (aosp/887877) (aosp/889834)
Bug fixes
- Target fragments are correctly cleared out when you pass
null
tosetTargetFragment()
. (aosp/849969) - Fixed an issue where target Fragments were sometimes unavailable in or after
onDestroy()
. (b/122312935) - DialogFragment’s onDismiss() is now called before
onDestroy()
. (aosp/874133) (aosp/890734)
Version 1.1.0-alpha03
December 17, 2018
New features
- Fragment now implements
BundleSavedStateRegistryOwner
and depends on the newly released SavedState library [aosp/824380] - A
by activityViewModels
Kotlin property delegate has been added to retrieve ViewModels associated with the containing Activity [b/119050253] - The
by viewModels
Kotlin property delegate has been expanded to take an optional lambda method for getting theViewModelStoreOwner
, allowing you to pass in the parent Fragment or other customViewModelStoreOwner
with code such asval viewModel: MyViewModel by viewModels(::requireParentFragment)
[b/119050253]
API changes
FragmentScenario
now allows you to specify a theme such asTheme.AppCompat
[b/119054431]. This is a breaking change.- Added a
requireView()
method which returns a@NonNull View
or throws anIllegalStateException
[b/120241368] - Added a
requireParentFragment()
method which returns a@NonNull Fragment
or throws anIllegalStateException
[b/112103783]
Bug fixes
- Fixed IllegalStateException: Failure saving state b/120814739
- Fragments being restored from saved instance state will now always receive a non-null
Bundle
[b/119794496] - Removed Fragments no longer reuse their
Lifecycle
object if re-added [b/118880674]
Version 1.1.0-alpha02
December 3, 2018
New features
- FragmentScenario’s Kotlin extensions now let you use a lambda for Fragment construction as an alternative to passing in a
FragmentFactory
instance. (aosp/812913)
Bug fixes
- Fixed an IllegalStateException when using nested Fragments on the back stack (b/119256498)
- Fixed crash when using
FragmentScenario.recreate()
with aFragmentFactory
(aosp/820540) - Fixed an issue where target Fragments were not accessible after the Fragment was removed (aosp/807634)
Version 1.1.0-alpha01
November 5, 2018
This is the first release of the
fragment-testing
artifact and FragmentScenario
which is built on top of the
androidx.test:core APIs. See the Fragment testing documentation for more details.
New features
- New FragmentScenario class for testing Fragments in isolation.
- You can now set a
FragmentFactory
on anyFragmentManager
to control how new Fragment instances are instantiated. - Added a new
by viewModels()
Kotlin property delegate for retrieving ViewModels from a Fragment. - Pending input events (such as clicks) are now canceled in a Fragment’s
onStop()
.
API changes
- Significantly expanded the nullability annotations across the Fragment API surface.
Bug fixes
- Fix an issue which caused Fragment operations to fail from within LiveData (b/77944637)
Known issues
- Target Fragments cannot be accessed after a Fragment has been removed from the FragmentManager.
fragment-testing
depends onandroidx.test:core:1.0.0-beta01
instead of the correctandroidx.test:core:1.0.0
.