diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java index 53b7f963a..a90ad157e 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -16,9 +16,9 @@ import de.danoeh.antennapod.core.storage.DBTasks; // Since the intent doesn't have the EXTRA_STATUS like the android.com article says it does // (though it used to) public class PowerConnectionReceiver extends BroadcastReceiver { - private static final String TAG = "PowerConnectionReceiver"; + private static final String TAG = "PowerConnectionReceiver"; - @Override + @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 8e82dd5e2..95203de5a 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -11,6 +11,10 @@ + + + + diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlElement.java b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlElement.java index 61eb4d0c9..e4ba08440 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlElement.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlElement.java @@ -1,46 +1,48 @@ package de.danoeh.antennapod.core.export.opml; -/** Represents a single feed in an OPML file. */ +/** + * Represents a single feed in an OPML file. + */ public class OpmlElement { - private String text; - private String xmlUrl; - private String htmlUrl; - private String type; + private String text; + private String xmlUrl; + private String htmlUrl; + private String type; - public OpmlElement() { + public OpmlElement() { - } + } - public String getText() { - return text; - } + public String getText() { + return text; + } - public void setText(String text) { - this.text = text; - } + public void setText(String text) { + this.text = text; + } - public String getXmlUrl() { - return xmlUrl; - } + public String getXmlUrl() { + return xmlUrl; + } - public void setXmlUrl(String xmlUrl) { - this.xmlUrl = xmlUrl; - } + public void setXmlUrl(String xmlUrl) { + this.xmlUrl = xmlUrl; + } - public String getHtmlUrl() { - return htmlUrl; - } + public String getHtmlUrl() { + return htmlUrl; + } - public void setHtmlUrl(String htmlUrl) { - this.htmlUrl = htmlUrl; - } + public void setHtmlUrl(String htmlUrl) { + this.htmlUrl = htmlUrl; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlReader.java b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlReader.java index a17fedd7d..9bcca5caf 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlReader.java @@ -12,78 +12,81 @@ import java.util.ArrayList; import de.danoeh.antennapod.core.BuildConfig; -/** Reads OPML documents. */ +/** + * Reads OPML documents. + */ public class OpmlReader { - private static final String TAG = "OpmlReader"; - - // ATTRIBUTES - private boolean isInOpml = false; - private ArrayList elementList; + private static final String TAG = "OpmlReader"; - /** - * Reads an Opml document and returns a list of all OPML elements it can - * find - * - * @throws IOException - * @throws XmlPullParserException - */ - public ArrayList readDocument(Reader reader) - throws XmlPullParserException, IOException { - elementList = new ArrayList<>(); - XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); - factory.setNamespaceAware(true); - XmlPullParser xpp = factory.newPullParser(); - xpp.setInput(reader); - int eventType = xpp.getEventType(); + private boolean isInOpml = false; - while (eventType != XmlPullParser.END_DOCUMENT) { - switch (eventType) { - case XmlPullParser.START_DOCUMENT: - if (BuildConfig.DEBUG) - Log.d(TAG, "Reached beginning of document"); - break; - case XmlPullParser.START_TAG: - if (xpp.getName().equals(OpmlSymbols.OPML)) { - isInOpml = true; - if (BuildConfig.DEBUG) - Log.d(TAG, "Reached beginning of OPML tree."); - } else if (isInOpml && xpp.getName().equals(OpmlSymbols.OUTLINE)) { - if (BuildConfig.DEBUG) - Log.d(TAG, "Found new Opml element"); - OpmlElement element = new OpmlElement(); - - final String title = xpp.getAttributeValue(null, OpmlSymbols.TITLE); - if (title != null) { - Log.i(TAG, "Using title: " + title); - element.setText(title); - } else { - Log.i(TAG, "Title not found, using text"); - element.setText(xpp.getAttributeValue(null, OpmlSymbols.TEXT)); - } - element.setXmlUrl(xpp.getAttributeValue(null, OpmlSymbols.XMLURL)); - element.setHtmlUrl(xpp.getAttributeValue(null, OpmlSymbols.HTMLURL)); - element.setType(xpp.getAttributeValue(null, OpmlSymbols.TYPE)); - if (element.getXmlUrl() != null) { - if (element.getText() == null) { - Log.i(TAG, "Opml element has no text attribute."); - element.setText(element.getXmlUrl()); - } - elementList.add(element); - } else { - if (BuildConfig.DEBUG) - Log.d(TAG, - "Skipping element because of missing xml url"); - } - } - break; - } - eventType = xpp.next(); - } + /** + * Reads an Opml document and returns a list of all OPML elements it can + * find + */ + public ArrayList readDocument(Reader reader) + throws XmlPullParserException, IOException { + ArrayList elementList = new ArrayList<>(); + XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); + factory.setNamespaceAware(true); + XmlPullParser xpp = factory.newPullParser(); + xpp.setInput(reader); + int eventType = xpp.getEventType(); - if (BuildConfig.DEBUG) - Log.d(TAG, "Parsing finished."); + while (eventType != XmlPullParser.END_DOCUMENT) { + switch (eventType) { + case XmlPullParser.START_DOCUMENT: + if (BuildConfig.DEBUG) { + Log.d(TAG, "Reached beginning of document"); + } + break; + case XmlPullParser.START_TAG: + if (xpp.getName().equals(OpmlSymbols.OPML)) { + isInOpml = true; + if (BuildConfig.DEBUG) { + Log.d(TAG, "Reached beginning of OPML tree."); + } + } else if (isInOpml && xpp.getName().equals(OpmlSymbols.OUTLINE)) { + if (BuildConfig.DEBUG) { + Log.d(TAG, "Found new Opml element"); + } + OpmlElement element = new OpmlElement(); - return elementList; - } + final String title = xpp.getAttributeValue(null, OpmlSymbols.TITLE); + if (title != null) { + Log.i(TAG, "Using title: " + title); + element.setText(title); + } else { + Log.i(TAG, "Title not found, using text"); + element.setText(xpp.getAttributeValue(null, OpmlSymbols.TEXT)); + } + element.setXmlUrl(xpp.getAttributeValue(null, OpmlSymbols.XMLURL)); + element.setHtmlUrl(xpp.getAttributeValue(null, OpmlSymbols.HTMLURL)); + element.setType(xpp.getAttributeValue(null, OpmlSymbols.TYPE)); + if (element.getXmlUrl() != null) { + if (element.getText() == null) { + Log.i(TAG, "Opml element has no text attribute."); + element.setText(element.getXmlUrl()); + } + elementList.add(element); + } else { + if (BuildConfig.DEBUG) { + Log.d(TAG, "Skipping element because of missing xml url"); + } + } + } + break; + default: + break; + } + eventType = xpp.next(); + } + + if (BuildConfig.DEBUG) { + Log.d(TAG, "Parsing finished."); + } + + return elementList; + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlSymbols.java b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlSymbols.java index 86091720d..0cdfd0d87 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlSymbols.java +++ b/core/src/main/java/de/danoeh/antennapod/core/export/opml/OpmlSymbols.java @@ -2,20 +2,22 @@ package de.danoeh.antennapod.core.export.opml; import de.danoeh.antennapod.core.export.CommonSymbols; -/** Contains symbols for reading and writing OPML documents. */ +/** + * Contains symbols for reading and writing OPML documents. + */ final class OpmlSymbols extends CommonSymbols { - - public static final String OPML = "opml"; - static final String OUTLINE = "outline"; - static final String TEXT = "text"; - static final String XMLURL = "xmlUrl"; - static final String HTMLURL = "htmlUrl"; - static final String TYPE = "type"; - static final String VERSION = "version"; - static final String DATE_CREATED = "dateCreated"; - - private OpmlSymbols() { - - } + + public static final String OPML = "opml"; + static final String OUTLINE = "outline"; + static final String TEXT = "text"; + static final String XMLURL = "xmlUrl"; + static final String HTMLURL = "htmlUrl"; + static final String TYPE = "type"; + static final String VERSION = "version"; + static final String DATE_CREATED = "dateCreated"; + + private OpmlSymbols() { + + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/ChapterStartTimeComparator.java b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/ChapterStartTimeComparator.java index e36f8d0a1..0f75d1237 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/ChapterStartTimeComparator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/ChapterStartTimeComparator.java @@ -6,9 +6,9 @@ import de.danoeh.antennapod.model.feed.Chapter; public class ChapterStartTimeComparator implements Comparator { - @Override - public int compare(Chapter lhs, Chapter rhs) { - return Long.compare(lhs.getStart(), rhs.getStart()); - } + @Override + public int compare(Chapter lhs, Chapter rhs) { + return Long.compare(lhs.getStart(), rhs.getStart()); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/PlaybackCompletionDateComparator.java b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/PlaybackCompletionDateComparator.java index b1e62bcf1..26c3a74c4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/PlaybackCompletionDateComparator.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/PlaybackCompletionDateComparator.java @@ -5,15 +5,15 @@ import java.util.Comparator; import de.danoeh.antennapod.model.feed.FeedItem; public class PlaybackCompletionDateComparator implements Comparator { - - public int compare(FeedItem lhs, FeedItem rhs) { - if (lhs.getMedia() != null - && lhs.getMedia().getPlaybackCompletionDate() != null - && rhs.getMedia() != null - && rhs.getMedia().getPlaybackCompletionDate() != null) { - return rhs.getMedia().getPlaybackCompletionDate() - .compareTo(lhs.getMedia().getPlaybackCompletionDate()); - } - return 0; - } + + public int compare(FeedItem lhs, FeedItem rhs) { + if (lhs.getMedia() != null + && lhs.getMedia().getPlaybackCompletionDate() != null + && rhs.getMedia() != null + && rhs.getMedia().getPlaybackCompletionDate() != null) { + return rhs.getMedia().getPlaybackCompletionDate() + .compareTo(lhs.getMedia().getPlaybackCompletionDate()); + } + return 0; + } }