From 3dba8822f8d8ed3b5cbdbbc01726a0fa9b466850 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Tue, 3 Mar 2015 18:00:40 -0500 Subject: [PATCH] Revert "Can understand DublinCore publication date in RSS feed" --- .../core/syndication/handler/SyndHandler.java | 24 +++--------- .../syndication/namespace/NSDublinCore.java | 37 ------------------- .../core/syndication/util/SyndDateUtils.java | 27 -------------- 3 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/SyndHandler.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/SyndHandler.java index 47503dee4..1dda24944 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/SyndHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/handler/SyndHandler.java @@ -1,23 +1,14 @@ package de.danoeh.antennapod.core.syndication.handler; import android.util.Log; - +import de.danoeh.antennapod.core.BuildConfig; +import de.danoeh.antennapod.core.feed.Feed; +import de.danoeh.antennapod.core.syndication.namespace.*; +import de.danoeh.antennapod.core.syndication.namespace.atom.NSAtom; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.core.feed.Feed; -import de.danoeh.antennapod.core.syndication.namespace.NSContent; -import de.danoeh.antennapod.core.syndication.namespace.NSDublinCore; -import de.danoeh.antennapod.core.syndication.namespace.NSITunes; -import de.danoeh.antennapod.core.syndication.namespace.NSMedia; -import de.danoeh.antennapod.core.syndication.namespace.NSRSS20; -import de.danoeh.antennapod.core.syndication.namespace.NSSimpleChapters; -import de.danoeh.antennapod.core.syndication.namespace.Namespace; -import de.danoeh.antennapod.core.syndication.namespace.SyndElement; -import de.danoeh.antennapod.core.syndication.namespace.atom.NSAtom; - /** Superclass for all SAX Handlers which process Syndication formats */ public class SyndHandler extends DefaultHandler { private static final String TAG = "SyndHandler"; @@ -109,12 +100,7 @@ public class SyndHandler extends DefaultHandler { state.namespaces.put(uri, new NSMedia()); if (BuildConfig.DEBUG) Log.d(TAG, "Recognized media namespace"); - } else if (uri.equals(NSDublinCore.NSURI) - && prefix.equals(NSDublinCore.NSTAG)) { - state.namespaces.put(uri, new NSDublinCore()); - if (BuildConfig.DEBUG) - Log.d(TAG, "Recognized DublinCore namespace"); - } + } } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java deleted file mode 100644 index 099593eed..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/NSDublinCore.java +++ /dev/null @@ -1,37 +0,0 @@ -package de.danoeh.antennapod.core.syndication.namespace; - -import org.xml.sax.Attributes; - -import de.danoeh.antennapod.core.syndication.handler.HandlerState; -import de.danoeh.antennapod.core.syndication.util.SyndDateUtils; - -public class NSDublinCore extends Namespace { - private static final String TAG = "NSDublinCore"; - public static final String NSTAG = "dc"; - public static final String NSURI = "http://purl.org/dc/elements/1.1/"; - - private static final String ITEM = "item"; - private static final String DATE = "date"; - - @Override - public SyndElement handleElementStart(String localName, HandlerState state, - Attributes attributes) { - return new SyndElement(localName, this); - } - - @Override - public void handleElementEnd(String localName, HandlerState state) { - if(state.getTagstack().size() >= 2 - && state.getContentBuf() != null) { - String content = state.getContentBuf().toString(); - SyndElement topElement = state.getTagstack().peek(); - String top = topElement.getName(); - SyndElement secondElement = state.getSecondTag(); - String second = secondElement.getName(); - if (top.equals(DATE) && second.equals(ITEM)) { - state.getCurrentItem().setPubDate( - SyndDateUtils.parseISO8601Date(content)); - } - } - } -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndDateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndDateUtils.java index a9929d7b1..1ac389f08 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndDateUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndDateUtils.java @@ -28,8 +28,6 @@ public class SyndDateUtils { */ public static final String RFC3339LOCAL = "yyyy-MM-dd'T'HH:mm:ssZ"; - public static final String ISO8601_SHORT = "yyyy-MM-dd"; - private static ThreadLocal RFC822Formatter = new ThreadLocal() { @Override protected SimpleDateFormat initialValue() { @@ -46,14 +44,6 @@ public class SyndDateUtils { }; - private static ThreadLocal ISO8601ShortFormatter = new ThreadLocal() { - @Override - protected SimpleDateFormat initialValue() { - return new SimpleDateFormat(ISO8601_SHORT, Locale.US); - } - - }; - public static Date parseRFC822Date(String date) { Date result = null; if (date.contains("PDT")) { @@ -133,23 +123,6 @@ public class SyndDateUtils { } - public static Date parseISO8601Date(String date) { - if(date.length() > ISO8601_SHORT.length()) { - return parseRFC3339Date(date); - } - Date result = null; - if(date.length() == "YYYYMMDD".length()) { - date = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6,8); - } - SimpleDateFormat format = ISO8601ShortFormatter.get(); - try { - result = format.parse(date); - } catch (ParseException e) { - e.printStackTrace(); - } - return result; - } - /** * Takes a string of the form [HH:]MM:SS[.mmm] and converts it to * milliseconds.