@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; }
private void gotoBookmark(Bookmark bookmark) { bookmark.markAsAccessed(); myCollection.saveBookmark(bookmark); final Book book = myCollection.getBookById(bookmark.getBookId()); if (book != null) { FBReader.openBookActivity(this, book, bookmark); } else { UIUtil.showErrorMessage(this, "cannotOpenBook"); } }
@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"); } }