sk.baka.ambient.activity.search
Class PlaylistEngine

java.lang.Object
  extended by sk.baka.ambient.activity.search.PlaylistEngine
All Implemented Interfaces:
ISearchEngine

public final class PlaylistEngine
extends Object
implements ISearchEngine

Search in playlist names.

Author:
Martin Vysny

Constructor Summary
PlaylistEngine()
           
 
Method Summary
 boolean canPerformSearch()
          Checks if this engine can currently perform the search.
 boolean canSearchOffline()
          Checks if this engine can perform an offline search.
 SearchType getType()
          Returns the type of this engine.
 void init(SearchActivity owner, int listViewId)
          Sets the owner activity and initializes the engine.
 void passivate()
          Passivates this engine.
 List<? extends Object> performSearch(String query)
          Performs a search for tracks contained words in given query.
 void update(List<? extends Object> model)
          Updates the list view with given model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlaylistEngine

public PlaylistEngine()
Method Detail

canSearchOffline

public boolean canSearchOffline()
Description copied from interface: ISearchEngine
Checks if this engine can perform an offline search. Executed in handler thread. May be invoked prior any other method.

Specified by:
canSearchOffline in interface ISearchEngine
Returns:
true if search can be performed offline, false otherwise.

init

public void init(SearchActivity owner,
                 int listViewId)
Description copied from interface: ISearchEngine
Sets the owner activity and initializes the engine. Executed in handler thread.

Specified by:
init in interface ISearchEngine
Parameters:
owner - owner view.
listViewId - the ID of the list view. Note that the list view is always configured to layout items using the playlist_item.xml layout.

passivate

public void passivate()
Description copied from interface: ISearchEngine
Passivates this engine. The engine may for example remove the listener on GesturesListView etc. Executed in handler thread.

Specified by:
passivate in interface ISearchEngine

performSearch

public List<? extends Object> performSearch(String query)
                                     throws Exception
Description copied from interface: ISearchEngine
Performs a search for tracks contained words in given query. The function must return non-null list which will serve as a model for GesturesListView. The method always executes in a new thread. The method should periodically check for Thread.isInterrupted() and terminate ASAP when interrupted.

Specified by:
performSearch in interface ISearchEngine
Parameters:
query - the query to search for
Returns:
result list. Not required to be thread-safe. May return null if interrupted. Given list must contain thread-safe objects.
Throws:
Exception - if search failed.

update

public void update(List<? extends Object> model)
Description copied from interface: ISearchEngine
Updates the list view with given model. This method is run in the Handler's thread. The engine must register in GesturesListView.listener and must be able to correctly display items returned by the ISearchEngine.performSearch(String) method.

Specified by:
update in interface ISearchEngine
Parameters:
model - the model as returned by ISearchEngine.performSearch(String).

getType

public SearchType getType()
Description copied from interface: ISearchEngine
Returns the type of this engine.

Specified by:
getType in interface ISearchEngine
Returns:
the engine type.

canPerformSearch

public boolean canPerformSearch()
Description copied from interface: ISearchEngine
Checks if this engine can currently perform the search. Executed in handler thread.

Specified by:
canPerformSearch in interface ISearchEngine
Returns:
true if search can be performed, false otherwise.


Copyright © 2007-2008. All Rights Reserved.