diff options
author | ByteHamster <info@bytehamster.com> | 2020-03-25 22:45:14 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-03-25 22:50:41 +0100 |
commit | 902215c18d7afa29a0207ca7600770f583a6c0df (patch) | |
tree | f4952efc61a18f1cc1dda18560ea7de71c8b474a /core | |
parent | 3399be1290592eff1b6ad5dd1a9b7807f7e7fcaa (diff) | |
download | AntennaPod-902215c18d7afa29a0207ca7600770f583a6c0df.zip |
Removed unused code
Diffstat (limited to 'core')
17 files changed, 46 insertions, 321 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java index e56445489..dbaece14a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/DownloadServiceCallbacks.java @@ -3,11 +3,10 @@ package de.danoeh.antennapod.core; import android.app.PendingIntent; import android.content.Context; -import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.service.download.DownloadRequest; /** - * Callbacks for the DownloadService of the core module + * Callbacks for the DownloadService of the core module. */ public interface DownloadServiceCallbacks { @@ -43,13 +42,6 @@ public interface DownloadServiceCallbacks { PendingIntent getReportNotificationContentIntent(Context context); /** - * Called by the FeedSyncThread after a feed has been downloaded and parsed. - * - * @param feed The non-null feed that has been parsed. - */ - void onFeedParsed(Context context, Feed feed); - - /** * Returns true if the DownloadService should create a report that shows the number of failed * downloads when the service shuts down. * */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java b/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java index 13a32ab8a..194ee65ae 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/PlaybackServiceCallbacks.java @@ -26,9 +26,4 @@ public interface PlaybackServiceCallbacks { * finishes. */ boolean useQueue(); - - /** - * Returns a drawable resource that is used for the notification of the playback service. - */ - int getNotificationIconResource(Context context); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/event/QueueEvent.java b/core/src/main/java/de/danoeh/antennapod/core/event/QueueEvent.java index 209dcba4d..f9a8c63b6 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/event/QueueEvent.java +++ b/core/src/main/java/de/danoeh/antennapod/core/event/QueueEvent.java @@ -59,18 +59,6 @@ public class QueueEvent { return new QueueEvent(Action.MOVED, item, null, newPosition); } - public boolean contains(long id) { - if(item != null) { - return item.getId() == id; - } - for(FeedItem item : items) { - if(item.getId() == id) { - return true; - } - } - return false; - } - @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java index b1598f111..0889e5182 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/Feed.java @@ -225,14 +225,6 @@ public class Feed extends FeedFile implements ImageResource { } /** - * Returns the number of FeedItems. - * - */ - public int getNumOfItems() { - return items.size(); - } - - /** * Returns the item at the specified index. * */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java index 572f32e66..80b205c0f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedMedia.java @@ -221,16 +221,6 @@ public class FeedMedia extends FeedFile implements Playable { ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING)); } - /** - * Reads playback preferences to determine whether this FeedMedia object is - * currently being played and the current player status is paused. - */ - public boolean isCurrentlyPaused() { - return isPlaying() && - ((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PAUSED)); - } - - public boolean hasAlmostEnded() { int smartMarkAsPlayedSecs = UserPreferences.getSmartMarkAsPlayedSecs(); return this.position >= this.duration - smartMarkAsPlayedSecs * 1000; diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java index 718faaa0a..8be3d2980 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedSyncTask.java @@ -2,16 +2,13 @@ package de.danoeh.antennapod.core.service.download.handler; import android.content.Context; import android.util.Log; -import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.feed.Feed; import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadStatus; -import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.storage.DownloadRequestException; import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.syndication.handler.FeedHandlerResult; -import java.util.List; public class FeedSyncTask { private static final String TAG = "FeedParserTask"; @@ -46,8 +43,6 @@ public class FeedSyncTask { Log.e(TAG, "Error trying to load next page", e); } } - - ClientConfig.downloadServiceCallbacks.onFeedParsed(context, savedFeed); return true; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index e818f3072..d31f5d688 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -160,12 +160,12 @@ public final class DBReader { } /** - * Loads the list of FeedItems for a certain Feed-object. This method should NOT be used if the FeedItems are not - * used. In order to get information ABOUT the list of FeedItems, consider using {@link #getFeedStatisticsList()} instead. + * Loads the list of FeedItems for a certain Feed-object. + * This method should NOT be used if the FeedItems are not used. * * @param feed The Feed whose items should be loaded * @return A list with the FeedItems of the Feed. The Feed-attribute of the FeedItems will already be set correctly. - * The method does NOT change the items-attribute of the feed. + * The method does NOT change the items-attribute of the feed. */ public static List<FeedItem> getFeedItemList(final Feed feed) { Log.d(TAG, "getFeedItemList() called with: " + "feed = [" + feed + "]"); @@ -273,8 +273,7 @@ public final class DBReader { * Loads the IDs of the FeedItems in the queue. This method should be preferred over * {@link #getQueue()} if the FeedItems of the queue are not needed. * - * @return A list of IDs sorted by the same order as the queue. The caller can wrap the returned - * list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties. + * @return A list of IDs sorted by the same order as the queue. */ public static LongList getQueueIDList() { Log.d(TAG, "getQueueIDList() called"); @@ -307,8 +306,7 @@ public final class DBReader { * Loads a list of the FeedItems in the queue. If the FeedItems of the queue are not used directly, consider using * {@link #getQueueIDList()} instead. * - * @return A list of FeedItems sorted by the same order as the queue. The caller can wrap the returned - * list in a {@link de.danoeh.antennapod.core.util.QueueAccess} object for easier access to the queue's properties. + * @return A list of FeedItems sorted by the same order as the queue. */ @NonNull public static List<FeedItem> getQueue() { @@ -546,34 +544,6 @@ public final class DBReader { } /** - * Loads the FeedItemStatistics objects of all Feeds in the database. This method should be preferred over - * {@link #getFeedItemList(Feed)} if only metadata about - * the FeedItems is needed. - * - * @return A list of FeedItemStatistics objects sorted alphabetically by their Feed's title. - */ - public static List<FeedItemStatistics> getFeedStatisticsList() { - Log.d(TAG, "getFeedStatisticsList() called"); - PodDBAdapter adapter = PodDBAdapter.getInstance(); - adapter.open(); - Cursor cursor = null; - try { - cursor = adapter.getFeedStatisticsCursor(); - List<FeedItemStatistics> result = new ArrayList<>(cursor.getCount()); - while (cursor.moveToNext()) { - FeedItemStatistics fis = FeedItemStatistics.fromCursor(cursor); - result.add(fis); - } - return result; - } finally { - if (cursor != null) { - cursor.close(); - } - adapter.close(); - } - } - - /** * Loads a specific Feed from the database. * * @param feedId The ID of the Feed diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemStatistics.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemStatistics.java deleted file mode 100644 index d84279f6e..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedItemStatistics.java +++ /dev/null @@ -1,81 +0,0 @@ -package de.danoeh.antennapod.core.storage; - -import android.database.Cursor; - -import java.util.Date; - -/** - * Contains information about a feed's items. - */ -public class FeedItemStatistics { - private final long feedID; - private final int numberOfItems; - private final int numberOfNewItems; - private final int numberOfInProgressItems; - private final Date lastUpdate; - private static final Date UNKNOWN_DATE = new Date(0); - - - /** - * Creates new FeedItemStatistics object. - * - * @param feedID ID of the feed. - * @param numberOfItems Number of items that this feed has. - * @param numberOfNewItems Number of unread items this feed has. - * @param numberOfInProgressItems Number of items that the user has started listening to. - * @param lastUpdate pubDate of the latest episode. A lastUpdate value of 0 will be interpreted as DATE_UNKOWN if - * numberOfItems is 0. - */ - private FeedItemStatistics(long feedID, int numberOfItems, int numberOfNewItems, int numberOfInProgressItems, Date lastUpdate) { - this.feedID = feedID; - this.numberOfItems = numberOfItems; - this.numberOfNewItems = numberOfNewItems; - this.numberOfInProgressItems = numberOfInProgressItems; - if (numberOfItems > 0) { - this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null; - } else { - this.lastUpdate = UNKNOWN_DATE; - } - } - - public static FeedItemStatistics fromCursor(Cursor cursor) { - return new FeedItemStatistics( - cursor.getLong(0), - cursor.getInt(1), - cursor.getInt(2), - cursor.getInt(4), - new Date(cursor.getLong(3))); - } - - public long getFeedID() { - return feedID; - } - - public int getNumberOfItems() { - return numberOfItems; - } - - public int getNumberOfNewItems() { - return numberOfNewItems; - } - - public int getNumberOfInProgressItems() { - return numberOfInProgressItems; - } - - /** - * Returns the pubDate of the latest item in the feed. Users of this method - * should check if this value is unkown or not by calling lastUpdateKnown() first. - */ - public Date getLastUpdate() { - return (lastUpdate != null) ? (Date) lastUpdate.clone() : null; - } - - /** - * Returns true if the lastUpdate value is known. The lastUpdate value is unkown if the - * feed has no items. - */ - public boolean lastUpdateKnown() { - return lastUpdate != UNKNOWN_DATE; - } -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/AtomText.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/AtomText.java index 714b8d8a7..e85d5fae1 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/AtomText.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/namespace/atom/AtomText.java @@ -36,16 +36,7 @@ public class AtomText extends SyndElement { } } - public String getContent() { - return content; - } - public void setContent(String content) { this.content = content; } - - public String getType() { - return type; - } - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndTypeUtils.java b/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndTypeUtils.java index 1d564ab0e..6c151d39b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndTypeUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/syndication/util/SyndTypeUtils.java @@ -37,21 +37,6 @@ public class SyndTypeUtils { } } - - /** - * Should be used if mime-type of enclosure tag is not supported. This - * method will check if the mime-type of the file extension is supported. If - * the type is not supported, this method will return null. - */ - public static String getValidMimeTypeFromUrl(String url) { - String type = getMimeTypeFromUrl(url); - if (enclosureTypeValid(type)) { - return type; - } else { - return null; - } - } - /** * Should be used if mime-type of enclosure tag is not supported. This * method will return the mime-type of the file extension. diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java index a2795194d..ebde1e412 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/InvalidFeedException.java @@ -8,16 +8,4 @@ public class InvalidFeedException extends Exception { public InvalidFeedException() { } - - public InvalidFeedException(String message) { - super(message); - } - - public InvalidFeedException(Throwable cause) { - super(cause); - } - - public InvalidFeedException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/QueueAccess.java b/core/src/main/java/de/danoeh/antennapod/core/util/QueueAccess.java deleted file mode 100644 index ec8b8a430..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/QueueAccess.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import java.util.Iterator; -import java.util.List; - -import de.danoeh.antennapod.core.feed.FeedItem; - -/** - * Provides methods for accessing the queue. It is possible to load only a part of the information about the queue that - * is stored in the database (e.g. sometimes the user just has to test if a specific item is contained in the List. - * QueueAccess provides an interface for accessing the queue without having to care about the type of the queue - * representation. - */ -public abstract class QueueAccess { - /** - * Returns true if the item is in the queue, false otherwise. - */ - public abstract boolean contains(long id); - - /** - * Removes the item from the queue. - * - * @return true if the queue was modified by this operation. - */ - public abstract boolean remove(long id); - - private QueueAccess() { - } -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java b/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java deleted file mode 100644 index f9e2e9991..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/exception/MediaFileNotFoundException.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.danoeh.antennapod.core.util.exception; - -import de.danoeh.antennapod.core.feed.FeedMedia; - -public class MediaFileNotFoundException extends Exception { - private static final long serialVersionUID = 1L; - - private final FeedMedia media; - - public MediaFileNotFoundException(String msg, FeedMedia media) { - super(msg); - this.media = media; - } - - public FeedMedia getMedia() { - return media; - } -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java index 021268adb..7a68bb5ce 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/id3reader/ID3ReaderException.java @@ -3,18 +3,7 @@ package de.danoeh.antennapod.core.util.id3reader; public class ID3ReaderException extends Exception { private static final long serialVersionUID = 1L; - public ID3ReaderException() { - } - public ID3ReaderException(String message) { super(message); } - - public ID3ReaderException(Throwable message) { - super(message); - } - - public ID3ReaderException(String message, Throwable cause) { - super(message, cause); - } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index a11406171..6c4dafa0d 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -382,12 +382,6 @@ public class PlaybackController { public void onPlaybackEnd() {} - public void repeatHandleStatus() { - if (status != null && playbackService != null) { - handleStatus(); - } - } - /** * Is called whenever the PlaybackService changes its status. This method * should be used to update the GUI or start/cancel background threads. diff --git a/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java b/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java index 275b104ea..80777d036 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/storage/ItemEnqueuePositionCalculatorTest.java @@ -120,10 +120,6 @@ public class ItemEnqueuePositionCalculatorTest { return ItemEnqueuePositionCalculatorTest.getCurrentlyPlaying(idCurrentlyPlaying); } - private static Playable externalMedia() { - return new ExternalMedia("http://example.com/episode.mp3", MediaType.AUDIO); - } - private static final long ID_CURRENTLY_PLAYING_NULL = -1L; private static final long ID_CURRENTLY_PLAYING_NOT_FEEDMEDIA = -9999L; diff --git a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java index 0b64cb10f..2560ac6a0 100644 --- a/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java +++ b/core/src/test/java/de/danoeh/antennapod/core/util/FeedItemUtilTest.java @@ -13,61 +13,49 @@ import de.danoeh.antennapod.core.feed.FeedItem; import static org.junit.Assert.assertEquals; +@RunWith(Parameterized.class) public class FeedItemUtilTest { + private static final String FEED_LINK = "http://example.com"; + private static final String ITEM_LINK = "http://example.com/feedItem1"; + + private final String msg; + private final String feedLink; + private final String itemLink; + private final String expected; + + @Parameters + public static Collection<Object[]> data() { + return Arrays.asList(new Object[][] { + { "average", FEED_LINK, ITEM_LINK, ITEM_LINK }, + { "null item link - fallback to feed", FEED_LINK, null, FEED_LINK}, + { "empty item link - same as null", FEED_LINK, "", FEED_LINK}, + { "blank item link - same as null", FEED_LINK, " ", FEED_LINK}, + { "fallback, but feed link is null too", null, null, null }, + { "fallback - but empty feed link - same as null", "", null, null}, + { "fallback - but blank feed link - same as null", " ", null, null} + }); + } + public FeedItemUtilTest(String msg, String feedLink, String itemLink, String expected) { + this.msg = msg; + this.feedLink = feedLink; + this.itemLink = itemLink; + this.expected = expected; + } - @RunWith(Parameterized.class) - public static class LinkWithFallbackTest { - private static final String FEED_LINK = "http://example.com"; - private static final String ITEM_LINK = "http://example.com/feedItem1"; - - @Parameters - public static Collection<Object[]> data() { - return Arrays.asList(new Object[][] { - { "average", - FEED_LINK, ITEM_LINK, ITEM_LINK }, - { "null item link - fallback to feed", - FEED_LINK, null, FEED_LINK}, - { "empty item link - same as null", - FEED_LINK, "", FEED_LINK}, - { "blank item link - same as null", - FEED_LINK, " ", FEED_LINK}, - { "fallback, but feed link is null too", - null, null, null }, - { "fallback - but empty feed link - same as null", - "", null, null}, - { "fallback - but blank feed link - same as null", - " ", null, null} - }); - } - - private final String msg; - private final String feedLink; - private final String itemLink; - private final String expected; - - public LinkWithFallbackTest(String msg, String feedLink, String itemLink, String expected) { - this.msg = msg; - this.feedLink = feedLink; - this.itemLink = itemLink; - this.expected = expected; - } - - - @Test - public void testLinkWithFallback() { - String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink)); - assertEquals(msg, expected, actual); - } + @Test + public void testLinkWithFallback() { + String actual = FeedItemUtil.getLinkWithFallback(createFeedItem(feedLink, itemLink)); + assertEquals(msg, expected, actual); + } - private static FeedItem createFeedItem(String feedLink, String itemLink) { - Feed feed = new Feed(); - feed.setLink(feedLink); - FeedItem feedItem = new FeedItem(); - feedItem.setLink(itemLink); - feedItem.setFeed(feed); - feed.setItems(Arrays.asList(feedItem)); - return feedItem; - } + private static FeedItem createFeedItem(String feedLink, String itemLink) { + Feed feed = new Feed(); + feed.setLink(feedLink); + FeedItem feedItem = new FeedItem(); + feedItem.setLink(itemLink); + feedItem.setFeed(feed); + feed.setItems(Arrays.asList(feedItem)); + return feedItem; } } |