Search in sources :

Example 1 with Article

use of com.israelferrer.effectiveandroid.entities.Article in project EffectiveAndroid by rallat.

the class TopArticleListModelImpl method processTweets.

@NonNull
private List<Article> processTweets(Result<List<Tweet>> result) {
    final List<Article> items = new ArrayList<>();
    for (Tweet tweet : result.data) {
        if (tweet.entities != null && tweet.entities.urls != null && tweet.entities.urls.size() > 0 && isEligibleDomain(tweet.entities.urls)) {
            items.add(Article.create(tweet));
        }
    }
    Collections.sort(items);
    return items;
}
Also used : Tweet(com.twitter.sdk.android.core.models.Tweet) Article(com.israelferrer.effectiveandroid.entities.Article) ArrayList(java.util.ArrayList) NonNull(android.support.annotation.NonNull)

Example 2 with Article

use of com.israelferrer.effectiveandroid.entities.Article in project EffectiveAndroid by rallat.

the class ArticleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras();
    Article article = extras.getParcelable(EXTRA_ARTICLE);
    setContentView(R.layout.activity_article);
    ButterKnife.bind(this);
    View innerContainer = cardView.findViewById(R.id.container_inner_item);
    ViewCompat.setTransitionName(innerContainer, TRANSITION_SHARED_ELEMENT);
    if (article != null) {
        titleView.setText(article.getTitle());
        retweetView.setText(article.getRetweetCount());
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl(article.getUrl());
    } else {
        finish();
    }
}
Also used : Bundle(android.os.Bundle) Article(com.israelferrer.effectiveandroid.entities.Article) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) View(android.view.View) WebView(android.webkit.WebView) WebViewClient(android.webkit.WebViewClient)

Example 3 with Article

use of com.israelferrer.effectiveandroid.entities.Article in project EffectiveAndroid by rallat.

the class TopArticleListActivity method onClick.

private void onClick(View view) {
    int position = recyclerView.getChildLayoutPosition(view);
    Article data = adapter.getItem(position);
    View innerContainer = view.findViewById(R.id.container_inner_item);
    Intent startIntent = new Intent(this, ArticleActivity.class);
    startIntent.putExtra(ArticleActivity.EXTRA_ARTICLE, data);
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, innerContainer, ArticleActivity.TRANSITION_SHARED_ELEMENT);
    ActivityCompat.startActivity(this, startIntent, options.toBundle());
}
Also used : Article(com.israelferrer.effectiveandroid.entities.Article) Intent(android.content.Intent) View(android.view.View) TopArticleListView(com.israelferrer.effectiveandroid.ui.views.TopArticleListView) ArticleRecyclerView(com.israelferrer.effectiveandroid.ui.recycler.ArticleRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Example 4 with Article

use of com.israelferrer.effectiveandroid.entities.Article in project EffectiveAndroid by rallat.

the class ArticleRecyclerView method onBindViewHolder.

@Override
public void onBindViewHolder(ArticleViewHolder holder, int position) {
    final Article article = items.get(position);
    holder.title.setText(article.getTitle());
    holder.retweet.setText(article.getRetweetCount());
    if (!TextUtils.isEmpty(article.getMediaUrl())) {
        holder.media.setVisibility(View.VISIBLE);
        Picasso.with(holder.media.getContext()).load(article.getMediaUrl()).into(holder.media);
    } else {
        holder.media.setVisibility(View.GONE);
    }
}
Also used : Article(com.israelferrer.effectiveandroid.entities.Article)

Aggregations

Article (com.israelferrer.effectiveandroid.entities.Article)4 View (android.view.View)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)1 CardView (android.support.v7.widget.CardView)1 RecyclerView (android.support.v7.widget.RecyclerView)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 TextView (android.widget.TextView)1 ArticleRecyclerView (com.israelferrer.effectiveandroid.ui.recycler.ArticleRecyclerView)1 TopArticleListView (com.israelferrer.effectiveandroid.ui.views.TopArticleListView)1 Tweet (com.twitter.sdk.android.core.models.Tweet)1 ArrayList (java.util.ArrayList)1