sk.baka.ambient.activity.main
Class AbstractPlaylistController

java.lang.Object
  extended by sk.baka.ambient.activity.main.AbstractController
      extended by sk.baka.ambient.activity.main.AbstractListController
          extended by sk.baka.ambient.activity.main.AbstractPlaylistController
All Implemented Interfaces:
IApplicationListener, IGestureListViewListener
Direct Known Subclasses:
PlaylistController, StaticPlaylistController

public abstract class AbstractPlaylistController
extends AbstractListController
implements IApplicationListener

Groups functionality for a controller managing a playlist.

Author:
Martin Vysny

Nested Class Summary
 
Nested classes/interfaces inherited from class sk.baka.ambient.activity.main.AbstractController
AbstractController.Listener
 
Field Summary
static int PLAYLIST_VIEW_ID
          The playlist view id.
 
Fields inherited from class sk.baka.ambient.activity.main.AbstractListController
highlightColor, listView
 
Fields inherited from class sk.baka.ambient.activity.main.AbstractController
app, cycle, listener, mainActivity, mainView
 
Constructor Summary
AbstractPlaylistController(int mainViewId, int listViewId, Activity mainActivity)
           Creates new controller.
 
Method Summary
 boolean canComputeItems()
          Checks if the model currently supports computing tracks.
 void clipboardChanged()
          The clipboard has been changed.
 List<TrackMetadataBean> computeTracks(Interval highlight)
           Retrieve a list of tracks from the selection.
 void configChanged(ConfigurationBean config)
          The configuration was changed.
abstract  String getHint(Interval highlight)
           Returns a very short and simple string representation of the selected contents.
protected abstract  int getPlaylistSize()
          Returns the underlying playlist size.
protected abstract  int getQueueNumber(int index)
          Returns queue status of given track.
protected abstract  TrackMetadataBean getTrack(int index)
          Retrieves a track from given position.
protected  void initialize()
          Overriding classes must invoke this method at the end of their constructors.
 boolean isComputeTracksLong(Interval interval)
           Checks if the IGestureListViewListener.computeTracks(Interval) method will be a long operation.
 boolean isComputeTracksOnlineOp(Interval interval)
           Checks if the IGestureListViewListener.computeTracks(Interval) method will involve polling of some data from the Internet.
protected abstract  boolean isCurrentlyPlayedTrack(int index)
          Checks if the track at given index is currently being played.
 boolean isReadOnly()
          Checks if the list view is currently read-only.
 void offline(boolean offline)
          Informs that the application has entered an offline/online mode.
protected  void recomputeListItems()
          Recomputes the model.
 void removeItems(Interval remove)
          The contract: when overriding this method, be sure to call this super method after you are done deleting items.
 void update(GesturesListView listView, View itemView, int index, Object model)
          An item view is being drawn (or re-drawn) on screen.
 
Methods inherited from class sk.baka.ambient.activity.main.AbstractListController
canHighlight, destroy, dropItems, getClipboard, highlightChanged, moveItems, moveItemsByOne, performZoom, setClipboard, update
 
Methods inherited from class sk.baka.ambient.activity.main.AbstractController
equals, flipVisibility, hashCode, hide, initButtonBar, initButtonBar, initButtonBar, isDestroyed, isVisible, isZoomed, onAction, setVisibility, show, visibilityChanged, zoom
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sk.baka.ambient.IApplicationListener
stateChanged
 
Methods inherited from interface sk.baka.ambient.views.gesturelist.IGestureListViewListener
itemActivated
 

Field Detail

PLAYLIST_VIEW_ID

public static final int PLAYLIST_VIEW_ID
The playlist view id.

See Also:
Constant Field Values
Constructor Detail

AbstractPlaylistController

public AbstractPlaylistController(int mainViewId,
                                  int listViewId,
                                  Activity mainActivity)

Creates new controller.

The contract: the extending class MUST invoke the initialize() after it is done initializing.

Parameters:
mainViewId - the view whose visibility is controlled.
listViewId - the id of the GesturesListView
mainActivity -
Method Detail

initialize

protected final void initialize()
Overriding classes must invoke this method at the end of their constructors.


removeItems

public void removeItems(Interval remove)
The contract: when overriding this method, be sure to call this super method after you are done deleting items. The adapter must be invalidated, to prevent drawing old data.

Specified by:
removeItems in interface IGestureListViewListener
Overrides:
removeItems in class AbstractListController
Parameters:
remove - the interval to remove

getTrack

protected abstract TrackMetadataBean getTrack(int index)
Retrieves a track from given position.

Parameters:
index - the index
Returns:
the track instance, never null.

recomputeListItems

protected void recomputeListItems()
Description copied from class: AbstractListController
Recomputes the model. You don't have to call the ModelHolder.notifyModified() - it is called automatically after the method finishes.

Specified by:
recomputeListItems in class AbstractListController

getPlaylistSize

protected abstract int getPlaylistSize()
Returns the underlying playlist size.

Returns:
the playlist size.

update

public final void update(GesturesListView listView,
                         View itemView,
                         int index,
                         Object model)
Description copied from interface: IGestureListViewListener
An item view is being drawn (or re-drawn) on screen. The implementation should correctly set the view contents, based on the model object. The model object is taken from the GesturesListView.getModel() list. The only exception is the EOP special item. For more information please read here.

Specified by:
update in interface IGestureListViewListener
Parameters:
listView - the listview containing the view
itemView - the view representing a single item
index - the index in the GesturesListView.getModel() list. May point outside of the model list only when drawing an EOP item.
model - The model object, taken from the GesturesListView.getModel() list. This value may optionally be the MutableListAdapter.EOP_MODEL_MARKER object - in this case the special EndOfPlaylist item must be drawn.

getQueueNumber

protected abstract int getQueueNumber(int index)
Returns queue status of given track.

Parameters:
index - the track index
Returns:
queue number or 0 if the track is not queued.

isCurrentlyPlayedTrack

protected abstract boolean isCurrentlyPlayedTrack(int index)
Checks if the track at given index is currently being played.

Parameters:
index - the track index
Returns:
true if it is being played, false otherwise.

canComputeItems

public final boolean canComputeItems()
Description copied from interface: IGestureListViewListener
Checks if the model currently supports computing tracks. This also affects the drag'n'drop capability - we cannot drag'n'drop if a track list cannot be computed.

Specified by:
canComputeItems in interface IGestureListViewListener
Overrides:
canComputeItems in class AbstractListController
Returns:
true if the model can compute tracks, false otherwise.

isComputeTracksLong

public boolean isComputeTracksLong(Interval interval)
Description copied from interface: IGestureListViewListener

Checks if the IGestureListViewListener.computeTracks(Interval) method will be a long operation. If yes, then the operation will be run in new thread. If not, the operation will be run in handler event thread.

This method is only invoked when IGestureListViewListener.canComputeItems() returns true.

Specified by:
isComputeTracksLong in interface IGestureListViewListener
Overrides:
isComputeTracksLong in class AbstractListController
Parameters:
interval - the selection
Returns:
true if long operation, false otherwise.

isComputeTracksOnlineOp

public boolean isComputeTracksOnlineOp(Interval interval)
Description copied from interface: IGestureListViewListener

Checks if the IGestureListViewListener.computeTracks(Interval) method will involve polling of some data from the Internet.

This method is only invoked when IGestureListViewListener.canComputeItems() returns true.

Specified by:
isComputeTracksOnlineOp in interface IGestureListViewListener
Overrides:
isComputeTracksOnlineOp in class AbstractListController
Parameters:
interval - the selection
Returns:
true if some Internet resources will be polled, false otherwise.

isReadOnly

public boolean isReadOnly()
Description copied from interface: IGestureListViewListener
Checks if the list view is currently read-only.

Specified by:
isReadOnly in interface IGestureListViewListener
Overrides:
isReadOnly in class AbstractListController
Returns:
true if the view cannot be modified, false otherwise.

getHint

public abstract String getHint(Interval highlight)
Description copied from interface: IGestureListViewListener

Returns a very short and simple string representation of the selected contents.

This method is only invoked when IGestureListViewListener.canComputeItems() returns true.

Specified by:
getHint in interface IGestureListViewListener
Overrides:
getHint in class AbstractListController
Parameters:
highlight - the highlighted items.
Returns:
short description of selected contents. May be null if no hint should be shown.

configChanged

public void configChanged(ConfigurationBean config)
Description copied from interface: IApplicationListener
The configuration was changed.

Specified by:
configChanged in interface IApplicationListener
Parameters:
config - the configuration instance, must NOT be modified.

computeTracks

public List<TrackMetadataBean> computeTracks(Interval highlight)
Description copied from interface: IGestureListViewListener

Retrieve a list of tracks from the selection. This operation may not be invoked from the handler's thread (depending on the result of the IGestureListViewListener.isComputeTracksLong(Interval) method). The method implementation should thus periodically check for the interrupted flag. When interrupted, it should return an empty list or null ASAP. It may do so by throwing an exception

If the method is invoked in a non-handler thread the callee wraps the result in a thread-safe list.

The method may throw RuntimeException - it will be caught and displayed unless the thread is interrupted.

This method is only invoked when IGestureListViewListener.canComputeItems() returns true.

Specified by:
computeTracks in interface IGestureListViewListener
Overrides:
computeTracks in class AbstractListController
Parameters:
highlight - the selection
Returns:
a list of tracks, must not be null.

clipboardChanged

public void clipboardChanged()
Description copied from interface: IApplicationListener
The clipboard has been changed.

Specified by:
clipboardChanged in interface IApplicationListener

offline

public void offline(boolean offline)
Description copied from interface: IApplicationListener
Informs that the application has entered an offline/online mode.

Specified by:
offline in interface IApplicationListener
Parameters:
offline - if true then we are currently offline. If false then we are online.


Copyright © 2007-2008. All Rights Reserved.