Пример #1
0
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = ViewUtil.findImageView(view, R.id.bookmark_item_icon);
      final TextView textView = ViewUtil.findTextView(view, R.id.bookmark_item_text);
      final TextView bookTitleView = ViewUtil.findTextView(view, R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(myResource.getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myShowAddBookmarkItem) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
Пример #2
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");
    }
  }