sk.baka.ambient.activity.main.cb
Interface IContentManager

All Known Implementing Classes:
CategoryManager, GroupingManager, TrackManager

public interface IContentManager

Manages current content as shown by the collection.

All long-running operations (methods not executed in handler's thread) should periodically check for interrupted status, throwing InterruptedException (or other type of exception) if they are interrupted.

Author:
Martin Vysny

Method Summary
 boolean canReturnTracks()
          Checks if this manager can provide a list of tracks.
 List<String> getDisplayableContent()
           Returns string representation of items contained in this manager.
 int getIndexOfPreviouslyActivatedItem(IContentManager contentManager)
          When activating an item, the manager should keep track of this item so that it can return its index when going back.
 String getSelectedItemName()
          Returns selected item as a displayable string.
 List<TrackMetadataBean> getTracks(Interval selection)
          Computes a list of tracks.
 IContentManager goBack()
           Returns a content manager which will handle contents after a back operation.
 boolean initialize(boolean isYear, ICollection collection)
           Initialize this manager and fetch the data.
 IContentManager itemActivated(int i)
           User activated given item.
 void uninitialize()
          This manager will not be used for a while.
 

Method Detail

initialize

boolean initialize(boolean isYear,
                   ICollection collection)
                   throws CollectionException,
                          InterruptedException

Initialize this manager and fetch the data. This method will not be invoked in handler's thread. This is the first method invoked on a new manager (or managers retrieved by goBack() and itemActivated(int) methods).

The manager may be initialized multiple times with different values of the isYear. The manager should simply do nothing if its previous contents does not change.

Parameters:
isYear - true if year is displayed, false otherwise.
collection - the collection to poll data from.
Returns:
the manager contains new data and the display component should be invalidated to reflect this new data.
Throws:
CollectionException - if the underlying collection throws an exception.
InterruptedException - if interrupted.

goBack

IContentManager goBack()

Returns a content manager which will handle contents after a back operation.

This method is run in handler's thread.

Returns:
the manager instance, may be null if the back operation is not allowed. Returned manager instance is uninitialized.

itemActivated

IContentManager itemActivated(int i)

User activated given item. Return a new manager which will handle new contents.

This method is run in handler's thread.

Parameters:
i - the item index.
Returns:
new content manager or null if we cannot move forward. Returned manager instance is uninitialized.

uninitialize

void uninitialize()
This manager will not be used for a while. It should discard all of its internal caches.


getDisplayableContent

List<String> getDisplayableContent()

Returns string representation of items contained in this manager.

This method is run in handler's thread.

Returns:
the displayable list, never null, may be empty.

canReturnTracks

boolean canReturnTracks()
Checks if this manager can provide a list of tracks. This method is run in handler's thread.

Returns:
true if the manager is able to provide a list of tracks.

getTracks

List<TrackMetadataBean> getTracks(Interval selection)
                                  throws CollectionException,
                                         InterruptedException
Computes a list of tracks. Run only if canReturnTracks() returns true. This method is not run in handler's thread.

Parameters:
selection - the selection
Returns:
list of tracks.
Throws:
CollectionException - if the underlying collection throws an exception.
InterruptedException - if interrupted.

getIndexOfPreviouslyActivatedItem

int getIndexOfPreviouslyActivatedItem(IContentManager contentManager)
When activating an item, the manager should keep track of this item so that it can return its index when going back. This method is run in handler's thread.

Parameters:
contentManager - the other manager on the same level.
Returns:
the item index or -1 if the item could no longer be found.

getSelectedItemName

String getSelectedItemName()
Returns selected item as a displayable string. If no item was selected yet since the last initialization then return a short descriptive name of this content manager.

Returns:
the item name or manager name.


Copyright © 2007-2008. All Rights Reserved.