A helper class for fragments that change their view depending on the size that it's given, offering an adaptive UI.
A 'view variant' of type T defines the different possible variations of the fragment's view. For example the view could have different orientations (HORIZONTAL, VERTICAL), different sizes (SMALL, MEDIUM, LARGE), or any combination of those variations.
Each time the fragment's root view size change, a different view variant can be selected via viewVariantSelector. If a different view variant is selected, the fragment's view is recreated with the corresponding ViewFactory provided by the viewFactoryProvider.
The enum type of view variant.
The adaptive fragment.
Called when the fragment's root view updates its size in order to determine which view variant to use. If the returned value differs from the previous one the fragment will be reattached in order to recreate the view. In case the value to which the size is compared is stored in the dimen xml, one can use the Context.getDimensionByAttrInDp function. If a view or any of its parents has the layout param WRAP_CONTENT, the size can vary after the view variant is chosen, causing a new view variant to be selected, which may end up in an endless loop. To prevent this from happening, such a view will report the stable value 0 in the WRAP_CONTENT dimension.