From 40da13e014a5b0c6e31b0234e31dac8c55473262 Mon Sep 17 00:00:00 2001 From: Taco Date: Mon, 4 Mar 2024 17:07:28 -0500 Subject: [PATCH] Clean up some dead code (#6952) --- .../util/event/FeedItemEventListener.java | 46 ------------------- .../antennapod/adapter/CoverLoader.java | 5 +- .../adapter/SubscriptionsRecyclerAdapter.java | 2 +- .../viewholder/EpisodeItemViewHolder.java | 4 +- .../viewholder/HorizontalItemViewHolder.java | 4 +- .../service/playback/ExoPlayerWrapper.java | 1 - .../util/download/ConnectionStateMonitor.java | 41 ----------------- .../core/util/playback/MediaPlayerError.java | 36 --------------- .../src/test/java/android/text/TextUtils.java | 1 + .../antennapod/core/storage/DbTasksTest.java | 21 --------- .../antennapod/model/feed/FeedItem.java | 4 -- .../antennapod/model/feed/SortOrder.java | 8 ---- .../net/sync/gpoddernet/GpodnetService.java | 32 ------------- .../ui/common/PagedToolbarFragment.java | 18 +------- ui/i18n/src/main/res/values/strings.xml | 5 -- 15 files changed, 8 insertions(+), 220 deletions(-) delete mode 100644 app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/util/download/ConnectionStateMonitor.java delete mode 100644 core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java diff --git a/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java b/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java deleted file mode 100644 index 7e8fc1205..000000000 --- a/app/src/androidTest/java/de/test/antennapod/util/event/FeedItemEventListener.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.test.antennapod.util.event; - -import androidx.annotation.NonNull; - -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; - -import java.util.ArrayList; -import java.util.List; - -import de.danoeh.antennapod.event.FeedItemEvent; -import io.reactivex.functions.Consumer; - -/** - * Test helpers to listen {@link FeedItemEvent} and handle them accordingly - * - */ -public class FeedItemEventListener { - private final List events = new ArrayList<>(); - - /** - * Provides an listener subscribing to {@link FeedItemEvent} that the callers can use - * - * Note: it uses RxJava's version of {@link Consumer} because it allows exceptions to be thrown. - */ - public static void withFeedItemEventListener(@NonNull Consumer consumer) - throws Exception { - FeedItemEventListener feedItemEventListener = new FeedItemEventListener(); - try { - EventBus.getDefault().register(feedItemEventListener); - consumer.accept(feedItemEventListener); - } finally { - EventBus.getDefault().unregister(feedItemEventListener); - } - } - - @Subscribe - public void onEvent(FeedItemEvent event) { - events.add(event); - } - - @NonNull - public List getEvents() { - return events; - } -} diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java index d5c67c675..c87228cdd 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/CoverLoader.java @@ -11,7 +11,6 @@ import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.CustomViewTarget; import com.bumptech.glide.request.transition.Transition; -import de.danoeh.antennapod.activity.MainActivity; import java.lang.ref.WeakReference; @@ -21,11 +20,9 @@ public class CoverLoader { private String fallbackUri; private ImageView imgvCover; private boolean textAndImageCombined; - private MainActivity activity; private TextView fallbackTitle; - public CoverLoader(MainActivity activity) { - this.activity = activity; + public CoverLoader() { } public CoverLoader withUri(String uri) { diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java index 284f3e468..2961796c6 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java @@ -244,7 +244,7 @@ public class SubscriptionsRecyclerAdapter extends SelectableAdapter 0) { - List items = new ArrayList<>(numFeedItems); - for (int i = 1; i <= numFeedItems; i++) { - FeedItem item = new FeedItem(0, "item " + i + " of " + title, "id" + title + i, "link", - new Date(), FeedItem.UNPLAYED, feed); - items.add(item); - } - feed.setItems(items); - } - - PodDBAdapter adapter = PodDBAdapter.getInstance(); - adapter.open(); - adapter.setCompleteFeed(feed); - adapter.close(); - return feed; - } - } diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java index e078d755a..25ea9330c 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedItem.java @@ -333,10 +333,6 @@ public class FeedItem implements Serializable { } } - public enum State { - UNREAD, IN_PROGRESS, READ, PLAYING - } - public long getFeedId() { return feedId; } diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java b/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java index 08504b445..f6c90341a 100644 --- a/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java +++ b/model/src/main/java/de/danoeh/antennapod/model/feed/SortOrder.java @@ -72,12 +72,4 @@ public enum SortOrder { public static String toCodeString(@Nullable SortOrder sortOrder) { return sortOrder != null ? Integer.toString(sortOrder.code) : null; } - - public static SortOrder[] valuesOf(String[] stringValues) { - SortOrder[] values = new SortOrder[stringValues.length]; - for (int i = 0; i < stringValues.length; i++) { - values[i] = SortOrder.valueOf(stringValues[i]); - } - return values; - } } diff --git a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java index 7873ae4fe..da23cd351 100644 --- a/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java +++ b/net/sync/gpoddernet/src/main/java/de/danoeh/antennapod/net/sync/gpoddernet/GpodnetService.java @@ -166,38 +166,6 @@ public class GpodnetService implements ISyncService { } } - /** - * Uploads the subscriptions of a specific device. - *

- * This method requires authentication. - * - * @param deviceId The ID of the device whose subscriptions should be updated. - * @param subscriptions A list of feed URLs containing all subscriptions of the - * device. - * @throws IllegalArgumentException If username, deviceId or subscriptions is null. - * @throws GpodnetServiceAuthenticationException If there is an authentication error. - */ - public void uploadSubscriptions(@NonNull String deviceId, @NonNull List subscriptions) - throws GpodnetServiceException { - requireLoggedIn(); - try { - URL url = new URI(baseScheme, null, baseHost, basePort, - String.format("/subscriptions/%s/%s.txt", username, deviceId), null, null).toURL(); - StringBuilder builder = new StringBuilder(); - for (String s : subscriptions) { - builder.append(s); - builder.append("\n"); - } - RequestBody body = RequestBody.create(TEXT, builder.toString()); - Request.Builder request = new Request.Builder().put(body).url(url); - executeRequest(request); - } catch (MalformedURLException | URISyntaxException e) { - e.printStackTrace(); - throw new GpodnetServiceException(e); - } - - } - /** * Updates the subscription list of a specific device. *

diff --git a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java index 3d82cb32c..48793ff13 100644 --- a/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java +++ b/ui/common/src/main/java/de/danoeh/antennapod/ui/common/PagedToolbarFragment.java @@ -1,6 +1,5 @@ package de.danoeh.antennapod.ui.common; -import androidx.annotation.NonNull; import com.google.android.material.appbar.MaterialToolbar; import androidx.fragment.app.Fragment; import androidx.viewpager2.widget.ViewPager2; @@ -10,23 +9,8 @@ import androidx.viewpager2.widget.ViewPager2; * All items share the same general menu items and are just allowed to show/hide them. */ public abstract class PagedToolbarFragment extends Fragment { - private MaterialToolbar toolbar; - private ViewPager2 viewPager; - /** - * Invalidate the toolbar menu if the current child fragment is visible. - * @param child The fragment to invalidate - */ - public void invalidateOptionsMenuIfActive(@NonNull Fragment child) { - Fragment visibleChild = getChildFragmentManager().findFragmentByTag("f" + viewPager.getCurrentItem()); - if (visibleChild == child) { - visibleChild.onPrepareOptionsMenu(toolbar.getMenu()); - } - } - - protected void setupPagedToolbar(MaterialToolbar toolbar, ViewPager2 viewPager) { - this.toolbar = toolbar; - this.viewPager = viewPager; + protected void setupPagedToolbar(final MaterialToolbar toolbar, final ViewPager2 viewPager) { toolbar.setOnMenuItemClickListener(item -> { if (this.onOptionsItemSelected(item)) { diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml index 03044a79d..1ce509002 100644 --- a/ui/i18n/src/main/res/values/strings.xml +++ b/ui/i18n/src/main/res/values/strings.xml @@ -320,11 +320,6 @@ - Server died - Unsupported media type - Operation timed out - Unable to access media file - Unknown error No media playing 00:00:00 AntennaPod - Unknown media key: %1$d