sk.baka.ambient.activity.main
Class AbstractController

java.lang.Object
  extended by sk.baka.ambient.activity.main.AbstractController
Direct Known Subclasses:
AbstractListController, ContextController, PlayerController, TaskSwitcherController, WindowButtonsController

public abstract class AbstractController
extends Object

A base class each controller must extend. Defines common operations.

Author:
Martin Vysny

Nested Class Summary
protected  class AbstractController.Listener
          The activity button listener.
 
Field Summary
protected  AmbientApplication app
          Returns the application instance.
protected  boolean cycle
          If true then random/repeat modes are cycled instead of being activated.
protected  AbstractController.Listener listener
          Listens for click actions and activates ActionsEnum stored in the tag values.
protected  Activity mainActivity
          Reference to the main activity.
protected  View mainView
          The main view controlled by this controller.
 
Constructor Summary
protected AbstractController(int mainViewId, Activity mainActivity)
          Creates new controller.
 
Method Summary
 void destroy()
          The controller is about to be destroyed.
 boolean equals(Object o)
           
 void flipVisibility()
          Flips the player visibility - shows it if it is hidden or vice versa.
 int hashCode()
           
 void hide()
          Hides the view and removes it (the View.GONE functionality).
static void initButtonBar(ButtonBar bar, List<ActionsEnum> actions, Point bitmapSize, Point hoveredBitmapSize)
          Initializes given button bar with buttons.
protected  void initButtonBar(int buttonbarId, List<ActionsEnum> actions)
          Initializes given button bar with buttons.
protected  void initButtonBar(int buttonbarId, List<ActionsEnum> actions, Point bitmapSize, Point hoveredBitmapSize)
          Initializes given button bar with buttons.
protected  boolean isDestroyed()
          Checks if this controller was destroyed.
 boolean isVisible()
          Checks if the view controlled by this controller is visible.
protected  boolean isZoomed()
          Checks if this controller is zoomed.
protected  void onAction(ActionsEnum action)
          Called when an action button is pressed.
protected abstract  void performZoom(boolean zoom)
          Zooms, or un-zooms the controller.
 void setVisibility(boolean visible)
          Sets the visibility of the view controlled by this controller.
 void show()
          Shows the view on screen.
 void update(Interval select)
          Reinitializes the underlying view.
protected  void visibilityChanged(boolean visible)
          Invoked when the component visibility changes.
 void zoom(boolean zoom)
          Zooms, or un-zooms the controller.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mainView

protected View mainView
The main view controlled by this controller.


mainActivity

protected Activity mainActivity
Reference to the main activity.


cycle

protected boolean cycle
If true then random/repeat modes are cycled instead of being activated.


listener

protected final AbstractController.Listener listener
Listens for click actions and activates ActionsEnum stored in the tag values.


app

protected AmbientApplication app
Returns the application instance.

Constructor Detail

AbstractController

protected AbstractController(int mainViewId,
                             Activity mainActivity)
Creates new controller.

Parameters:
mainViewId - the view whose visibility is controlled.
mainActivity - the activity.
Method Detail

flipVisibility

public final void flipVisibility()
Flips the player visibility - shows it if it is hidden or vice versa.


isVisible

public final boolean isVisible()
Checks if the view controlled by this controller is visible.

Returns:
true if visible, false otherwise.

show

public final void show()
Shows the view on screen.


visibilityChanged

protected void visibilityChanged(boolean visible)
Invoked when the component visibility changes. By default does nothing.

Parameters:
visible - new visibility flag.

hide

public final void hide()
Hides the view and removes it (the View.GONE functionality).


setVisibility

public final void setVisibility(boolean visible)
Sets the visibility of the view controlled by this controller.

Parameters:
visible - if true then the view is made visible, otherwise it is made GONE.

onAction

protected void onAction(ActionsEnum action)
Called when an action button is pressed. By default invokes main activity. Subclasses can override.

Parameters:
action - the action to take

update

public void update(Interval select)
Reinitializes the underlying view. Used when the view was not updated for a time and is about to be shown on screen. Default implementation does nothing.

Parameters:
select - reset selection to this interval.

initButtonBar

protected void initButtonBar(int buttonbarId,
                             List<ActionsEnum> actions)
Initializes given button bar with buttons. The size is 32x32 (48x48 when hovered) when not zoomed, 48x48 (64x64 when hovered) when zoomed.

Parameters:
buttonbarId - the resource id of the ButtonBar component.
actions - the list of actions.

initButtonBar

protected void initButtonBar(int buttonbarId,
                             List<ActionsEnum> actions,
                             Point bitmapSize,
                             Point hoveredBitmapSize)
Initializes given button bar with buttons.

Parameters:
buttonbarId - the resource id of the ButtonBar component.
actions - the list of actions.
bitmapSize - the size of all buttons.
hoveredBitmapSize - maximum size of a button when hovered.

initButtonBar

public static final void initButtonBar(ButtonBar bar,
                                       List<ActionsEnum> actions,
                                       Point bitmapSize,
                                       Point hoveredBitmapSize)
Initializes given button bar with buttons.

Parameters:
bar - the ButtonBar component.
actions - the list of actions.
bitmapSize - the size of all buttons.
hoveredBitmapSize - maximum size of a button when hovered.

destroy

public void destroy()
The controller is about to be destroyed. No invocations are performed after this call. The controller should release its resources, stop its activities etc. Make sure that you call super() if you override this method!


isDestroyed

protected final boolean isDestroyed()
Checks if this controller was destroyed.

Returns:
true if this controller is destroyed.

equals

public final boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

zoom

public final void zoom(boolean zoom)
Zooms, or un-zooms the controller.

Parameters:
zoom - true zoom the controller in, false zoom the controller out.

performZoom

protected abstract void performZoom(boolean zoom)
Zooms, or un-zooms the controller.

Parameters:
zoom - true zoom the controller in, false zoom the controller out.

isZoomed

protected final boolean isZoomed()
Checks if this controller is zoomed.

Returns:
true if zoomed, false otherwise.


Copyright © 2007-2008. All Rights Reserved.