Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set theme
    setSystemTheme(getFeedThemeBgId());

    setContentView(R.layout.activity_article);

    ButterKnife.bind(this);

    // get Feed item from intent bundle
    FeedItem feedItem = getFeedItem();

    // set toolbar
    setToolbar(feedItem);

    // set default font sizes
    setFontSize();

    // set feed title
    txtFeedTitle.setText(feedItem.getItemTitle());

    // set feed category
    txtFeedCategory.setText(feedItem.getItemCategory());

    // set feed publish date
    txtFeedPubDate.setText(feedItem.getItemPubDate());

    // set feed image
    Glide.with(ArticleActivity.this)
        .load(feedItem.getItemImgUrl())
        .centerCrop()
        .crossFade()
        .into(imgArticle);

    // load article presenter
    if (mArticlePresenter == null) {
      mArticlePresenter = new ArticlePresenter(ArticleActivity.this, this);
    }

    // load feeds presenter
    if (mFeedsPresenter == null) {
      mFeedsPresenter = new FeedsPresenter(ArticleActivity.this, this);
    }

    // only load the data online if this activity was opened from FeedsFragment
    // , else if it was redirected from ArchiveFragment then load the saved article
    if (feedItem.getItemWebDesc().isEmpty()) {
      mSaved = false;
      if (NetworkConnectionUtil.isNetworkAvailable(ArticleActivity.this)) {
        mArticlePresenter.attemptArticleLoading(feedItem.getItemLink());
      } else {
        NetworkConnectionUtil.showNoNetworkDialog(ArticleActivity.this);
      }
    } else {
      mSaved = true;
      fabArchive.setImageResource(R.drawable.ic_archive_done_24dp);
      txtContent.setText(feedItem.getItemWebDesc());
    } /* else if(!feedItem.getItemWebDescSync().isEmpty()){
          txtContent.setText(feedItem.getItemWebDescSync());
      }*/
  }