sk.baka.ambient.views.gesturelist
Interface IGestureListViewListener

All Known Implementing Classes:
AbstractCollectionController, AbstractListController, AbstractPlaylistController, AmpacheController, CollectionController, FileBrowserController, MagnatuneController, PlaylistController, PlaylistManagerController, ShoutcastController, StaticPlaylistController, StringListController

public interface IGestureListViewListener

Listens for events produced by the gesture list view listener.

Author:
Martin Vysny

Method Summary
 boolean canComputeItems()
          Checks if the model currently supports computing tracks.
 boolean canHighlight()
          Checks if we can start highlight mode now.
 List<TrackMetadataBean> computeTracks(Interval highlight)
           Retrieve a list of tracks from the selection.
 void dropItems(List<TrackMetadataBean> tracks, int x, int y, int index)
          The drag'n'drop operation is finished.
 Object getClipboard()
          Retrieves current clipboard value.
 String getHint(Interval highlight)
           Returns a very short and simple string representation of the selected contents.
 void highlightChanged(Interval highlight)
          Selection was changed.
 boolean isComputeTracksLong(Interval interval)
           Checks if the computeTracks(Interval) method will be a long operation.
 boolean isComputeTracksOnlineOp(Interval interval)
           Checks if the computeTracks(Interval) method will involve polling of some data from the Internet.
 boolean isReadOnly()
          Checks if the list view is currently read-only.
 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)
           Remove these items from the list.
 void setClipboard(TrackListClipboardObject clipboard)
          Sets the new clipboard.
 void update(GesturesListView listView, View itemView, int index, Object model)
          An item view is being drawn (or re-drawn) on screen.
 

Method Detail

removeItems

void removeItems(Interval remove)

Remove these items from the list. The list view sets the highlight automatically to zero interval.

This operation is invoked even when isReadOnly() returns false as some use cases activates a "Go Back" activity instead of deleting items.

Parameters:
remove - remove these items. The interval is not null however it may be empty.

highlightChanged

void highlightChanged(Interval highlight)
Selection was changed. The new highlight is already being drawn.

Parameters:
highlight - highlighted items

canHighlight

boolean canHighlight()
Checks if we can start highlight mode now.

Returns:
true if highlight mode can be started, false otherwise.

isReadOnly

boolean isReadOnly()
Checks if the list view is currently read-only.

Returns:
true if the view cannot be modified, false otherwise.

dropItems

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

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.

itemActivated

void itemActivated(int index,
                   Object model)
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.

moveItems

Interval moveItems(Interval highlight,
                   int index)

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 isReadOnly() returns false.

Parameters:
highlight - move these items
index - drop the items before item with this index.
Returns:
new interval which contains all moved tracks.

moveItemsByOne

Interval moveItemsByOne(Interval highlight,
                        boolean down)

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 isReadOnly() returns false.

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.

canComputeItems

boolean canComputeItems()
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.

Returns:
true if the model can compute tracks, false otherwise.

isComputeTracksLong

boolean isComputeTracksLong(Interval interval)

Checks if the 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 canComputeItems() returns true.

Parameters:
interval - the selection
Returns:
true if long operation, false otherwise.

isComputeTracksOnlineOp

boolean isComputeTracksOnlineOp(Interval interval)

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

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

Parameters:
interval - the selection
Returns:
true if some Internet resources will be polled, false otherwise.

computeTracks

List<TrackMetadataBean> computeTracks(Interval highlight)

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 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 canComputeItems() returns true.

Parameters:
highlight - the selection
Returns:
a list of tracks, must not be null.

getHint

String getHint(Interval highlight)

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

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

Parameters:
highlight - the highlighted items.
Returns:
short description of selected contents. May be null if no hint should be shown.

update

void update(GesturesListView listView,
            View itemView,
            int index,
            Object model)
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.

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.

setClipboard

void setClipboard(TrackListClipboardObject clipboard)
Sets the new clipboard.

Parameters:
clipboard - the clipboard to set.

getClipboard

Object getClipboard()
Retrieves current clipboard value.

Returns:
current clipboard contents. Do NOT cache this value.


Copyright © 2007-2008. All Rights Reserved.