コード例 #1
0
  @Override
  protected void onNewIntent(Intent intent) {
    OrientationUtil.setOrientation(this, intent);

    if (!Intent.ACTION_SEARCH.equals(intent.getAction())) {
      return;
    }
    String pattern = intent.getStringExtra(SearchManager.QUERY);
    myBookmarkSearchPatternOption.setValue(pattern);

    final LinkedList<Bookmark> bookmarks = new LinkedList<Bookmark>();
    pattern = pattern.toLowerCase();
    for (Bookmark b : myAllBooksAdapter.bookmarks()) {
      if (MiscUtil.matchesIgnoreCase(b.getText(), pattern)) {
        bookmarks.add(b);
      }
    }
    if (!bookmarks.isEmpty()) {
      showSearchResultsTab(bookmarks);
    } else {
      UIUtil.showErrorMessage(this, "bookmarkNotFound");
    }
  }
コード例 #2
0
ファイル: FBReader.java プロジェクト: max-kammerer/FBReaderJ
 @Override
 protected void onNewIntent(Intent intent) {
   if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
     super.onNewIntent(intent);
   } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
     final String pattern = intent.getStringExtra(SearchManager.QUERY);
     final Runnable runnable =
         new Runnable() {
           public void run() {
             final FBReaderApp fbReader = (FBReaderApp) FBReaderApp.Instance();
             final TextSearchPopup popup =
                 (TextSearchPopup) fbReader.getPopupById(TextSearchPopup.ID);
             popup.initPosition();
             fbReader.TextSearchPatternOption.setValue(pattern);
             if (fbReader.getTextView().search(pattern, true, false, false, false) != 0) {
               runOnUiThread(
                   new Runnable() {
                     public void run() {
                       fbReader.showPopup(popup.getId());
                     }
                   });
             } else {
               runOnUiThread(
                   new Runnable() {
                     public void run() {
                       UIUtil.showErrorMessage(FBReader.this, "textNotFound");
                       popup.StartPosition = null;
                     }
                   });
             }
           }
         };
     UIUtil.wait("search", runnable, this);
   } else {
     super.onNewIntent(intent);
   }
 }