package de.metalmatze.krautreporter.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.List;

import de.metalmatze.krautreporter.R;
import de.metalmatze.krautreporter.adapters.ArticlesAdapter;
import de.metalmatze.krautreporter.models.ArticleModel;
import de.metalmatze.krautreporter.services.ArticleService;

public class MainActivity extends ActionBarActivity implements ArticlesAdapter.OnItemClickListener {

    protected RecyclerView recyclerView;
    protected ArticlesAdapter recyclerViewAdapter;
    protected ArticleService articleService;

    private List<ArticleModel> articles;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.articleService = new ArticleService(getApplicationContext());

        this.setContentView(R.layout.activity_main);

        this.recyclerView = (RecyclerView) findViewById(R.id.recyclerView);

        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        layoutManager.scrollToPosition(0);
        this.recyclerView.setLayoutManager(layoutManager);

        this.articleService.update();
        this.articles = this.articleService.all();

        this.recyclerViewAdapter = new ArticlesAdapter(getApplicationContext(), this, this.articles);
        this.recyclerView.setAdapter(this.recyclerViewAdapter);
    }

    @Override
    public void onItemClick(ArticleModel articleModel) {
        Intent intent = new Intent(this, ArticleActivity.class);
        intent.putExtra("id", articleModel.getId());

        this.startActivity(intent);
    }
}

@@ -1241,51 +1241,8 @@
 L);%0A
-        layoutManager.scrollToPosition(0);%0A
     
@@ -1396,36 +1396,434 @@
        this.
-recyclerView
+setArticles(this.articles);%0A    %7D%0A%0A    @Override%0A    protected void onResume() %7B%0A        super.onResume();%0A%0A        List%3CArticleModel%3E articles = this.articleService.all();%0A%0A        if (this.articles.size() %3C articles.size()) %7B%0A            this.setArticles(articles);%0A        %7D%0A    %7D%0A%0A    public void setArticles(List%3CArticleModel%3E articles) %7B%0A        this.articles = articles;%0A        ArticlesAdapter articles
 Adapter = ne
@@ -1924,33 +1924,24 @@
 Adapter(
-this.recyclerView
+articles
 Adapter)

Create setArticles() to overwrite adapter in MainActivity use onResume()