sk.baka.ambient.activity.main
Class PlaylistController

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.PlaylistController
All Implemented Interfaces:
IApplicationListener, IPlaylistPlayerListener, IGestureListViewListener

public final class PlaylistController
extends AbstractPlaylistController
implements IPlaylistPlayerListener

Manages the 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
PlaylistController(MainActivity mainActivity)
          Creates the controller
 
Method Summary
 void dropItems(List<TrackMetadataBean> tracks, int x, int y, int index)
          The drag'n'drop operation is finished.
 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.
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 playbackStateChanged(PlayerStateEnum state)
          The playback state was changed.
 void playlistChanged(Interval target)
          Fired when the playlist changes - by removing a track, reshuffling etc.
 void randomChanged(Random random)
          The play mode was changed.
 void removeItems(Interval remove)
          The contract: when overriding this method, be sure to call this super method after you are done deleting items.
 void repeatChanged(Repeat repeat)
          The play mode was changed.
 void stateChanged(AppState state)
          The application state was changed.
 void trackChanged(PlaylistItem track, boolean play, int positionMillis)
          A new track was selected in the playlist.
 void trackPositionChanged(int position, boolean playing)
           A position in the track 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, 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
 

Field Detail

PLAYLIST_VIEW_ID

public static final int PLAYLIST_VIEW_ID
The playlist view id.

See Also:
Constant Field Values
Constructor Detail

PlaylistController

public PlaylistController(MainActivity mainActivity)
Creates the controller

Parameters:
mainActivity - the activity
Method Detail

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.

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.

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.

Specified by:
itemActivated in interface IGestureListViewListener
Parameters:
index - the index of the item.
model - the model for the item.

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

getPlaylistSize

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

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

dropItems

public void dropItems(List<TrackMetadataBean> tracks,
                      int x,
                      int y,
                      int index)
Description copied from interface: IGestureListViewListener
The drag'n'drop operation is finished. This view has received a list of tracks.

Specified by:
dropItems in interface IGestureListViewListener
Overrides:
dropItems in class AbstractListController
Parameters:
tracks - the tracks
x - the drop point x axis relative to the item upper-left corner.
y - the drop point y axis relative to the item upper-left corner.
index - the index of the item where the files were dropped.

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.

trackChanged

public void trackChanged(PlaylistItem track,
                         boolean play,
                         int positionMillis)
Description copied from interface: IPlaylistPlayerListener
A new track was selected in the playlist.

Specified by:
trackChanged in interface IPlaylistPlayerListener
Parameters:
track - the new track, may be null - in this case the playback is stopped.
play - if true then the track is already being played (or is about to be played).
positionMillis - the starting playback position in milliseconds.

playbackStateChanged

public void playbackStateChanged(PlayerStateEnum state)
Description copied from interface: IPlaylistPlayerListener
The playback state was changed.

Specified by:
playbackStateChanged in interface IPlaylistPlayerListener
Parameters:
state - new playback state.

randomChanged

public void randomChanged(Random random)
Description copied from interface: IPlaylistPlayerListener
The play mode was changed.

Specified by:
randomChanged in interface IPlaylistPlayerListener
Parameters:
random - new random value, never null.

repeatChanged

public void repeatChanged(Repeat repeat)
Description copied from interface: IPlaylistPlayerListener
The play mode was changed.

Specified by:
repeatChanged in interface IPlaylistPlayerListener
Parameters:
repeat - new repeat value, never null.

trackPositionChanged

public void trackPositionChanged(int position,
                                 boolean playing)
Description copied from interface: IPlaylistPlayerListener

A position in the track was changed. This is only due to PlaylistPlayer.seek(int) - it is never invoked periodically as the playback progresses. This event is not invoked when a playback is started with non-zero start seek time.

Note that the playback may be paused.

Specified by:
trackPositionChanged in interface IPlaylistPlayerListener
Parameters:
position - the new position in milliseconds.
playing - if true then playback is activated, if false then the playback is paused. This event is not invoked when the playback is stopped.

playlistChanged

public void playlistChanged(Interval target)
Description copied from interface: IPlaylistPlayerListener
Fired when the playlist changes - by removing a track, reshuffling etc.

Specified by:
playlistChanged in interface IPlaylistPlayerListener
Parameters:
target - the "target" (or the product) of the operation - for example for copy/move operations this interval contains added items, for delete operation the interval is empty. May be null if the target is not known. Semantically, the target should contain tracks that were 'produced' by the operation and they should be the target of the next operation. This implies that the playlist view should make these tracks appear selected.

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.

stateChanged

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

Specified by:
stateChanged in interface IApplicationListener
Parameters:
state - the state instance, must NOT be modified.


Copyright © 2007-2008. All Rights Reserved.