diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-27 21:01:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 21:01:45 +0100 |
commit | 1dbda2fb8a070fb30b4314feca839525cfc701eb (patch) | |
tree | 30b63908a65915e60439353eea493b175fa959ae /app/src/main/java/de/danoeh/antennapod | |
parent | 130da46f5d9c598ca76f4f2127c08bb4ef225b34 (diff) | |
download | AntennaPod-1dbda2fb8a070fb30b4314feca839525cfc701eb.zip |
Split up DBTasks which has unclear responsibilities (#7032)
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod')
8 files changed, 27 insertions, 17 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 53faf8eb0..de76c4066 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -33,7 +33,7 @@ import de.danoeh.antennapod.adapter.FeedItemlistDescriptionAdapter; import de.danoeh.antennapod.ui.common.ThemeSwitcher; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException; -import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.core.util.DownloadErrorLabel; import de.danoeh.antennapod.databinding.EditTextDialogBinding; @@ -452,7 +452,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity { if (feedInFeedlist()) { openFeed(); } else { - DBTasks.updateFeed(this, feed, false); + FeedDatabaseWriter.updateFeed(this, feed, false); didPressSubscribe = true; handleUpdatedFeedStatus(); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java index 7bd057988..ed11e6910 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportActivity.java @@ -28,7 +28,7 @@ import androidx.core.app.ActivityCompat; import de.danoeh.antennapod.R; import de.danoeh.antennapod.ui.common.ThemeSwitcher; -import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.databinding.OpmlSelectionBinding; import de.danoeh.antennapod.model.feed.Feed; @@ -102,7 +102,7 @@ public class OpmlImportActivity extends AppCompatActivity { Feed feed = new Feed(element.getXmlUrl(), null, element.getText() != null ? element.getText() : "Unknown podcast"); feed.setItems(Collections.emptyList()); - DBTasks.updateFeed(this, feed, false); + FeedDatabaseWriter.updateFeed(this, feed, false); } FeedUpdateManager.runOnce(this); }) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java index 983ae3df9..e0a15191e 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/actionbutton/PlayActionButton.java @@ -1,17 +1,22 @@ package de.danoeh.antennapod.adapter.actionbutton; import android.content.Context; +import android.util.Log; import androidx.annotation.DrawableRes; import androidx.annotation.StringRes; import de.danoeh.antennapod.R; +import de.danoeh.antennapod.core.storage.DBWriter; +import de.danoeh.antennapod.event.FeedItemEvent; +import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.playback.MediaType; import de.danoeh.antennapod.core.service.playback.PlaybackService; -import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter; +import org.greenrobot.eventbus.EventBus; public class PlayActionButton extends ItemActionButton { + private static final String TAG = "PlayActionButton"; public PlayActionButton(FeedItem item) { super(item); @@ -36,7 +41,12 @@ public class PlayActionButton extends ItemActionButton { return; } if (!media.fileExists()) { - DBTasks.notifyMissingFeedMediaFile(context, media); + Log.i(TAG, "Missing episode. Will update the database now."); + media.setDownloaded(false); + media.setLocalFileUrl(null); + DBWriter.setFeedMedia(media); + EventBus.getDefault().post(FeedItemEvent.updated(media.getItem())); + EventBus.getDefault().post(new MessageEvent(context.getString(R.string.error_file_not_found))); return; } new PlaybackServiceStarter(context, media) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java index 16bfaa00a..5074c5b64 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java @@ -29,7 +29,7 @@ import de.danoeh.antennapod.activity.OnlineFeedViewActivity; import de.danoeh.antennapod.activity.OpmlImportActivity; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.databinding.AddfeedBinding; import de.danoeh.antennapod.databinding.EditTextDialogBinding; @@ -205,7 +205,7 @@ public class AddFeedFragment extends Fragment { Feed dirFeed = new Feed(Feed.PREFIX_LOCAL_FOLDER + uri.toString(), null, title); dirFeed.setItems(Collections.emptyList()); dirFeed.setSortOrder(SortOrder.EPISODE_TITLE_A_Z); - Feed fromDatabase = DBTasks.updateFeed(getContext(), dirFeed, false); + Feed fromDatabase = FeedDatabaseWriter.updateFeed(getContext(), dirFeed, false); FeedUpdateManager.runOnce(requireContext(), fromDatabase); return fromDatabase; } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java index a8d6053fe..49ea28765 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java @@ -35,7 +35,7 @@ import com.google.android.material.snackbar.Snackbar; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.storage.database.DBReader; -import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.ShareUtils; import de.danoeh.antennapod.core.util.syndication.HtmlToPlainText; @@ -340,7 +340,7 @@ public class FeedInfoFragment extends Fragment implements MaterialToolbar.OnMenu throw new IllegalArgumentException("Unable to retrieve document tree"); } feed.setDownloadUrl(Feed.PREFIX_LOCAL_FOLDER + uri.toString()); - DBTasks.updateFeed(getContext(), feed, true); + FeedDatabaseWriter.updateFeed(getContext(), feed, true); }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java index 8c976ae7c..76b53a264 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -42,10 +42,10 @@ import de.danoeh.antennapod.event.UnreadItemsUpdateEvent; import de.danoeh.antennapod.fragment.actions.EpisodeMultiSelectActionHandler; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.core.storage.FeedSearcher; import de.danoeh.antennapod.core.util.FeedItemUtil; import de.danoeh.antennapod.menuhandler.FeedItemMenuHandler; import de.danoeh.antennapod.net.discovery.CombinedSearcher; +import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.view.EmptyViewHandler; import de.danoeh.antennapod.view.EpisodeItemListRecyclerView; import de.danoeh.antennapod.view.LiftOnScrollListener; @@ -407,8 +407,8 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O return new Pair<>(Collections.emptyList(), Collections.emptyList()); } long feed = getArguments().getLong(ARG_FEED); - List<FeedItem> items = FeedSearcher.searchFeedItems(query, feed); - List<Feed> feeds = FeedSearcher.searchFeeds(query); + List<FeedItem> items = DBReader.searchFeedItems(feed, query); + List<Feed> feeds = DBReader.searchFeeds(query); return new Pair<>(items, feeds); } 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 a90ad157e..9b3b40b45 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/PowerConnectionReceiver.java @@ -6,9 +6,9 @@ import android.content.Intent; import android.util.Log; import de.danoeh.antennapod.core.ClientConfigurator; +import de.danoeh.antennapod.core.storage.AutoDownloadManager; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; -import de.danoeh.antennapod.core.storage.DBTasks; // modified from http://developer.android.com/training/monitoring-device-state/battery-monitoring.html // and ConnectivityActionReceiver.java @@ -32,7 +32,7 @@ public class PowerConnectionReceiver extends BroadcastReceiver { // downloading now. They shouldn't mind. // autodownloadUndownloadedItems will make sure we're on the right wifi networks, // etc... so we don't have to worry about it. - DBTasks.autodownloadUndownloadedItems(context); + AutoDownloadManager.autodownloadUndownloadedItems(context); } else { // if we're not supposed to be auto-downloading when we're not charging, stop it if (!UserPreferences.isEnableAutodownloadOnBattery()) { diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java index 788359a4e..d6641a1e1 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/SPAReceiver.java @@ -12,7 +12,7 @@ import java.util.Collections; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.ClientConfigurator; -import de.danoeh.antennapod.core.storage.DBTasks; +import de.danoeh.antennapod.core.storage.FeedDatabaseWriter; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; import de.danoeh.antennapod.model.feed.Feed; @@ -46,7 +46,7 @@ public class SPAReceiver extends BroadcastReceiver{ for (String url : feedUrls) { Feed feed = new Feed(url, null, "Unknown podcast"); feed.setItems(Collections.emptyList()); - DBTasks.updateFeed(context, feed, false); + FeedDatabaseWriter.updateFeed(context, feed, false); } Toast.makeText(context, R.string.sp_apps_importing_feeds_msg, Toast.LENGTH_LONG).show(); FeedUpdateManager.runOnce(context); |