Esempio n. 1
0
  @Override
  public void onClick(View v) {
    Intent viewArticle = new Intent();
    viewArticle.setClass(this, ArticleViewActivity.class);
    RssArticle article = (RssArticle) v.getTag();
    viewArticle.putExtra("RUBRIC_ID", article.getRubricId());
    viewArticle.putExtra("ID", article.getId());

    startActivity(viewArticle);
  }
Esempio n. 2
0
  private void refreshImages() {
    Bitmap thumbnailBitmap;
    RssArticle article;
    for (View articleView : listArticlesViews) {
      ImageView thumbnailImageView = (ImageView) articleView.findViewById(R.id.article_image);
      article = (RssArticle) articleView.getTag();

      Boolean tag = (Boolean) thumbnailImageView.getTag(R.bool.image_empty);
      if (tag != null && tag == true) {
        thumbnailBitmap = ThumbnailCache.getInstance().getBitmap(article.getEnclosure());
        if (thumbnailBitmap != null) {
          thumbnailImageView.setImageBitmap(thumbnailBitmap);
        } else {
          ThumbnailCache.getInstance().load(thumbnailImageView, article.getEnclosure());
        }
      }
    }
  }
Esempio n. 3
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);
  }