sk.baka.ambient.activity.main
Class StaticPlaylistController

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
              extended by sk.baka.ambient.activity.main.StaticPlaylistController
All Implemented Interfaces:
IApplicationListener, IGestureListViewListener

public final class StaticPlaylistController
extends AbstractPlaylistController

Manages provided track list. Uses a simple List of tracks as model.

Author:
Martin Vysny

Nested Class Summary
 
Nested classes/interfaces inherited from class sk.baka.ambient.activity.main.AbstractController
AbstractController.Listener
 
Field Summary
 
Fields inherited from class sk.baka.ambient.activity.main.AbstractPlaylistController
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
StaticPlaylistController(int mainViewId, int listviewId, Activity activity, List<TrackMetadataBean> tracks, boolean addActivated)
          Creates new controller.
 
Method Summary
 String getHint(Interval highlight)
           Returns a very short and simple string representation of the selected contents.
protected  int getPlaylistSize()
          Returns the underlying playlist size.
protected  int getQueueNumber(int index)
          Returns queue status of given track.
protected  TrackMetadataBean getTrack(int index)
          Retrieves a track from given position.
 List<TrackMetadataBean> getTracks()
          Returns an unmodifiable view on the track list.
protected  boolean isCurrentlyPlayedTrack(int index)
          Checks if the track at given index is currently being played.
 void itemActivated(int index, Object model)
          The item was activated, either by clicking on it or using a keyboard.
 Interval moveItems(Interval highlight, int index)
           Move selected items up or down.
 Interval moveItemsByOne(Interval highlight, boolean down)
           Move selected items up or down.
 void removeItems(Interval remove)
          The contract: when overriding this method, be sure to call this super method after you are done deleting items.
 void setResults(List<TrackMetadataBean> tracks, String query, SearchType type)
          Shows given search result on the list view.
 void setTracks(List<TrackMetadataBean> tracks)
          Sets new track list.
 void stateChanged(AppState state)
          The application state was changed.
 
Methods inherited from class sk.baka.ambient.activity.main.AbstractPlaylistController
canComputeItems, clipboardChanged, computeTracks, configChanged, initialize, isComputeTracksLong, isComputeTracksOnlineOp, isReadOnly, offline, recomputeListItems, update
 
Methods inherited from class sk.baka.ambient.activity.main.AbstractListController
canHighlight, destroy, dropItems, getClipboard, highlightChanged, 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
 

Constructor Detail

StaticPlaylistController

public StaticPlaylistController(int mainViewId,
                                int listviewId,
                                Activity activity,
                                List<TrackMetadataBean> tracks,
                                boolean addActivated)
Creates new controller.

Parameters:
mainViewId - the view whose visibility is controlled.
listviewId - the list view id
activity - the parent activity.
tracks - initial track list.
addActivated - if true then the activated items are added at the end of the playlist.
Method Detail

itemActivated

public void itemActivated(int index,
                          Object model)
Description copied from interface: IGestureListViewListener
The item was activated, either by clicking on it or using a keyboard.

Parameters:
index - the index of the item.
model - the model for the item.

getPlaylistSize

protected int getPlaylistSize()
Description copied from class: AbstractPlaylistController
Returns the underlying playlist size.

Specified by:
getPlaylistSize in class AbstractPlaylistController
Returns:
the playlist size.

getTrack

protected TrackMetadataBean getTrack(int index)
Description copied from class: AbstractPlaylistController
Retrieves a track from given position.

Specified by:
getTrack in class AbstractPlaylistController
Parameters:
index - the index
Returns:
the track instance, never null.

isCurrentlyPlayedTrack

protected boolean isCurrentlyPlayedTrack(int index)
Description copied from class: AbstractPlaylistController
Checks if the track at given index is currently being played.

Specified by:
isCurrentlyPlayedTrack in class AbstractPlaylistController
Parameters:
index - the track index
Returns:
true if it is being played, false otherwise.

removeItems

public void removeItems(Interval remove)
Description copied from class: AbstractPlaylistController
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 AbstractPlaylistController
Parameters:
remove - the interval to remove

moveItems

public Interval moveItems(Interval highlight,
                          int index)
Description copied from interface: IGestureListViewListener

Move selected items up or down. The listener must update the items and return the new highlight. This operation is always considered as a short-running and thus always executed directly in handler's event thread.

The list view will be redrawn automatically when the method returns.

This operation is invoked only when IGestureListViewListener.isReadOnly() returns false.

Specified by:
moveItems in interface IGestureListViewListener
Overrides:
moveItems in class AbstractListController
Parameters:
highlight - move these items
index - drop the items before item with this index.
Returns:
new interval which contains all moved tracks.

moveItemsByOne

public Interval moveItemsByOne(Interval highlight,
                               boolean down)
Description copied from interface: IGestureListViewListener

Move selected items up or down. The listener must update the items and return the new highlight. This operation is always considered as a short-running and thus always executed directly in handler's event thread.

The list view will be redrawn automatically when the method returns.

This operation is invoked only when IGestureListViewListener.isReadOnly() returns false.

Specified by:
moveItemsByOne in interface IGestureListViewListener
Overrides:
moveItemsByOne in class AbstractListController
Parameters:
highlight - move these items
down - down if true then move the highlighted interval down, otherwise move it up.
Returns:
new interval which contains all moved tracks.

getTracks

public List<TrackMetadataBean> getTracks()
Returns an unmodifiable view on the track list.

Returns:
list of tracks.

getHint

public 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
Specified by:
getHint in class AbstractPlaylistController
Parameters:
highlight - the highlighted items.
Returns:
short description of selected contents. May be null if no hint should be shown.

getQueueNumber

protected int getQueueNumber(int index)
Description copied from class: AbstractPlaylistController
Returns queue status of given track.

Specified by:
getQueueNumber in class AbstractPlaylistController
Parameters:
index - the track index
Returns:
queue number or 0 if the track is not queued.

setResults

public void setResults(List<TrackMetadataBean> tracks,
                       String query,
                       SearchType type)
Shows given search result on the list view.

Parameters:
tracks - the model to show.
query - the query
type - hint on the type of data in the model.

setTracks

public void setTracks(List<TrackMetadataBean> tracks)
Sets new track list.

Parameters:
tracks -

stateChanged

public void stateChanged(AppState state)
Description copied from interface: IApplicationListener
The application state was changed.

Parameters:
state - the state instance, must NOT be modified.


Copyright © 2007-2008. All Rights Reserved.