package de.metalmatze.krautreporter.adapters;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

import de.metalmatze.krautreporter.R;
import de.metalmatze.krautreporter.entities.Article;
import de.metalmatze.krautreporter.viewholders.ArticleViewHolder;

public class ArticleRecyclerViewAdapter extends RecyclerView.Adapter<ArticleViewHolder> {

    private List<Article> articles;

    public ArticleRecyclerViewAdapter(List<Article> articles) {
        this.articles = articles;
    }

    @Override
    public ArticleViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        View itemView = LayoutInflater
                        .from(viewGroup.getContext())
                        .inflate(R.layout.article_list, viewGroup, false);

        return new ArticleViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(ArticleViewHolder articleViewHolder, int position) {
        Article article = this.articles.get(position);

        articleViewHolder.article_date.setText(article.getDate());
        articleViewHolder.article_headline.setText(article.getHeadline());
    }

    @Override
    public int getItemCount() {
        return this.articles.size();
    }
}

@@ -181,16 +181,51 @@
 Group;%0A%0A
+import java.text.SimpleDateFormat;%0A
 import j
@@ -1106,24 +1106,125 @@
 position);%0A%0A
+        String articleDate = new SimpleDateFormat(%22dd.MM.yyyy%22).format(article.getDate().getTime());%0A
         arti
@@ -1265,26 +1265,20 @@
 (article
-.get
 Date
-()
 );%0A     
@@ -1338,15 +1338,12 @@
 .get
-Headlin
+Titl
 e())

Format date of article in ArticleRecyclerViewAdapter