sk.baka.ambient.views.gesturelist
Class ModelHolder

java.lang.Object
  extended by sk.baka.ambient.views.gesturelist.ModelHolder

public final class ModelHolder
extends Object

Manages the model for the GesturesListView.

Handles special End Of Playlist item - this item allows us to insert tracks at the end of the playlist (and into an empty playlist) using keypad gestures. The special item is shown only when the list view:

Author:
Martin Vysny

Field Summary
(package private)  MutableListAdapter adapter
          The backing adapter.
 
Constructor Summary
ModelHolder(GesturesListView owner)
          Creates new instance.
 
Method Summary
 Interval getAllItems()
          Returns interval containing all items.
 Interval getHighlight()
          Returns current highlight.
 Interval getHighlight(boolean returnSelectionOnEmptyHighlight)
          Returns current highlight.
 Interval getHighlight(int returnSelectionOnEmptyHighlight)
          Returns current highlight.
 List<Object> getModel()
           Returns a list of items.
 void highlight(Interval highlight)
          Highlight given items.
 void notifyModified()
          Redraws items and reflects changes made to the getModel() list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

adapter

final MutableListAdapter adapter
The backing adapter.

Constructor Detail

ModelHolder

ModelHolder(GesturesListView owner)
Creates new instance.

Parameters:
owner - owner listview.
Method Detail

getModel

public List<Object> getModel()

Returns a list of items. The backing array of item data. In the MVC terminology, this is a model for all items. If you plan to modify this list, do not forget to call notifyModified() after all modifications are made.

This model must never contain the MutableListAdapter.EOP_MODEL_MARKER object!

Returns:
a live list of item data.

notifyModified

public void notifyModified()
Redraws items and reflects changes made to the getModel() list.


highlight

public void highlight(Interval highlight)
Highlight given items. Does not update the view - you need to call notifyModified() to force the redraw.

Parameters:
highlight - items to highlight

getHighlight

public Interval getHighlight()
Returns current highlight.

Returns:
current highlight, never null.

getHighlight

public Interval getHighlight(boolean returnSelectionOnEmptyHighlight)
Returns current highlight. If no items are highlighted, optionally return current selection.

Parameters:
returnSelectionOnEmptyHighlight - if true and no items are currently being highlighted, return current selection.
Returns:
current highlight, never null.

getHighlight

public Interval getHighlight(int returnSelectionOnEmptyHighlight)
Returns current highlight. If no items are highlighted, optionally return given item.

Parameters:
returnSelectionOnEmptyHighlight - if not negative and no items are currently being highlighted, return selection consisting of a single item.
Returns:
current highlight, never null.

getAllItems

public Interval getAllItems()
Returns interval containing all items.

Returns:
non-null interval.


Copyright © 2007-2008. All Rights Reserved.