sk.baka.ambient
Class AppStateHandler

java.lang.Object
  extended by sk.baka.ambient.AppStateHandler

public final class AppStateHandler
extends Object

Handles application configuration and state storage.

Author:
Martin Vysny

Constructor Summary
AppStateHandler(AmbientApplication app)
          Creates new handler.
 
Method Summary
 boolean containsStateAware(Class<? extends AppState.IAppStateAware> clazz)
          Checks if a handler with given class is present in the state aware handlers.
 ConfigurationBean getConfig()
          Returns the configuration bean.
 AppState getStartupState()
          Returns the startup application state.
 void registerStateAware(AppState.IAppStateAware aware)
          Registers given state aware object.
 void saveConfig()
          Stores the configuration bean to the shared preferences.
 void saveState()
          Saves the state.
 void unregisterStateAware(AppState.IAppStateAware aware)
          Unregisters given state aware object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppStateHandler

public AppStateHandler(AmbientApplication app)
Creates new handler. The application configuration is loaded automatically. The handler is essentially a singleton and caller should make sure there is at most single instance of the handler.

Parameters:
app - owning application.
Method Detail

containsStateAware

public boolean containsStateAware(Class<? extends AppState.IAppStateAware> clazz)
Checks if a handler with given class is present in the state aware handlers.

Parameters:
clazz - the handler class, must not be null.
Returns:
true if given handler is present, false otherwise.

saveState

public void saveState()
Saves the state. Polls all global state aware objects.


registerStateAware

public void registerStateAware(AppState.IAppStateAware aware)
Registers given state aware object.

Parameters:
aware - the object instance.

unregisterStateAware

public void unregisterStateAware(AppState.IAppStateAware aware)
Unregisters given state aware object.

Parameters:
aware - the object instance.

getStartupState

public AppState getStartupState()
Returns the startup application state.

Returns:
the application state. Never null.

saveConfig

public void saveConfig()
Stores the configuration bean to the shared preferences.


getConfig

public ConfigurationBean getConfig()
Returns the configuration bean.

Returns:
the configuration bean. Only the ConfigActivity may modify this bean!


Copyright © 2007-2008. All Rights Reserved.