Yacov Rosenberg
04/12/2022, 7:40 PMfun create (lifecycleOwner: LifecycleOwner, view: View) {
val toast = Toast(context)
val toastCustomView = ToastCustomView(
context
)
toast.view = toastCustomView
toast.show()
}
Any help?
Adam Powell
04/12/2022, 8:00 PMViewTreeLifecycleOwner.set
and similar to configure view tree dependencies when hosting compose outside of a ComponentActivity
or DialogFragment
window.
3. Toasts are awful UI, don't use them. 🙂Yacov Rosenberg
04/12/2022, 8:15 PMfun create(
lifecycleOwner: LifecycleOwner,
viewModelStoreOwner: ViewModelStoreOwner,
savedStateRegistryOwner: SavedStateRegistryOwner
) {
val toastCustomView = ToastCustomView(context)
Toast(context).apply {
ViewTreeLifecycleOwner.set(toastCustomView, lifecycleOwner)
ViewTreeViewModelStoreOwner.set(toastCustomView, viewModelStoreOwner)
ViewTreeSavedStateRegistryOwner.set(toastCustomView, savedStateRegistryOwner)
view = toastCustomView
show()
}
}
That way worked for me, I think I might stay with toast api because is a lot simples.Yacov Rosenberg
04/12/2022, 8:25 PMAdam Powell
04/12/2022, 8:34 PMAdam Powell
04/12/2022, 8:36 PM