/**
   * Start a search
   *
   * @param author Author to search for
   * @param title Title to search for
   * @param isbn ISBN to search for
   */
  public void search(
      String author, String title, String isbn, boolean fetchThumbnail, int searchFlags) {
    if ((searchFlags & SEARCH_ALL) == 0)
      throw new RuntimeException("Must specify at least one source to use");

    if (mRunningTasks.size() > 0) {
      throw new RuntimeException("Attempting to start new search while previous search running");
    }

    // Save the flags
    mSearchFlags = searchFlags;
    if (!Utils.USE_LT) {
      mSearchFlags &= ~SEARCH_LIBRARY_THING;
    }

    // Save the input and initialize
    mBookData = new Bundle();
    mSearchResults = new Hashtable<Integer, Bundle>();

    mWaitingForIsbn = false;
    mCancelledFlg = false;

    mAuthor = author;
    mTitle = title;
    mIsbn = isbn;
    mHasIsbn = mIsbn != null && mIsbn.trim().length() > 0 && IsbnUtils.isValid(mIsbn);

    mFetchThumbnail = fetchThumbnail;

    // XXXX: Not entirely sure why this code was targetted at the UI thread.
    doSearch();
    // if (mTaskManager.runningInUiThread()) {
    //	doSearch();
    // } else {
    //	mTaskManager.postToUiThread(new Runnable() {
    //		@Override
    //		public void run() {
    //			doSearch();
    //		}});
    // }
  }
  private void doSearch() {
    // List for task ends
    TaskManager.getMessageSwitch().addListener(mTaskManager.getSenderId(), this, false);
    // System.out.println("Listening");

    // We really want to ensure we get the same book from each, so if isbn is not present, do
    // these in series.

    boolean tasksStarted = false;
    mSearchingAsin = false;
    try {
      if (mIsbn != null && mIsbn.length() > 0) {
        if (IsbnUtils.isValid(mIsbn)) {
          // We have an ISBN, just do the search
          mWaitingForIsbn = false;
          tasksStarted = this.startSearches(mSearchFlags);
        } else {
          // Assume it's an ASIN, and just search Amazon
          mSearchingAsin = true;
          mWaitingForIsbn = false;
          // mSearchFlags = SEARCH_AMAZON;
          tasksStarted = startOneSearch(SEARCH_AMAZON);
          // tasksStarted = this.startSearches(mSearchFlags);
        }
      } else {
        // Run one at a time, startNext() defined the order.
        mWaitingForIsbn = true;
        tasksStarted = startNext();
      }
    } finally {
      if (!tasksStarted) {
        sendResults();
        TaskManager.getMessageSwitch().removeListener(mTaskManager.getSenderId(), this);
        // System.out.println("Not listening(2)");
      }
    }
  }