sk.baka.ambient.activity.search
Interface ISearchEngine

All Known Implementing Classes:
AmpacheEngine, CollectionEngine, LibraryEngine, MagnatuneEngine, PlaylistEngine, ShoutcastEngine, SkreemrEngine

public interface ISearchEngine

Performs the search.

Author:
Martin Vysny

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.
 

Method Detail

getType

SearchType getType()
Returns the type of this engine.

Returns:
the engine type.

init

void init(SearchActivity owner,
          int listViewId)
Sets the owner activity and initializes the engine. Executed in handler thread.

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.

canSearchOffline

boolean canSearchOffline()
Checks if this engine can perform an offline search. Executed in handler thread. May be invoked prior any other method.

Returns:
true if search can be performed offline, false otherwise.

canPerformSearch

boolean canPerformSearch()
Checks if this engine can currently perform the search. Executed in handler thread.

Returns:
true if search can be performed, false otherwise.

performSearch

List<? extends Object> performSearch(String query)
                                     throws Exception
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.

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

void update(List<? extends Object> model)
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 performSearch(String) method.

Parameters:
model - the model as returned by performSearch(String).

passivate

void passivate()
Passivates this engine. The engine may for example remove the listener on GesturesListView etc. Executed in handler thread.



Copyright © 2007-2008. All Rights Reserved.