package de.metalmatze.krautreporter.activities;

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

import com.newrelic.agent.android.NewRelic;

import org.xmlpull.v1.XmlPullParserException;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;

import de.metalmatze.krautreporter.KrautreporterRssParser;
import de.metalmatze.krautreporter.R;
import de.metalmatze.krautreporter.adapters.ArticleRecyclerViewAdapter;
import de.metalmatze.krautreporter.entities.Article;

public class MainActivity extends ActionBarActivity {

    protected RecyclerView recyclerView;
    protected ArticleRecyclerViewAdapter recyclerViewAdapter;

    private ArrayList<Article> articles;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        NewRelic.withApplicationToken("AAcd87d4b9197cb6e3184ac6d5b78f1f1d42488de6").start(this.getApplication());

        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);

        try {

            BufferedInputStream inputStream = new BufferedInputStream(getAssets().open("krautreporter.rss"));
            this.articles = new KrautreporterRssParser().parse(inputStream);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }

        this.recyclerViewAdapter = new ArticleRecyclerViewAdapter(this.articles);
        this.recyclerView.setAdapter(this.recyclerViewAdapter);
    }

}

@@ -222,51 +222,71 @@
 ew;%0A
-%0A
 import 
-com.newrelic.agent.android.NewRelic
+android.util.Log;%0A%0Aimport com.activeandroid.query.Select
 ;%0A%0Ai
@@ -412,21 +412,16 @@
 va.util.
-Array
 List;%0A%0Ai
@@ -627,15 +627,13 @@
 ter.
-entitie
+model
 s.Ar
@@ -637,16 +637,21 @@
 .Article
+Model
 ;%0A%0Apubli
@@ -820,13 +820,8 @@
 ate 
-Array
 List
@@ -828,16 +828,21 @@
 %3CArticle
+Model
 %3E articl
@@ -961,16 +961,18 @@
 State);%0A
+//
         
@@ -1451,24 +1451,185 @@
 tManager);%0A%0A
+        int count = new Select().from(ArticleModel.class).count();%0A%0A        Log.d(%22article count%22, String.valueOf(count));%0A%0A        if (count %3C 1)%0A        %7B%0A    
         try 
@@ -1643,16 +1643,20 @@
         
+  
+  
 Buffered
@@ -1753,24 +1753,28 @@
             
+    
 this.article
@@ -1823,24 +1823,169 @@
 utStream);%0A%0A
+                for (ArticleModel articleModel: this.articles)%0A                %7B%0A                    articleModel.save();%0A                %7D%0A%0A    
         %7D ca
@@ -2010,32 +2010,36 @@
 ) %7B%0A            
+    
 e.printStackTrac
@@ -2043,32 +2043,36 @@
 race();%0A        
+  
+  
 %7D catch (XmlPull
@@ -2084,32 +2084,36 @@
 rException e) %7B%0A
+    
             e.pr
@@ -2121,32 +2121,140 @@
 ntStackTrace();%0A
+            %7D%0A        %7D else %7B%0A            this.articles = new Select().from(ArticleModel.class).execute();%0A
         %7D%0A%0A     

Use ArticleModel in MainActivity