An element of an application that is notified of the application life cycle

Most users of app.nit need only to implement on_create to setup the application.

On mobile devices, the application can be stopped a anytime when another application takes the foreground. Implement the callbacks on_save_state and on_load_state to keep the state of the application between execution, for an illusion of continuous execution.

Introduced properties

fun notify_observers(event: AppEvent)

app :: AppComponent :: notify_observers

Propagate event to all observers by calling AppObserver::on_event
fun observers: HashSet[AppObserver]

app :: AppComponent :: observers

All AppObserver notified of events raised by self
protected fun observers=(observers: HashSet[AppObserver])

app :: AppComponent :: observers=

All AppObserver notified of events raised by self
fun on_create

app :: AppComponent :: on_create

The application is being created
fun on_destroy

app :: AppComponent :: on_destroy

The application is being destroyed
fun on_pause

app :: AppComponent :: on_pause

The application leaves the active state but is still partially visible
fun on_restart

app :: AppComponent :: on_restart

The application returns to a visible state from a previous on_stop
fun on_restore_state

app :: AppComponent :: on_restore_state

The application is launching, restore its state from a previous on_save_state
fun on_resume

app :: AppComponent :: on_resume

The application enters the active state, it is in the foreground and interactive
fun on_save_state

app :: AppComponent :: on_save_state

The application may be destroyed soon, save its state for a future on_restore_state
fun on_start

app :: AppComponent :: on_start

The application is starting or restarting, it is visible to the user
fun on_stop

app :: AppComponent :: on_stop

The application is completely hidden from the user

Redefined properties

redef type SELF: AppComponent

app $ AppComponent :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun notify_observers(event: AppEvent)

app :: AppComponent :: notify_observers

Propagate event to all observers by calling AppObserver::on_event
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun observers: HashSet[AppObserver]

app :: AppComponent :: observers

All AppObserver notified of events raised by self
protected fun observers=(observers: HashSet[AppObserver])

app :: AppComponent :: observers=

All AppObserver notified of events raised by self
fun on_create

app :: AppComponent :: on_create

The application is being created
fun on_destroy

app :: AppComponent :: on_destroy

The application is being destroyed
fun on_event(event: AppEvent)

app :: AppObserver :: on_event

Notification of event raised by sender
fun on_pause

app :: AppComponent :: on_pause

The application leaves the active state but is still partially visible
fun on_restart

app :: AppComponent :: on_restart

The application returns to a visible state from a previous on_stop
fun on_restore_state

app :: AppComponent :: on_restore_state

The application is launching, restore its state from a previous on_save_state
fun on_resume

app :: AppComponent :: on_resume

The application enters the active state, it is in the foreground and interactive
fun on_save_state

app :: AppComponent :: on_save_state

The application may be destroyed soon, save its state for a future on_restore_state
fun on_start

app :: AppComponent :: on_start

The application is starting or restarting, it is visible to the user
fun on_stop

app :: AppComponent :: on_stop

The application is completely hidden from the user
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram app::AppComponent AppComponent app::AppObserver AppObserver app::AppComponent->app::AppObserver core::Object Object app::AppObserver->core::Object ...core::Object ... ...core::Object->core::Object app::App App app::App->app::AppComponent app::Control Control app::Control->app::AppComponent app::CompositeControl CompositeControl app::CompositeControl->app::Control app::View View app::View->app::Control app::CompositeControl... ... app::CompositeControl...->app::CompositeControl app::View... ... app::View...->app::View

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

interface AppObserver

app :: AppObserver

Observer of AppEvents raised by AppComponents

Children

class App

app :: App

App subclasses are cross-platform applications
class Control

app :: Control

A control implementing the UI

Descendants

class BackButton

linux :: BackButton

Button to go back between windows
class Button

app :: Button

A pressable button, raises ButtonPressEvent
class CheckBox

app :: CheckBox

Toggle control between two states, also displays a label
class CompositeControl

app :: CompositeControl

A Control grouping other controls
class HorizontalLayout

app :: HorizontalLayout

An horizontal linear organization
class HttpRequestClientWindow

app :: HttpRequestClientWindow

Simple window with a label and a button
class Label

app :: Label

A simple text label
abstract class Layout

app :: Layout

A layout to visually organize Controls
class ListLayout

app :: ListLayout

Scrollable list of views in a simple list
class SecondWindow

app :: SecondWindow

Another window with a small VerticalLayout
class TableView

ios :: TableView

iOS specific layout using a UITableView, works only with simple children views
class TextInput

app :: TextInput

A control for the user to enter custom text
abstract class TextView

app :: TextView

A control displaying some text
class UiExampleWindow

app :: UiExampleWindow

Window showing off some the available controls
class VerticalLayout

app :: VerticalLayout

A vertical linear organization
abstract class View

app :: View

A visible Control
class Window

app :: Window

A window, root of the Control tree

Class definitions

app $ AppComponent
# An element of an application that is notified of the application life cycle
#
# Most users of _app.nit_ need only to implement `on_create` to setup the application.
#
# On mobile devices, the application can be stopped a anytime when another application takes the foreground.
# Implement the callbacks `on_save_state` and `on_load_state` to keep the state of the application between execution,
# for an illusion of continuous execution.
abstract class AppComponent

	# The application is being created
	#
	# You should build the UI at this time.
	#
	# Triggers are platform specific:
	# * Android: `Activity.onCreate`
	# * iOS: `UIApplicationDelegate application:didFinishLaunchingWithOptions`
	fun on_create do end

	# The application enters the active state, it is in the foreground and interactive
	#
	# Triggers are platform specific:
	# * Android: `Activity.onResume`
	# * iOS: `UIApplicationDelegate applicationDidBecomeActive`
	fun on_resume do end

	# The application leaves the active state but is still partially visible
	#
	# It may then go back to `on_resume` or `on_stop`.
	#
	# Triggers are platform specific:
	# * Android: `Activity.onPause`
	# * iOS: `UIApplicationDelegate applicationWillResignActive`
	fun on_pause do end

	# The application is completely hidden from the user
	#
	# It may then be destroyed or go back to a paused state with `on_restart`.
	#
	# Triggers are platform specific:
	# * Android: `Activity.onStop`
	# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
	fun on_stop do end

	# The application returns to a visible state from a previous `on_stop`
	#
	# Triggers are platform specific:
	# * Android: `Activity.onRestart`
	# * iOS: `UIApplicationDelegate applicationWillEnterForeground`
	fun on_restart do end

	# The application may be destroyed soon, save its state for a future `on_restore_state`
	#
	# Triggers are platform specific:
	# * Android: `Activity.onSaveInstanceState`
	# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
	fun on_save_state do end

	# The application is launching, restore its state from a previous `on_save_state`
	#
	# Triggers are platform specific:
	# * Android: `Activity.onCreate`, _not_ `Activity.onRestoreInstanceState`
	#   as it is trigged only if there is a previous Android specific save state.
	# * iOS: `UIApplicationDelegate applicationDidEnterBackground`
	fun on_restore_state do end
end
lib/app/app_base.nit:42,1--106,3

app :: ui $ AppComponent
redef class AppComponent
	super AppObserver

	# All `AppObserver` notified of events raised by `self`
	#
	# By default, only `self` is an observer.
	# Any other `AppObserver` can be added to this collection.
	var observers = new HashSet[AppObserver].from([self: AppObserver])

	# Propagate `event` to all `observers` by calling `AppObserver::on_event`
	fun notify_observers(event: AppEvent)
	do
		for observer in observers do
			observer.on_event(event)
		end
	end
end
lib/app/ui.nit:109,1--125,3

android :: nit_activity $ AppComponent
redef class AppComponent
	# The application is starting or restarting, it is visible to the user
	fun on_start do end

	# The application is being destroyed
	fun on_destroy do end
end
lib/android/nit_activity.nit:211,1--217,3