Beagle v1.5 is no longer actively maintained. The documented version you are viewing may contain deprecated functionality. For up-to-date documentation, see the latest version .
The RootView interface holds the reference of an activity or fragment. Through the interface methods, you have a reference to context, life cycle, ViewModelStore and parent view Id.
RootView is available as an attribute in the ViewConvertable and Action interfaces.
interface RootView {
fun getContext(): Context
fun getLifecycleOwner(): LifecycleOwner
fun getViewModelStoreOwner(): ViewModelStoreOwner
fun getParentId(): Int
}
Returns the context.
fun getContext(): Context
Returns the lifecycle.
fun getLifecycleOwner(): LifecycleOwner
Returns a ViewModelStore for activity and fragment.
fun getViewModelStoreOwner(): ViewModelStoreOwner
Returns the id of the parent View that encapsulates all rendered content.
fun getParentId(): Int
The ActivityRootView class is responsible for keeping the Activity reference of which a [** loadView **] method (/ pt / docs / tutorials / adding-the-beagle-to-a-part-of-the-native-screen / adding- a-component-beagle-server-driven /) is called.
class ActivityRootView(
val activity: AppCompatActivity,
private val parentId: Int
) : RootView {
override fun getContext(): Context = activity
override fun getLifecycleOwner(): LifecycleOwner = activity
override fun getViewModelStoreOwner(): ViewModelStoreOwner = activity
override fun getParentId(): Int = parentId
}
Attributes | Type | Required | Description |
---|---|---|---|
activity | AppCompatActivity | ✓ | Receives the instance of an activity. |
parentId | Int | ✓ | View id. |
The FragmentRootView class is responsible for keeping the Fragment reference of which a [** loadView **] method (/ pt / docs / tutorials / adding-the-beagle-to-a-part-of-the-native-screen / adding a-component-beagle-server-driven /) is called.
class FragmentRootView(
val fragment: Fragment,
private val parentId: Int
) : RootView {
override fun getContext(): Context = fragment.requireContext()
override fun getLifecycleOwner(): LifecycleOwner = fragment.viewLifecycleOwner
override fun getViewModelStoreOwner(): ViewModelStoreOwner = fragment
override fun getParentId(): Int = parentId
}
Attributes | Type | Required | Description |
---|---|---|---|
fragment | Fragment | ✓ | Receives the instance of an fragment. |
parentId | Int | ✓ | View id. |
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.