package com.shirwa.simplistic_rss;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.util.List;

/*
 * Copyright (C) 2014 Shirwa Mohamed <shirwa99@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class RssReader {
    private String rssUrl;

    public RssReader(String url) {
        rssUrl = url;
    }

    public List<RssItem> getItems() throws Exception {
        SAXParserFactory factory = SAXParserFactory.newInstance();
        SAXParser saxParser = factory.newSAXParser();
        //Creates a new RssHandler which will do all the parsing.
        RssHandler handler = new RssHandler();
        //Pass SaxParser the RssHandler that was created.
        saxParser.parse(rssUrl, handler);
        return handler.getRssItemList();
    }
}

@@ -29,16 +29,243 @@
 c_rss;%0A%0A
+import android.net.http.AndroidHttpClient;%0Aimport android.util.Log;%0A%0Aimport org.apache.http.client.methods.HttpGet;%0Aimport org.apache.http.client.methods.HttpUriRequest;%0Aimport org.xml.sax.InputSource;%0A%0Aimport java.util.List;%0A%0A
 import j
@@ -334,39 +334,16 @@
 Factory;
-%0Aimport java.util.List;
 %0A%0A/*%0A * 
@@ -1049,16 +1049,114 @@
  url) %7B%0A
+        if (!url.startsWith(%22http%22)) %7B%0A            rssUrl = %22http://%22 + url;%0A        %7D else %7B%0A    
         
@@ -1165,24 +1165,34 @@
 sUrl = url;%0A
+        %7D%0A
     %7D%0A%0A    p
@@ -1471,24 +1471,415 @@
 sHandler();%0A
+        //Need to take care of gzip encoded content ourselves%0A        HttpUriRequest request = new HttpGet(rssUrl);%0A        AndroidHttpClient.modifyRequestToAcceptGzipResponse(request);%0A        AndroidHttpClient client = AndroidHttpClient.newInstance(%22%22);%0A        InputSource is = new InputSource(AndroidHttpClient%0A                .getUngzippedContent(client.execute(request).getEntity()));%0A
         //Pa
@@ -1895,20 +1895,33 @@
 ser the 
-RssH
+inputsource and h
 andler t
@@ -1961,22 +1961,18 @@
 r.parse(
-rssUrl
+is
 , handle
@@ -1987,39 +1987,161 @@
     
-return handler.getRssItemList()
+//Parse the stream%0A        List%3CRssItem%3E items = handler.getRssItemList();%0A        // Close http client last%0A        client.close();%0A        return items
 ;%0A  

Handle gzip responses