Kanzi  3.9.4
Android application framework API
KanziView Class Reference

A view that owns the native Kanzi application and provides the output surface. More...

Inheritance diagram for KanziView:
[legend]

Classes

enum  State
 KanziView java-side lifecycle state.
 

Public Member Functions

 KanziView (Context context)
 Simple constructor to use when creating a KanziView from code. More...
 
 KanziView (Context context, AttributeSet attrs)
 Constructor that is called when inflating a KanziView from XML. More...
 
void createNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_CREATE events. More...
 
void destroyNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_DESTROY events. More...
 
boolean onKeyDown (final int keyCode, KeyEvent event)
 A key down handler. More...
 
boolean onKeyUp (final int keyCode, KeyEvent event)
 A key up handler. More...
 
boolean onTouchEvent (final MotionEvent event)
 Handler for touches inside KanziView. More...
 
void pauseNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_PAUSE events. More...
 
int queueEvent (Runnable runnable)
 Submits a runnable task to Kanzi's task dispatcher. More...
 
void registerLifecycle (Lifecycle lifecycle)
 Attaches KanziView to the given Lifecycle. More...
 
void resumeNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_RESUME events. More...
 
void setOrientation (int orientation)
 Handler for device/display orientation changes. More...
 
void startNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_START events. More...
 
void stopNativeApplication ()
 Lifecycle handler for Lifecycle.Event.ON_STOP events. More...
 
void surfaceChanged (SurfaceHolder holder, int format, int width, int height)
 This is called immediately after any structural changes (format or size) have been made to the surface. More...
 
void surfaceCreated (SurfaceHolder holder)
 This is called immediately after the surface is first created. More...
 
void surfaceDestroyed (SurfaceHolder holder)
 This is called immediately before a surface is being destroyed. More...
 

Protected Member Functions

void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect)
 Called by the view system when the focus state of this KanziView changes. More...
 

Protected Attributes

State mState = State.IDLE
 Current KanziView lifecycle state.
 
Surface mSurface = null
 Valid Surface. More...
 

Detailed Description

A view that owns the native Kanzi application and provides the output surface.

Constructor & Destructor Documentation

◆ KanziView() [1/2]

KanziView ( Context  context)

Simple constructor to use when creating a KanziView from code.

Parameters
contextThe Context the KanziView is running in, through which it can access the current theme, resources, etc.

◆ KanziView() [2/2]

KanziView ( Context  context,
AttributeSet  attrs 
)

Constructor that is called when inflating a KanziView from XML.

Parameters
contextThe Context the KanziView is running in, through which it can access the current theme, resources, etc.
attrsThe attributes of the XML tag that is inflating the KanziView.

Member Function Documentation

◆ createNativeApplication()

void createNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_CREATE events.

Loads the native library providing all Kanzi functionality. Initializes the context and assigns this KanziView for rendering. Creates Kanzi application which loads the Kanzi project.

◆ destroyNativeApplication()

void destroyNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_DESTROY events.

Halts and destroys the Kanzi application.

◆ onFocusChanged()

void onFocusChanged ( boolean  gainFocus,
int  direction,
Rect  previouslyFocusedRect 
)
protected

Called by the view system when the focus state of this KanziView changes.

Parameters
gainFocusTrue if the KanziView has focus; false otherwise.
directionThe direction focus has moved when requestFocus() is called to give this KanziView focus.
previouslyFocusedRectThe rectangle, in this KanziView's coordinate system, of the previously focused view. May be null.
See also
android.view.View::View(Context context, AttributeSet attrs)

◆ onKeyDown()

boolean onKeyDown ( final int  keyCode,
KeyEvent  event 
)

A key down handler.

Passes the key down event to the key event handler.

Parameters
keyCodeA key code that represents the button pressed, from android.view.KeyEvent.
eventThe KeyEvent object that defines the button action.
Returns
If the event was handled by the superclass' handler, return true.

◆ onKeyUp()

boolean onKeyUp ( final int  keyCode,
KeyEvent  event 
)

A key up handler.

Passes the key up event to the key event handler.

Parameters
keyCodeA key code that represents the button pressed, from android.view.KeyEvent.
eventThe KeyEvent object that defines the button action.
Returns
If the event was handled by the superclass' handler, return true.

◆ onTouchEvent()

boolean onTouchEvent ( final MotionEvent  event)

Handler for touches inside KanziView.

Translates the received events into the native library's touch states.

Parameters
eventThe motion event.
Returns
True, always as this is the only touch handler for KanziView.

◆ pauseNativeApplication()

void pauseNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_PAUSE events.

Logs the event.

◆ queueEvent()

int queueEvent ( Runnable  runnable)

Submits a runnable task to Kanzi's task dispatcher.

This function fails if the task dispatcher is not yet initialized.

Parameters
runnableThe task to be run.
Returns
Zero on success, non-zero on failure.

◆ registerLifecycle()

void registerLifecycle ( Lifecycle  lifecycle)

Attaches KanziView to the given Lifecycle.

Parameters
lifecycleThe lifecycle to attach to.

◆ resumeNativeApplication()

void resumeNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_RESUME events.

Logs the event.

◆ setOrientation()

void setOrientation ( int  orientation)

Handler for device/display orientation changes.

Translates the received orientation qualifiers into the native library's orientation constants.

Parameters
orientationThe orientation qualifier from onOrientationChanged().

◆ startNativeApplication()

void startNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_START events.

Runs the Kanzi application if a surface has already been received.

◆ stopNativeApplication()

void stopNativeApplication ( )

Lifecycle handler for Lifecycle.Event.ON_STOP events.

Stops the Kanzi application.

◆ surfaceChanged()

void surfaceChanged ( SurfaceHolder  holder,
int  format,
int  width,
int  height 
)

This is called immediately after any structural changes (format or size) have been made to the surface.

This method is always called at least once, after surfaceCreated.

Parameters
holderThe SurfaceHolder whose surface has changed.
formatThe new PixelFormat of the surface.
widthThe new width of the surface.
heightThe new height of the surface.

◆ surfaceCreated()

void surfaceCreated ( SurfaceHolder  holder)

This is called immediately after the surface is first created.

Passes the created surface to the native library for rendering target.

Parameters
holderThe SurfaceHolder whose surface is being created.

◆ surfaceDestroyed()

void surfaceDestroyed ( SurfaceHolder  holder)

This is called immediately before a surface is being destroyed.

Parameters
holderThe SurfaceHolder whose surface is being destroyed.

Member Data Documentation

◆ mSurface

Surface mSurface = null
protected

Valid Surface.

The surface will be captured during the onSurfaceCreated event.