Kanzi  3.9.7
Android framework API
KanziViewAdapter Class Reference

KanziViewAdapter allows embedding Kanzi UI content into an Android view. More...

Public Member Functions

 KanziViewAdapter (View view, AttributeSet attrs)
 Constructor to use when inflating a view from XML. More...
 
 KanziViewAdapter (View view, String name)
 Constructor to use when attaching to a view. More...
 
 KanziViewAdapter (Context context, String name)
 Constructor to use when operating without a view. More...
 
void addListener (KanziViewListener listener)
 Adds a view state change listener. More...
 
Domain getDomain ()
 Gets the Domain associated with this view. More...
 
String getName ()
 Gets the name of the underlying native view node. More...
 
Node2D getRoot ()
 Returns the root node of the underlying native view's node tree. More...
 
KanziRuntime getRuntime ()
 Gets the KanziRuntime associated with this view. More...
 
void handleActivityStarted ()
 Notifies the adapter that the Activity has started. More...
 
void handleActivityStopped ()
 Notifies the adapter that the Activity has stopped. More...
 
void handleAttachedToWindow ()
 Notifies the adapter of the attachment of the associated view to a window. More...
 
void handleDetachedFromWindow ()
 Notifies the adapter of the detachment of the associated view from its window. More...
 
void handleFocusChange (boolean hasFocus)
 Handles focus change. More...
 
boolean handleKeyEvent (final int keyCode, KeyEvent event)
 Handles key events. More...
 
void handleOrientationChange (int orientation)
 Applies device orientation changes to the Kanzi contents of associated view. More...
 
void handleSurfaceChanged (Surface surface, int width, int height)
 Notifies the adapter of any changes in the dimensions of the surface of the associated view. More...
 
void handleSurfaceCreated (Surface surface)
 Notifies the adapter of availability of surface of the associated view. More...
 
void handleSurfaceDestroyed ()
 Notifies the adapter of the destruction of the surface of the associated view. More...
 
boolean handleTouchEvent (final MotionEvent event)
 Handles touch events. More...
 
void handleVisibilityChange (boolean isVisible)
 Notifies the adapter that the visibility has changed. More...
 
void removeListener (KanziViewListener listener)
 Removes a view state change listener. More...
 
void setClearColor (ColorRGBA color)
 Configures the clear color that is used when rendering of the surface of the view. More...
 
void setKzbPathList (String[] kzbPaths)
 Configures the list of kzb files that are loaded when the view is attached. More...
 
void setName (String name)
 Sets the name for the underlying native view node. More...
 
void setRoot (Node2D node)
 Sets the root node of the underlying native view's node tree, used to manually set content to the view. More...
 
void setStartupPrefabUrl (String url)
 Configures the startup prefab that is automatically loaded during initialization. More...
 

Detailed Description

KanziViewAdapter allows embedding Kanzi UI content into an Android view.

Alternatively, you can use one of the Kanzi view classes: KanziSurfaceView and KanziTextureView.

Constructor & Destructor Documentation

KanziViewAdapter ( View  view,
AttributeSet  attrs 
)

Constructor to use when inflating a view from XML.

Parameters
viewReference to the view being adapted.
attrsAttributes received when inflating the view from XML.
KanziViewAdapter ( View  view,
String  name 
)

Constructor to use when attaching to a view.

Parameters
viewReference to the view being adapted.
nameA name for the underlying native view node.
KanziViewAdapter ( Context  context,
String  name 
)

Constructor to use when operating without a view.

Parameters
contextReference to the application context.
nameA name for the underlying native view node.

Member Function Documentation

void addListener ( KanziViewListener  listener)

Adds a view state change listener.

Parameters
listenerAn instance of KanziViewListener.
Domain getDomain ( )

Gets the Domain associated with this view.

Returns
Domain associated with this view.
String getName ( )

Gets the name of the underlying native view node.

Returns
Name of the underlying native view node.
Node2D getRoot ( )

Returns the root node of the underlying native view's node tree.

Returns
Reference to the root node. If called before StartupPrefab has finished loading, returns Null.
KanziRuntime getRuntime ( )

Gets the KanziRuntime associated with this view.

Returns
KanziRuntime associated with this view.
void handleActivityStarted ( )

Notifies the adapter that the Activity has started.

Activates the view node.

void handleActivityStopped ( )

Notifies the adapter that the Activity has stopped.

Deactivates the view node.

void handleAttachedToWindow ( )

Notifies the adapter of the attachment of the associated view to a window.

Initializes runtime if this is the first Kanzi based view to be attached in this application. Initializes the underlying view node and initiates asynchronous loading of its start-up prefab if configured.

void handleDetachedFromWindow ( )

Notifies the adapter of the detachment of the associated view from its window.

Releases the underlying view node.

void handleFocusChange ( boolean  hasFocus)

Handles focus change.

Call this to inform Kanzi of changes in the focus of a Kanzi-based-view. Kanzi view types KanziSurfaceView and KanziTextureView do this by default, so you don't have to.

Parameters
hasFocusTrue if the View has focus; false otherwise.
boolean handleKeyEvent ( final int  keyCode,
KeyEvent  event 
)

Handles key events.

You can forward key events received by Kanzi-based-view to this function, if you want Kanzi to handle them. Kanzi view types KanziSurfaceView and KanziTextureView do this by default, so you don't have to.

Parameters
keyCodea key code that represents the button pressed, from android.view.KeyEvent.
eventthe KeyEvent object that defines the button action.
Returns
True if the event was handled, false otherwise.
void handleOrientationChange ( int  orientation)

Applies device orientation changes to the Kanzi contents of associated view.

Parameters
orientationThe orientation qualifier from onOrientationChanged().
void handleSurfaceChanged ( Surface  surface,
int  width,
int  height 
)

Notifies the adapter of any changes in the dimensions of the surface of the associated view.

Parameters
surfaceThe new surface
widthThe new width of the surface.
heightThe new height of the surface.
void handleSurfaceCreated ( Surface  surface)

Notifies the adapter of availability of surface of the associated view.

Sets the surface as the target of the graphics context of the underlying view node. Activates the view node.

Parameters
surfaceThe surface
void handleSurfaceDestroyed ( )

Notifies the adapter of the destruction of the surface of the associated view.

Detaches the graphics context of the underlying view node from this surface. Deactivates the view node.

boolean handleTouchEvent ( final MotionEvent  event)

Handles touch events.

You can forward touch events received by Kanzi-based-view to this function, if you want Kanzi to handle them. Kanzi view types KanziSurfaceView and KanziTextureView do this by default, so you don't have to.

Parameters
eventThe touch event.
Returns
True if the event was handled, false otherwise.
void handleVisibilityChange ( boolean  isVisible)

Notifies the adapter that the visibility has changed.

Use this method only when your application is in a view-less context, such as a WallpaperEngine.

Toggles the activation of the Kanzi View.

Parameters
isVisibleWhether the surface is visible and must be rendered.
void removeListener ( KanziViewListener  listener)

Removes a view state change listener.

Parameters
listenerThe instance of KanziViewListener to remove.
void setClearColor ( ColorRGBA  color)

Configures the clear color that is used when rendering of the surface of the view.

Parameters
colorColor used to clear the surface of the view. Use null to skip clearing.
void setKzbPathList ( String[]  kzbPaths)

Configures the list of kzb files that are loaded when the view is attached.

Parameters
kzbPathsArray of kzb paths to load.
void setName ( String  name)

Sets the name for the underlying native view node.

Parameters
nameNew name for native view node.
void setRoot ( Node2D  node)

Sets the root node of the underlying native view's node tree, used to manually set content to the view.

Parameters
nodeReference to a node.
void setStartupPrefabUrl ( String  url)

Configures the startup prefab that is automatically loaded during initialization.

Parameters
urlUrl of the prefab template to load.