PYDroid has received an update to version 22.5.0! Major changes include new support for the androidx.savedstate module in UiViewModels! This support is optional.
UiViewModel
will be deprecating the doOnRestoreState
and doOnSaveState
hooks. In the future, the UiViewModel
class will no longer support instance state saving. For ViewModels wishing to use and write instance state, the new UiSavedStateViewModel
class should be used (long names - I know - what is this - Java?). The UiSavedStateViewModel
class takes in it's constructor an additional UiSavedState
parameter, which is a simple abstraction over the SavedStateHandle
class from androidx. You can access the UiSavedState
via the restoreSavedState
, putSavedState
and removeSavedState
functions.
Currently the UiSavedStateViewModel
class is seperated from the UiViewModel
class, but once the saved state migration is complete in a future version, the saved state view model will extend from the normal view model as a base class. Consumer API will not change, but ABI compatibility will not be maintained once this happens.
To facilitate these new ViewModels, a new factory has been created, called SavedStateViewModelFactory
. To create simple factories, the new inline functions createViewModelFactory
and createSavedStateViewModelFactory
can be used to create simple single-value factories so that your custom ViewModels can play nice with Android's ViewModelStore
system.
Along with these changes, the UiBundleReader
and UiBundleWriter
interfaces have been deprecated. For library consumers, this change is largely unimportant - but one thing that will affect consumers is that the UiBundleReader
methods have been reduced to just the get(String): T?
method. All other methods in the future will be removed. UiView
consumer code will be largely unchanged, as long as all reader access is changed to only use get(String): T?
.
The UiRender
interface has removed support for the distinct
function as it did not make any sense in the given context, and has renamed the distinctBy
function to mapChanged
to better convey how that function is used. The asUiRender
extension function has been changed from being an extension on Any
to being an extension on UiViewState
only, so that random objects cannot be turned into renderers unintentionally.
PYDroid ui
has been updated to use these new systems and now lazily initializes all of it's components, which should reduce the start up time cost. An optimization has been made to coroutine scope creation which should avoid a large time penalty during debug mode builds. In the future, support will begin for using UiViews as composable building blocks, but this will not be at least until compose-ui enters an API beta with stability guarantees.
Finally, some functions are exposed to a Java consumer that were intended to be internal to the library only. These functions have since been moved into an Internals
class. You should not use these functions as a PYDroid library consumer - if you do, there is no support and functions can be radically changed or removed without warning. Don't use anything labelled internal, if you are able to access it, it is a mistake.
The bintray official release will be going up later today, stay tuned!
========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?
Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com
Follow my Facebook Page
Check out my code on GitHub
=========================