Esempio n. 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");
    }
  }
Esempio n. 2
0
  /**
   * Add article thumbnail to the appropriate rubric
   *
   * @param article
   */
  private void insertArticleView(RssArticle article) {
    LayoutInflater layoutInflater;
    View articleView;
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    LinearLayout rubricLayout;

    Bitmap thumbnailBitmap;

    TextView articleTitle;
    ImageView thumbnailImageView;

    int rubricId = article.getRubricId();
    Rubric rubric = articleFeed.getRubric(rubricId);
    int articlePosition = rubric.getPosition(article);

    updateRubricTitle(rubric);

    if (articlePosition >= rubric.getViewCount()
        && articlePosition > rubric.getMaximumViewCount()) {
      return;
    }

    rubric.increaseViewCount(1);

    layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    articleView = layoutInflater.inflate(R.layout.article_thumbnail, null);

    thumbnailImageView = (ImageView) articleView.findViewById(R.id.article_image);
    articleTitle = (TextView) articleView.findViewById(R.id.article_title);
    articleTitle.setText(article.getTitle());

    thumbnailBitmap = ThumbnailCache.getInstance().getBitmap(article.getEnclosure());
    if (thumbnailBitmap != null) {
      thumbnailImageView.setImageBitmap(thumbnailBitmap);
    } else {
      ThumbnailCache.getInstance().load(thumbnailImageView, article.getEnclosure());
    }
    listArticlesViews.add(articleView);

    if (article.isRead()) {
      thumbnailImageView.setColorFilter(0x99ffffff, PorterDuff.Mode.MULTIPLY);
      articleTitle.setTextColor(0xffb7b7b7);
    }

    String fontSize = preferences.getString("font_list_size", "medium");
    float imageSize = 12;
    float density = getResources().getDisplayMetrics().density;
    if (fontSize.equalsIgnoreCase("small")) {
      articleTitle.setTextSize(getResources().getDimension(R.dimen.tile_text_small) / density);
      imageSize = getResources().getDimension(R.dimen.image_size_small);
    } else if (fontSize.equalsIgnoreCase("medium")) {
      articleTitle.setTextSize(getResources().getDimension(R.dimen.tile_text_medium) / density);
      imageSize = getResources().getDimension(R.dimen.image_size_medium);
    } else if (fontSize.equalsIgnoreCase("large")) {
      articleTitle.setTextSize(getResources().getDimension(R.dimen.tile_text_large) / density);
      imageSize = getResources().getDimension(R.dimen.image_size_large);
    }
    thumbnailImageView.setLayoutParams(
        new RelativeLayout.LayoutParams((int) imageSize, (int) imageSize));

    articleView.setOnClickListener(this);
    articleView.setTag(article);

    rubricLayout = (LinearLayout) rubricsViews.get(rubricId).findViewById(R.id.rubric_layout);

    rubricLayout.addView(articleView, articlePosition);
  }