package edu.yalestc.yalepublic.news;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import org.xml.sax.SAXException;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import edu.yalestc.yalepublic.R;
import edu.yalestc.yalepublic.news.RssReader;
import edu.yalestc.yalepublic.news.RssFeed;

/**
 * Created by Jason Liu on 10/4/14.
 */

public class NewsReader extends Activity {

    TextView tRSSTitle, tRSSContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.news_items);
        tRSSTitle = (TextView) findViewById(R.id.tvRSSTitle);
        tRSSContent = (TextView) findViewById(R.id.tvRSSContent);

        URL url = null;
        try {
            url = new URL("http://news.yale.edu/news-rss");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        RssFeed feed = null;
        try {
            feed = RssReader.read(url);
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        ArrayList<RssItem> rssItems = feed.getRssItems();
        for(RssItem rssItem : rssItems) {
            Log.d("RSS Reader", rssItem.getTitle());
        }
    }
}

@@ -79,42 +79,153 @@
 oid.
-os.Bundle;%0Aimport android.util.Log
+content.Intent;%0Aimport android.net.Uri;%0Aimport android.os.Bundle;%0Aimport android.util.Log;%0Aimport android.view.View;%0Aimport android.widget.Button
 ;%0Aim
@@ -945,25 +945,24 @@
 ntent);%0A
-%0A
         
 URL url 
@@ -957,582 +957,143 @@
     
-URL url = null;%0A        try %7B%0A            url = new URL(%22http://news.yale.edu/news-rss%22);%0A        %7D catch (MalformedURLException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        RssFeed feed = null;%0A        try %7B%0A            feed = RssReader.read(url);%0A        %7D catch (SAXException e) %7B%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        ArrayList%3CRssItem%3E rssItems = feed.getRssItems();%0A        for(RssItem rssItem : rssItems) %7B%0A            Log.d(%22RSS Reader%22, rssItem.getTitl
+%0A        // TODO: Check for Internet Connectivity first%0A        NewsDownload start = new NewsDownload();%0A        start.execut
 e()
-)
 ;%0A    
- 
-   %7D%0A    
 %7D
+%0A
 %0A%7D%0A

Move download out of main thread (not allowed)