diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2019-09-20 22:05:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-20 22:05:39 +0200 |
commit | d3949969701f940193b2b60ccf5bfb16f22967a7 (patch) | |
tree | 2111e981312bff08b05dc8a15b627683861ac0c9 | |
parent | f9e7e9aeb67e739f9d72f787a05a083ff81a5dbc (diff) | |
parent | 79c94112ef722f807cb633bc2987a8a688d06f9b (diff) | |
download | AntennaPod-d3949969701f940193b2b60ccf5bfb16f22967a7.zip |
Merge pull request #3425 from ByteHamster/cleanup
Removed unused code
13 files changed, 3 insertions, 472 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/util/service/download/HTTPBin.java b/app/src/androidTest/java/de/test/antennapod/util/service/download/HTTPBin.java index 3d8417bf6..4158fd31c 100644 --- a/app/src/androidTest/java/de/test/antennapod/util/service/download/HTTPBin.java +++ b/app/src/androidTest/java/de/test/antennapod/util/service/download/HTTPBin.java @@ -72,20 +72,6 @@ public class HTTPBin extends NanoHTTPD { return servedFiles.size() - 1; } - /** - * Removes the file with the given ID from the server. - * - * @return True if a file was removed, false otherwise - */ - public synchronized boolean removeFile(int id) { - if (id < 0) throw new IllegalArgumentException("ID < 0"); - if (id >= servedFiles.size()) { - return false; - } else { - return servedFiles.remove(id) != null; - } - } - public synchronized File accessFile(int id) { if (id < 0 || id >= servedFiles.size()) { return null; diff --git a/app/src/free/java/de/danoeh/antennapod/activity/CastEnabledActivity.java b/app/src/free/java/de/danoeh/antennapod/activity/CastEnabledActivity.java index 79d7e02f2..519d4c61b 100644 --- a/app/src/free/java/de/danoeh/antennapod/activity/CastEnabledActivity.java +++ b/app/src/free/java/de/danoeh/antennapod/activity/CastEnabledActivity.java @@ -7,212 +7,9 @@ import android.support.v7.app.AppCompatActivity; * network. */ public abstract class CastEnabledActivity extends AppCompatActivity { -// implements SharedPreferences.OnSharedPreferenceChangeListener { public static final String TAG = "CastEnabledActivity"; -// protected CastManager castManager; -// protected SwitchableMediaRouteActionProvider mediaRouteActionProvider; -// private final CastButtonVisibilityManager castButtonVisibilityManager = new CastButtonVisibilityManager(); -// -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// -// PreferenceManager.getDefaultSharedPreferences(getApplicationContext()). -// registerOnSharedPreferenceChangeListener(this); -// -// castManager = CastManager.getInstance(); -// castManager.addCastConsumer(castConsumer); -// castButtonVisibilityManager.setPrefEnabled(UserPreferences.isCastEnabled()); -// onCastConnectionChanged(castManager.isConnected()); -// } -// -// @Override -// protected void onDestroy() { -// PreferenceManager.getDefaultSharedPreferences(getApplicationContext()) -// .unregisterOnSharedPreferenceChangeListener(this); -// castManager.removeCastConsumer(castConsumer); -// super.onDestroy(); -// } -// -// @Override -// @CallSuper -// public boolean onCreateOptionsMenu(Menu menu) { -// super.onCreateOptionsMenu(menu); -// getMenuInflater().inflate(R.menu.cast_enabled, menu); -// castButtonVisibilityManager.setMenu(menu); -// return true; -// } -// -// @Override -// @CallSuper -// public boolean onPrepareOptionsMenu(Menu menu) { -// super.onPrepareOptionsMenu(menu); -// mediaRouteActionProvider = castManager -// .addMediaRouterButton(menu.findItem(R.id.media_route_menu_item)); -// mediaRouteActionProvider.setEnabled(castButtonVisibilityManager.shouldEnable()); -// return true; -// } -// -// @Override -// protected void onResume() { -// super.onResume(); -// castButtonVisibilityManager.setResumed(true); -// } -// -// @Override -// protected void onPause() { -// super.onPause(); -// castButtonVisibilityManager.setResumed(false); -// } -// -// @Override -// public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { -// if (UserPreferences.PREF_CAST_ENABLED.equals(key)) { -// boolean newValue = UserPreferences.isCastEnabled(); -// Log.d(TAG, "onSharedPreferenceChanged(), isCastEnabled set to " + newValue); -// castButtonVisibilityManager.setPrefEnabled(newValue); -// // PlaybackService has its own listener, so if it's active we don't have to take action here. -// if (!newValue && !PlaybackService.isRunning) { -// CastManager.getInstance().disconnect(); -// } -// } -// } -// -// CastConsumer castConsumer = new DefaultCastConsumer() { -// @Override -// public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) { -// onCastConnectionChanged(true); -// } -// -// @Override -// public void onDisconnected() { -// onCastConnectionChanged(false); -// } -// }; -// -// private void onCastConnectionChanged(boolean connected) { -// if (connected) { -// castButtonVisibilityManager.onConnected(); -// setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE); -// } else { -// castButtonVisibilityManager.onDisconnected(); -// setVolumeControlStream(AudioManager.STREAM_MUSIC); -// } -// } -// -// /** -// * Should be called by any activity or fragment for which the cast button should be shown. -// * -// * @param showAsAction refer to {@link MenuItem#setShowAsAction(int)} -// */ public final void requestCastButton(int showAsAction) { // no-op } - -// private class CastButtonVisibilityManager { -// private volatile boolean prefEnabled = false; -// private volatile boolean viewRequested = false; -// private volatile boolean resumed = false; -// private volatile boolean connected = false; -// private volatile int showAsAction = MenuItem.SHOW_AS_ACTION_IF_ROOM; -// private Menu menu; -// -// public synchronized void setPrefEnabled(boolean newValue) { -// if (prefEnabled != newValue && resumed && (viewRequested || connected)) { -// if (newValue) { -// castManager.incrementUiCounter(); -// } else { -// castManager.decrementUiCounter(); -// } -// } -// prefEnabled = newValue; -// if (mediaRouteActionProvider != null) { -// mediaRouteActionProvider.setEnabled(prefEnabled && (viewRequested || connected)); -// } -// } -// -// public synchronized void setResumed(boolean newValue) { -// if (resumed == newValue) { -// Log.e(TAG, "resumed should never change to the same value"); -// return; -// } -// resumed = newValue; -// if (prefEnabled && (viewRequested || connected)) { -// if (resumed) { -// castManager.incrementUiCounter(); -// } else { -// castManager.decrementUiCounter(); -// } -// } -// } -// -// public synchronized void setViewRequested(boolean newValue) { -// if (viewRequested != newValue && resumed && prefEnabled && !connected) { -// if (newValue) { -// castManager.incrementUiCounter(); -// } else { -// castManager.decrementUiCounter(); -// } -// } -// viewRequested = newValue; -// if (mediaRouteActionProvider != null) { -// mediaRouteActionProvider.setEnabled(prefEnabled && (viewRequested || connected)); -// } -// } -// -// public synchronized void setConnected(boolean newValue) { -// if (connected != newValue && resumed && prefEnabled && !prefEnabled) { -// if (newValue) { -// castManager.incrementUiCounter(); -// } else { -// castManager.decrementUiCounter(); -// } -// } -// connected = newValue; -// if (mediaRouteActionProvider != null) { -// mediaRouteActionProvider.setEnabled(prefEnabled && (viewRequested || connected)); -// } -// } -// -// public synchronized boolean shouldEnable() { -// return prefEnabled && viewRequested; -// } -// -// public void setMenu(Menu menu) { -// setViewRequested(false); -// showAsAction = MenuItem.SHOW_AS_ACTION_IF_ROOM; -// this.menu = menu; -// setShowAsAction(); -// } -// -// public void requestCastButton(int showAsAction) { -// setViewRequested(true); -// this.showAsAction = showAsAction; -// setShowAsAction(); -// } -// -// public void onConnected() { -// setConnected(true); -// setShowAsAction(); -// } -// -// public void onDisconnected() { -// setConnected(false); -// setShowAsAction(); -// } -// -// private void setShowAsAction() { -// if (menu == null) { -// Log.d(TAG, "setShowAsAction() without a menu"); -// return; -// } -// MenuItem item = menu.findItem(R.id.media_route_menu_item); -// if (item == null) { -// Log.e(TAG, "setShowAsAction(), but cast button not inflated"); -// return; -// } -// MenuItemCompat.setShowAsAction(item, connected? MenuItem.SHOW_AS_ACTION_ALWAYS : showAsAction); -// } -// } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java index b4226b546..87d436eda 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/StoragePreferencesFragment.java @@ -171,7 +171,9 @@ public class StoragePreferencesFragment extends PreferenceFragmentCompat { return true; } - public void unsubscribeExportSubscription() { + @Override + public void onStop() { + super.onStop(); if (disposable != null) { disposable.dispose(); } 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 @@ -891,13 +891,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. */ public static boolean isCastEnabled() { 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> 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> 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<FeedItem> 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<FeedItem> 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<FeedItem> 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<FeedItem> 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<Feed> { - - @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<SearchResult> { - - /** - * 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; - } - -} |