Beispiel #1
0
 private FeedItem getFeedItem() {
   Bundle bundle = getIntent().getExtras();
   FeedItem feedItem = new FeedItem();
   feedItem.setItemTitle(bundle.getString("title", ""));
   feedItem.setItemCategory(bundle.getString("category", ""));
   feedItem.setItemDesc(bundle.getString("description", ""));
   feedItem.setItemImgUrl(bundle.getString("img_url", ""));
   feedItem.setItemCategoryImgId(bundle.getInt("image_id", 0));
   feedItem.setItemLink(bundle.getString("link", ""));
   feedItem.setItemPubDate(bundle.getString("pub_date", ""));
   feedItem.setItemSource(bundle.getString("source", ""));
   feedItem.setItemSourceUrl(bundle.getString("source_url", ""));
   feedItem.setItemWebDesc(bundle.getString("article_content", ""));
   feedItem.setItemWebDescSync(bundle.getString("sync_desc", ""));
   return feedItem;
 }
Beispiel #2
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());
      }*/
  }
Beispiel #3
0
 private void setToolbar(FeedItem feedItem) {
   toolbar.setTitle(feedItem.getItemSource());
   setSupportActionBar(toolbar);
   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 }