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 /core/src/main | |
parent | 130da46f5d9c598ca76f4f2127c08bb4ef225b34 (diff) | |
download | AntennaPod-1dbda2fb8a070fb30b4314feca839525cfc701eb.zip |
Split up DBTasks which has unclear responsibilities (#7032)
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java | 4 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java | 6 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java | 7 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 3 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/AutoDownloadManager.java | 54 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java | 40 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/FeedDatabaseWriter.java (renamed from core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java) | 186 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java | 43 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java | 6 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java | 4 |
10 files changed, 109 insertions, 244 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java b/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java index a4b0436bd..358b75e9c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java +++ b/core/src/main/java/de/danoeh/antennapod/core/backup/OpmlBackupAgent.java @@ -8,7 +8,7 @@ import android.content.Context; import android.os.ParcelFileDescriptor; import android.util.Log; -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.storage.importexport.OpmlElement; import de.danoeh.antennapod.storage.importexport.OpmlReader; @@ -146,7 +146,7 @@ public class OpmlBackupAgent extends BackupAgentHelper { for (OpmlElement opmlElem : opmlElements) { Feed feed = new Feed(opmlElem.getXmlUrl(), null, opmlElem.getText()); feed.setItems(Collections.emptyList()); - DBTasks.updateFeed(mContext, feed, false); + FeedDatabaseWriter.updateFeed(mContext, feed, false); } FeedUpdateManager.runOnce(mContext); } catch (XmlPullParserException e) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java index 096a3757e..a4dab1996 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/LocalFeedUpdater.java @@ -31,7 +31,7 @@ import de.danoeh.antennapod.core.util.FastDocumentFile; import de.danoeh.antennapod.model.MediaMetadataRetrieverCompat; import de.danoeh.antennapod.model.download.DownloadResult; 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.storage.DBWriter; import de.danoeh.antennapod.parser.feed.util.DateUtils; import de.danoeh.antennapod.model.download.DownloadError; @@ -82,7 +82,7 @@ public class LocalFeedUpdater { feed.setItems(new ArrayList<>()); } //make sure it is the latest 'version' of this feed from the db (all items etc) - feed = DBTasks.updateFeed(context, feed, false); + feed = FeedDatabaseWriter.updateFeed(context, feed, false); // list files in feed folder List<FastDocumentFile> allFiles = FastDocumentFile.list(context, folderUri); @@ -127,7 +127,7 @@ public class LocalFeedUpdater { feed.setDescription(context.getString(R.string.local_feed_description)); feed.setAuthor(context.getString(R.string.local_folder)); - DBTasks.updateFeed(context, feed, true); + FeedDatabaseWriter.updateFeed(context, feed, true); } /** diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java b/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java index ac1f739af..45b6aee04 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java @@ -24,8 +24,9 @@ import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.NewEpisodesNotification; import de.danoeh.antennapod.core.service.download.handler.FeedParserTask; +import de.danoeh.antennapod.core.storage.AutoDownloadManager; 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.storage.DBWriter; import de.danoeh.antennapod.net.common.NetworkUtils; import de.danoeh.antennapod.core.util.download.FeedUpdateManager; @@ -99,7 +100,7 @@ public class FeedUpdateWorker extends Worker { refreshFeeds(toUpdate, force); notificationManager.cancel(R.id.notification_updating_feeds); - DBTasks.autodownloadUndownloadedItems(getApplicationContext()); + AutoDownloadManager.autodownloadUndownloadedItems(getApplicationContext()); return Result.success(); } @@ -199,7 +200,7 @@ public class FeedUpdateWorker extends Worker { return; } feedHandlerResult.feed.setLastRefreshAttempt(System.currentTimeMillis()); - Feed savedFeed = DBTasks.updateFeed(getApplicationContext(), feedHandlerResult.feed, false); + Feed savedFeed = FeedDatabaseWriter.updateFeed(getApplicationContext(), feedHandlerResult.feed, false); if (request.getFeedfileId() == 0) { return; // No download logs for new subscriptions diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index f40d51933..6f7068d24 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -72,7 +72,6 @@ import de.danoeh.antennapod.core.service.QuickSettingsTileService; import de.danoeh.antennapod.core.service.playback.PlaybackServiceTaskManager.SleepTimer; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; -import de.danoeh.antennapod.core.storage.FeedSearcher; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.util.ChapterUtils; import de.danoeh.antennapod.core.util.FeedItemUtil; @@ -1842,7 +1841,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { return; } - List<FeedItem> results = FeedSearcher.searchFeedItems(query, 0); + List<FeedItem> results = DBReader.searchFeedItems(0, query); if (results.size() > 0 && results.get(0).getMedia() != null) { FeedMedia media = results.get(0).getMedia(); startPlaying(media, false); diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/AutoDownloadManager.java b/core/src/main/java/de/danoeh/antennapod/core/storage/AutoDownloadManager.java new file mode 100644 index 000000000..bc5244381 --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/AutoDownloadManager.java @@ -0,0 +1,54 @@ +package de.danoeh.antennapod.core.storage; + +import android.content.Context; +import android.util.Log; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +public abstract class AutoDownloadManager { + private static final String TAG = "AutoDownloadManager"; + + /** + * Executor service used by the autodownloadUndownloadedEpisodes method. + */ + private static final ExecutorService autodownloadExec; + + private static AutomaticDownloadAlgorithm downloadAlgorithm = new AutomaticDownloadAlgorithm(); + + static { + autodownloadExec = Executors.newSingleThreadExecutor(r -> { + Thread t = new Thread(r); + t.setPriority(Thread.MIN_PRIORITY); + return t; + }); + } + + /** + * Looks for non-downloaded episodes in the queue or list of unread items and request a download if + * 1. Network is available + * 2. The device is charging or the user allows auto download on battery + * 3. There is free space in the episode cache + * This method is executed on an internal single thread executor. + * + * @param context Used for accessing the DB. + * @return A Future that can be used for waiting for the methods completion. + */ + public static Future<?> autodownloadUndownloadedItems(final Context context) { + Log.d(TAG, "autodownloadUndownloadedItems"); + return autodownloadExec.submit(downloadAlgorithm.autoDownloadUndownloadedItems(context)); + } + + /** + * Removed downloaded episodes outside of the queue if the episode cache is full. Episodes with a smaller + * 'playbackCompletionDate'-value will be deleted first. + * <p/> + * This method should NOT be executed on the GUI thread. + * + * @param context Used for accessing the DB. + */ + public static void performAutoCleanup(final Context context) { + EpisodeCleanupAlgorithmFactory.build().performCleanup(context); + } +} diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java index 496eaf374..1e5b416e2 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBWriter.java @@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.storage; import android.app.backup.BackupManager; import android.content.Context; +import android.database.Cursor; import android.net.Uri; import android.util.Log; @@ -27,6 +28,7 @@ import java.util.Date; import java.util.List; import java.util.Locale; import java.util.Set; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; @@ -366,7 +368,7 @@ public class DBWriter { adapter.close(); if (performAutoDownload) { - DBTasks.autodownloadUndownloadedItems(context); + AutoDownloadManager.autodownloadUndownloadedItems(context); } }); @@ -460,7 +462,7 @@ public class DBWriter { } adapter.close(); if (performAutoDownload) { - DBTasks.autodownloadUndownloadedItems(context); + AutoDownloadManager.autodownloadUndownloadedItems(context); } }); } @@ -569,7 +571,7 @@ public class DBWriter { } adapter.close(); if (performAutoDownload) { - DBTasks.autodownloadUndownloadedItems(context); + AutoDownloadManager.autodownloadUndownloadedItems(context); } } @@ -1017,6 +1019,38 @@ public class DBWriter { } /** + * Removes the feed with the given download url. This method should NOT be executed on the GUI thread. + * + * @param context Used for accessing the db + * @param downloadUrl URL of the feed. + */ + public static void removeFeedWithDownloadUrl(Context context, String downloadUrl) { + PodDBAdapter adapter = PodDBAdapter.getInstance(); + adapter.open(); + Cursor cursor = adapter.getFeedCursorDownloadUrls(); + long feedId = 0; + if (cursor.moveToFirst()) { + do { + if (cursor.getString(1).equals(downloadUrl)) { + feedId = cursor.getLong(0); + } + } while (cursor.moveToNext()); + } + cursor.close(); + adapter.close(); + + if (feedId != 0) { + try { + deleteFeed(context, feedId).get(); + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } else { + Log.w(TAG, "removeFeedWithDownloadUrl: Could not find feed with url: " + downloadUrl); + } + } + + /** * Submit to the DB thread only if caller is not already on the DB thread. Otherwise, * just execute synchronously */ diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedDatabaseWriter.java index b7112e6fd..7c21bd7c9 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedDatabaseWriter.java @@ -1,26 +1,19 @@ package de.danoeh.antennapod.core.storage; import android.content.Context; -import android.database.Cursor; import android.text.TextUtils; import android.util.Log; -import androidx.annotation.VisibleForTesting; -import de.danoeh.antennapod.core.R; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator; -import de.danoeh.antennapod.event.FeedItemEvent; import de.danoeh.antennapod.event.FeedListUpdateEvent; -import de.danoeh.antennapod.event.MessageEvent; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.feed.Feed; import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedPreferences; import de.danoeh.antennapod.net.sync.model.EpisodeAction; import de.danoeh.antennapod.storage.database.DBReader; import de.danoeh.antennapod.storage.database.PodDBAdapter; -import de.danoeh.antennapod.storage.database.mapper.FeedCursorMapper; import de.danoeh.antennapod.storage.preferences.UserPreferences; import org.greenrobot.eventbus.EventBus; @@ -29,116 +22,13 @@ import java.util.Collections; import java.util.Date; import java.util.Iterator; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; /** - * Provides methods for doing common tasks that use DBReader and DBWriter. + * Creates and updates feeds in the database. */ -public final class DBTasks { - private static final String TAG = "DBTasks"; - - /** - * Executor service used by the autodownloadUndownloadedEpisodes method. - */ - private static final ExecutorService autodownloadExec; - - private static AutomaticDownloadAlgorithm downloadAlgorithm = new AutomaticDownloadAlgorithm(); - - static { - autodownloadExec = Executors.newSingleThreadExecutor(r -> { - Thread t = new Thread(r); - t.setPriority(Thread.MIN_PRIORITY); - return t; - }); - } - - private DBTasks() { - } - - /** - * Removes the feed with the given download url. This method should NOT be executed on the GUI thread. - * - * @param context Used for accessing the db - * @param downloadUrl URL of the feed. - */ - public static void removeFeedWithDownloadUrl(Context context, String downloadUrl) { - PodDBAdapter adapter = PodDBAdapter.getInstance(); - adapter.open(); - Cursor cursor = adapter.getFeedCursorDownloadUrls(); - long feedID = 0; - if (cursor.moveToFirst()) { - do { - if (cursor.getString(1).equals(downloadUrl)) { - feedID = cursor.getLong(0); - } - } while (cursor.moveToNext()); - } - cursor.close(); - adapter.close(); - - if (feedID != 0) { - try { - DBWriter.deleteFeed(context, feedID).get(); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } else { - Log.w(TAG, "removeFeedWithDownloadUrl: Could not find feed with url: " + downloadUrl); - } - } - - /** - * Notifies the database about a missing FeedMedia file. This method will correct the FeedMedia object's - * values in the DB and send a FeedItemEvent. - */ - public static void notifyMissingFeedMediaFile(final Context context, final FeedMedia media) { - Log.i(TAG, "The feedmanager was notified about a missing episode. It will update its 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))); - } - - /** - * Looks for non-downloaded episodes in the queue or list of unread items and request a download if - * 1. Network is available - * 2. The device is charging or the user allows auto download on battery - * 3. There is free space in the episode cache - * This method is executed on an internal single thread executor. - * - * @param context Used for accessing the DB. - * @return A Future that can be used for waiting for the methods completion. - */ - public static Future<?> autodownloadUndownloadedItems(final Context context) { - Log.d(TAG, "autodownloadUndownloadedItems"); - return autodownloadExec.submit(downloadAlgorithm.autoDownloadUndownloadedItems(context)); - } - - /** - * For testing purpose only. - */ - @VisibleForTesting(otherwise = VisibleForTesting.NONE) - public static void setDownloadAlgorithm(AutomaticDownloadAlgorithm newDownloadAlgorithm) { - downloadAlgorithm = newDownloadAlgorithm; - } - - /** - * Removed downloaded episodes outside of the queue if the episode cache is full. Episodes with a smaller - * 'playbackCompletionDate'-value will be deleted first. - * <p/> - * This method should NOT be executed on the GUI thread. - * - * @param context Used for accessing the DB. - */ - public static void performAutoCleanup(final Context context) { - EpisodeCleanupAlgorithmFactory.build().performCleanup(context); - } +public abstract class FeedDatabaseWriter { + private static final String TAG = "FeedDbWriter"; private static Feed searchFeedByIdentifyingValueOrID(Feed feed) { if (feed.getId() != 0) { @@ -191,10 +81,6 @@ public final class DBTasks { * Adds new Feeds to the database or updates the old versions if they already exists. If another Feed with the same * identifying value already exists, this method will add new FeedItems from the new Feed to the existing Feed. * These FeedItems will be marked as unread with the exception of the most recent FeedItem. - * <p/> - * This method can update multiple feeds at once. Submitting a feed twice in the same method call can result in undefined behavior. - * <p/> - * This method should NOT be executed on the GUI thread. * * @param context Used for accessing the DB. * @param newFeed The new Feed object. @@ -373,70 +259,4 @@ public final class DBTasks { + "\nID: " + item.getItemIdentifier() + ((item.getMedia() == null) ? "" : "\nURL: " + item.getMedia().getDownloadUrl()); } - - /** - * Searches the FeedItems of a specific Feed for a given string. - * - * @param feedID The id of the feed whose items should be searched. - * @param query The search string. - * @return A FutureTask object that executes the search request - * and returns the search result as a List of FeedItems. - */ - public static FutureTask<List<FeedItem>> searchFeedItems(final long feedID, final String query) { - return new FutureTask<>(new QueryTask<List<FeedItem>>() { - @Override - public void execute(PodDBAdapter adapter) { - Cursor searchResult = adapter.searchItems(feedID, query); - List<FeedItem> items = DBReader.extractItemlistFromCursor(searchResult); - DBReader.loadAdditionalFeedItemListData(items); - setResult(items); - searchResult.close(); - } - }); - } - - public static FutureTask<List<Feed>> searchFeeds(final String query) { - return new FutureTask<>(new QueryTask<List<Feed>>() { - @Override - public void execute(PodDBAdapter adapter) { - Cursor cursor = adapter.searchFeeds(query); - List<Feed> items = new ArrayList<>(); - if (cursor.moveToFirst()) { - do { - items.add(FeedCursorMapper.convert(cursor)); - } while (cursor.moveToNext()); - } - setResult(items); - cursor.close(); - } - }); - } - - /** - * A runnable which should be used for database queries. The onCompletion - * method is executed on the database executor to handle Cursors correctly. - * This class automatically creates a PodDBAdapter object and closes it when - * it is no longer in use. - */ - abstract static class QueryTask<T> implements Callable<T> { - private T result; - - public QueryTask() { - } - - @Override - public T call() throws Exception { - PodDBAdapter adapter = PodDBAdapter.getInstance(); - adapter.open(); - execute(adapter); - adapter.close(); - return result; - } - - public abstract void execute(PodDBAdapter adapter); - - void setResult(T result) { - this.result = result; - } - } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java b/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java deleted file mode 100644 index 68ce7b7ef..000000000 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/FeedSearcher.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.danoeh.antennapod.core.storage; - -import androidx.annotation.NonNull; -import de.danoeh.antennapod.model.feed.Feed; -import de.danoeh.antennapod.model.feed.FeedItem; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.FutureTask; - -/** - * Performs search on Feeds and FeedItems. - */ -public class FeedSearcher { - private FeedSearcher() { - - } - - @NonNull - public static List<FeedItem> searchFeedItems(final String query, final long selectedFeed) { - try { - FutureTask<List<FeedItem>> itemSearchTask = DBTasks.searchFeedItems(selectedFeed, query); - itemSearchTask.run(); - return itemSearchTask.get(); - } catch (ExecutionException | InterruptedException e) { - e.printStackTrace(); - return Collections.emptyList(); - } - } - - @NonNull - public static List<Feed> searchFeeds(final String query) { - try { - FutureTask<List<Feed>> feedSearchTask = DBTasks.searchFeeds(query); - feedSearchTask.run(); - return feedSearchTask.get(); - } catch (ExecutionException | InterruptedException e) { - e.printStackTrace(); - return Collections.emptyList(); - } - } -} diff --git a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java index 2dca8a9e7..28ada01f8 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/sync/SyncService.java @@ -43,7 +43,7 @@ import de.danoeh.antennapod.event.SyncServiceEvent; import de.danoeh.antennapod.storage.preferences.UserPreferences; import de.danoeh.antennapod.net.common.AntennapodHttpClient; 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.storage.DBWriter; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueStorage; import de.danoeh.antennapod.core.util.FeedItemUtil; @@ -158,7 +158,7 @@ public class SyncService extends Worker { if (!UrlChecker.containsUrl(localSubscriptions, downloadUrl) && !queuedRemovedFeeds.contains(downloadUrl)) { Feed feed = new Feed(downloadUrl, null, "Unknown podcast"); feed.setItems(Collections.emptyList()); - Feed newFeed = DBTasks.updateFeed(getApplicationContext(), feed, false); + Feed newFeed = FeedDatabaseWriter.updateFeed(getApplicationContext(), feed, false); FeedUpdateManager.runOnce(getApplicationContext(), newFeed); } } @@ -166,7 +166,7 @@ public class SyncService extends Worker { // remove subscription if not just subscribed (again) for (String downloadUrl : subscriptionChanges.getRemoved()) { if (!queuedAddedFeeds.contains(downloadUrl)) { - DBTasks.removeFeedWithDownloadUrl(getApplicationContext(), downloadUrl); + DBWriter.removeFeedWithDownloadUrl(getApplicationContext(), downloadUrl); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java b/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java index 8097a4cb1..cafbde368 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/download/NetworkConnectionChangeHandler.java @@ -2,8 +2,8 @@ package de.danoeh.antennapod.core.util.download; import android.content.Context; import android.util.Log; +import de.danoeh.antennapod.core.storage.AutoDownloadManager; import de.danoeh.antennapod.net.download.serviceinterface.DownloadServiceInterface; -import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.net.common.NetworkUtils; public abstract class NetworkConnectionChangeHandler { @@ -17,7 +17,7 @@ public abstract class NetworkConnectionChangeHandler { public static void networkChangedDetected() { if (NetworkUtils.isAutoDownloadAllowed()) { Log.d(TAG, "auto-dl network available, starting auto-download"); - DBTasks.autodownloadUndownloadedItems(context); + AutoDownloadManager.autodownloadUndownloadedItems(context); } else { // if new network is Wi-Fi, finish ongoing downloads, // otherwise cancel all downloads if (NetworkUtils.isNetworkRestricted()) { |