From 79c94112ef722f807cb633bc2987a8a688d06f9b Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sat, 14 Sep 2019 21:14:16 +0200 Subject: Removed unused code --- .../antennapod/core/event/FeedMediaEvent.java | 23 ---- .../core/preferences/UserPreferences.java | 7 -- .../core/service/download/DownloadStatus.java | 4 - .../de/danoeh/antennapod/core/storage/DBTasks.java | 5 - .../antennapod/core/storage/DownloadRequester.java | 5 - .../antennapod/core/storage/PodDBAdapter.java | 13 --- .../de/danoeh/antennapod/core/util/DuckType.java | 117 --------------------- .../danoeh/antennapod/core/util/FeedItemUtil.java | 38 ------- .../antennapod/core/util/FeedtitleComparator.java | 15 --- .../comparator/SearchResultValueComparator.java | 27 ----- 10 files changed, 254 deletions(-) delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/event/FeedMediaEvent.java delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/util/DuckType.java delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/util/FeedtitleComparator.java delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/util/comparator/SearchResultValueComparator.java (limited to 'core/src/main') diff --git a/core/src/main/java/de/danoeh/antennapod/core/event/FeedMediaEvent.java b/core/src/main/java/de/danoeh/antennapod/core/event/FeedMediaEvent.java deleted file mode 100644 index 4a591c996..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/event/FeedMediaEvent.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.danoeh.antennapod.core.event; - -import de.danoeh.antennapod.core.feed.FeedMedia; - -public class FeedMediaEvent { - - public enum Action { - UPDATE - } - - private final Action action; - private final FeedMedia media; - - private FeedMediaEvent(Action action, FeedMedia media) { - this.action = action; - this.media = media; - } - - public static FeedMediaEvent update(FeedMedia media) { - return new FeedMediaEvent(Action.UPDATE, media); - } - -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java index b8ab1c888..6d614f039 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java @@ -890,13 +890,6 @@ public class UserPreferences { } } - /** - * Reads episode cache size as it is saved in the episode_cache_size_values array. - */ - public static int readEpisodeCacheSize(String valueFromPrefs) { - return readEpisodeCacheSizeInternal(valueFromPrefs); - } - /** * Evaluates whether Cast support (Chromecast, Audio Cast, etc) is enabled on the preferences. */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java index 5debc6d05..d88eb63f4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java @@ -193,10 +193,6 @@ public class DownloadStatus { this.cancelled = true; } - public void setCompletionDate(Date completionDate) { - this.completionDate = (Date) completionDate.clone(); - } - public void setId(long id) { this.id = id; } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index e68bff16e..0fb181299 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -193,11 +193,6 @@ public final class DBTasks { }).start(); } - public static long getLastRefreshAllFeedsTimeMillis(final Context context) { - SharedPreferences prefs = context.getSharedPreferences(DBTasks.PREF_NAME, MODE_PRIVATE); - return prefs.getLong(DBTasks.PREF_LAST_REFRESH, 0); - } - /** * @param context * @param feedList the list of feeds to refresh diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java index 892a4675a..9c48f31dd 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java @@ -34,7 +34,6 @@ import de.danoeh.antennapod.core.util.URLChecker; public class DownloadRequester { private static final String TAG = "DownloadRequester"; - public static final String IMAGE_DOWNLOADPATH = "images/"; private static final String FEED_DOWNLOADPATH = "cache/"; private static final String MEDIA_DOWNLOADPATH = "media/"; @@ -274,10 +273,6 @@ public class DownloadRequester { return item.getDownload_url() != null && downloads.containsKey(item.getDownload_url()); } - public synchronized DownloadRequest getDownload(String downloadUrl) { - return downloads.get(downloadUrl); - } - /** * Checks if feedfile with the given download url is in the downloads list */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 13ea9daf0..a3271bcf9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -55,16 +55,10 @@ public class PodDBAdapter { */ private static final int IN_OPERATOR_MAXIMUM = 800; - /** - * Maximum number of entries per search request. - */ - public static final int SEARCH_LIMIT = 30; - // Key-constants public static final String KEY_ID = "id"; public static final String KEY_TITLE = "title"; public static final String KEY_CUSTOM_TITLE = "custom_title"; - public static final String KEY_NAME = "name"; public static final String KEY_LINK = "link"; public static final String KEY_DESCRIPTION = "description"; public static final String KEY_FILE_URL = "file_url"; @@ -1400,13 +1394,6 @@ public class PodDBAdapter { return db.rawQuery(query, null); } - - public static final int IDX_FEEDSTATISTICS_FEED = 0; - public static final int IDX_FEEDSTATISTICS_NUM_ITEMS = 1; - public static final int IDX_FEEDSTATISTICS_NEW_ITEMS = 2; - public static final int IDX_FEEDSTATISTICS_LATEST_EPISODE = 3; - public static final int IDX_FEEDSTATISTICS_IN_PROGRESS_EPISODES = 4; - /** * Select number of items, new items, the date of the latest episode and the number of episodes in progress. The result * is sorted by the title of the feed. diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DuckType.java b/core/src/main/java/de/danoeh/antennapod/core/util/DuckType.java deleted file mode 100644 index 69dc38895..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/DuckType.java +++ /dev/null @@ -1,117 +0,0 @@ -/* Adapted from: http://thinking-in-code.blogspot.com/2008/11/duck-typing-in-java-using-dynamic.html */ - -package de.danoeh.antennapod.core.util; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.lang.reflect.Proxy; - -import de.danoeh.antennapod.core.BuildConfig; - -/** - * Allows "duck typing" or dynamic invocation based on method signature rather - * than type hierarchy. In other words, rather than checking whether something - * IS-a duck, check whether it WALKS-like-a duck or QUACKS-like a duck. - * - * To use first use the coerce static method to indicate the object you want to - * do Duck Typing for, then specify an interface to the to method which you want - * to coerce the type to, e.g: - * - * public interface Foo { void aMethod(); } class Bar { ... public void - * aMethod() { ... } ... } Bar bar = ...; Foo foo = - * DuckType.coerce(bar).to(Foo.class); foo.aMethod(); - * - * - */ -public class DuckType { - - private final Object objectToCoerce; - - private DuckType(Object objectToCoerce) { - this.objectToCoerce = objectToCoerce; - } - - private class CoercedProxy implements InvocationHandler { - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - Method delegateMethod = findMethodBySignature(method); - assert delegateMethod != null; - return delegateMethod.invoke(DuckType.this.objectToCoerce, args); - } - } - - /** - * Specify the duck typed object to coerce. - * - * @param object - * the object to coerce - * @return - */ - public static DuckType coerce(Object object) { - return new DuckType(object); - } - - /** - * Coerce the Duck Typed object to the given interface providing it - * implements all the necessary methods. - * - * @param - * @param iface - * @return an instance of the given interface that wraps the duck typed - * class - * @throws ClassCastException - * if the object being coerced does not implement all the - * methods in the given interface. - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - public T to(Class iface) { - if (BuildConfig.DEBUG && !iface.isInterface()) throw new AssertionError("cannot coerce object to a class, must be an interface"); - if (isA(iface)) { - return (T) iface.cast(objectToCoerce); - } - if (quacksLikeA(iface)) { - return generateProxy(iface); - } - throw new ClassCastException("Could not coerce object of type " + objectToCoerce.getClass() + " to " + iface); - } - - @SuppressWarnings("rawtypes") - private boolean isA(Class iface) { - return objectToCoerce.getClass().isInstance(iface); - } - - /** - * Determine whether the duck typed object can be used with the given - * interface. - * - * @param Type - * of the interface to check. - * @param iface - * Interface class to check - * @return true if the object will support all the methods in the interface, - * false otherwise. - */ - @SuppressWarnings("rawtypes") - private boolean quacksLikeA(Class iface) { - for (Method method : iface.getMethods()) { - if (findMethodBySignature(method) == null) { - return false; - } - } - return true; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private T generateProxy(Class iface) { - return (T) Proxy.newProxyInstance(iface.getClassLoader(), new Class[] { iface }, new CoercedProxy()); - } - - private Method findMethodBySignature(Method method) { - try { - return objectToCoerce.getClass().getMethod(method.getName(), method.getParameterTypes()); - } catch (NoSuchMethodException e) { - return null; - } - } - -} \ No newline at end of file diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java index 826c06822..a8206d3bd 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/FeedItemUtil.java @@ -7,19 +7,6 @@ import de.danoeh.antennapod.core.feed.FeedItem; public class FeedItemUtil { private FeedItemUtil(){} - public static int indexOfItemWithDownloadUrl(List items, String downloadUrl) { - if(items == null) { - return -1; - } - for(int i=0; i < items.size(); i++) { - FeedItem item = items.get(i); - if(item.hasMedia() && item.getMedia().getDownload_url().equals(downloadUrl)) { - return i; - } - } - return -1; - } - public static int indexOfItemWithId(List items, long id) { for(int i=0; i < items.size(); i++) { FeedItem item = items.get(i); @@ -40,17 +27,6 @@ public class FeedItemUtil { return -1; } - public static long[] getIds(FeedItem... items) { - if(items == null || items.length == 0) { - return new long[0]; - } - long[] result = new long[items.length]; - for(int i=0; i < items.length; i++) { - result[i] = items[i].getId(); - } - return result; - } - public static long[] getIds(List items) { if(items == null || items.size() == 0) { return new long[0]; @@ -62,20 +38,6 @@ public class FeedItemUtil { return result; } - public static boolean containsAnyId(List items, long[] ids) { - if(items == null || items.size() == 0) { - return false; - } - for(FeedItem item : items) { - for(long id : ids) { - if(item.getId() == id) { - return true; - } - } - } - return false; - } - /** * Get the link for the feed item for the purpose of Share. It fallbacks to * use the feed's link if the named feed item has no link. diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/FeedtitleComparator.java b/core/src/main/java/de/danoeh/antennapod/core/util/FeedtitleComparator.java deleted file mode 100644 index 29d095cd2..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/FeedtitleComparator.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.danoeh.antennapod.core.util; - -import java.util.Comparator; - -import de.danoeh.antennapod.core.feed.Feed; - -/** Compares the title of two feeds for sorting. */ -class FeedtitleComparator implements Comparator { - - @Override - public int compare(Feed lhs, Feed rhs) { - return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); - } - -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/SearchResultValueComparator.java b/core/src/main/java/de/danoeh/antennapod/core/util/comparator/SearchResultValueComparator.java deleted file mode 100644 index 56a684475..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/util/comparator/SearchResultValueComparator.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.danoeh.antennapod.core.util.comparator; - -import java.util.Comparator; - -import de.danoeh.antennapod.core.feed.FeedItem; -import de.danoeh.antennapod.core.feed.SearchResult; - -public class SearchResultValueComparator implements Comparator { - - /** - * Compare items based, first, on where they were found (ie. title, chapters, or show notes). - * If they were found in the same section, then compare based on the title, in lexicographic - * order. This is still not ideal since, for example, "#12 Example A" would be considered - * before "#8 Example B" due to the fact that "8" has a larger unicode value than "1" - */ - @Override - public int compare(SearchResult lhs, SearchResult rhs) { - int value = rhs.getValue() - lhs.getValue(); - if (value == 0 && lhs.getComponent() instanceof FeedItem && rhs.getComponent() instanceof FeedItem) { - String lhsTitle = ((FeedItem) lhs.getComponent()).getTitle(); - String rhsTitle = ((FeedItem) rhs.getComponent()).getTitle(); - return lhsTitle.compareTo(rhsTitle); - } - return value; - } - -} -- cgit v1.2.3