diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java | 17 | ||||
-rw-r--r-- | storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadResultCursorMapper.java (renamed from storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadStatusCursorMapper.java) | 16 | ||||
-rw-r--r-- | storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java | 5 |
3 files changed, 20 insertions, 18 deletions
diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java index 40933e8d1..21f12e223 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java @@ -35,7 +35,7 @@ import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedItemFilter; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedPreferences; -import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.feed.SortOrder; import de.danoeh.antennapod.storage.database.mapper.FeedItemFilterQuery; import de.danoeh.antennapod.storage.database.mapper.FeedItemSortQuery; @@ -757,7 +757,7 @@ public class PodDBAdapter { /** * Inserts or updates a download status. */ - public long setDownloadStatus(DownloadStatus status) { + public long setDownloadStatus(DownloadResult status) { ContentValues values = new ContentValues(); values.put(KEY_FEEDFILE, status.getFeedfileId()); values.put(KEY_FEEDFILETYPE, status.getFeedfileType()); @@ -1142,12 +1142,19 @@ public class PodDBAdapter { return db.rawQuery(query, null); } - public final Cursor getFeedItemCursorByMediaIds(final Long[] ids) { - if (ids.length > IN_OPERATOR_MAXIMUM) { + public final Cursor getFeedItemCursorByUrl(List<String> urls) { + if (urls.size() > IN_OPERATOR_MAXIMUM) { throw new IllegalArgumentException("number of IDs must not be larger than " + IN_OPERATOR_MAXIMUM); } + StringBuilder urlsString = new StringBuilder(); + for (int i = 0; i < urls.size(); i++) { + if (i != 0) { + urlsString.append(","); + } + urlsString.append(DatabaseUtils.sqlEscapeString(urls.get(i))); + } final String query = SELECT_FEED_ITEMS_AND_MEDIA - + " WHERE " + SELECT_KEY_MEDIA_ID + " IN (" + TextUtils.join(",", ids) + ")"; + + " WHERE " + KEY_DOWNLOAD_URL + " IN (" + urlsString + ")"; return db.rawQuery(query, null); } diff --git a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadStatusCursorMapper.java b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadResultCursorMapper.java index 1b8f3c726..d8f40d6a3 100644 --- a/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadStatusCursorMapper.java +++ b/storage/database/src/main/java/de/danoeh/antennapod/storage/database/mapper/DownloadResultCursorMapper.java @@ -2,21 +2,21 @@ package de.danoeh.antennapod.storage.database.mapper; import android.database.Cursor; import androidx.annotation.NonNull; -import de.danoeh.antennapod.model.download.DownloadStatus; +import de.danoeh.antennapod.model.download.DownloadResult; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.storage.database.PodDBAdapter; import java.util.Date; /** - * Converts a {@link Cursor} to a {@link DownloadStatus} object. + * Converts a {@link Cursor} to a {@link DownloadResult} object. */ -public abstract class DownloadStatusCursorMapper { +public abstract class DownloadResultCursorMapper { /** - * Create a {@link DownloadStatus} instance from a database row (cursor). + * Create a {@link DownloadResult} instance from a database row (cursor). */ @NonNull - public static DownloadStatus convert(@NonNull Cursor cursor) { + public static DownloadResult convert(@NonNull Cursor cursor) { int indexId = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_ID); int indexTitle = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_DOWNLOADSTATUS_TITLE); int indexFeedFile = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_FEEDFILE); @@ -26,10 +26,10 @@ public abstract class DownloadStatusCursorMapper { int indexCompletionDate = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_COMPLETION_DATE); int indexReasonDetailed = cursor.getColumnIndexOrThrow(PodDBAdapter.KEY_REASON_DETAILED); - return new DownloadStatus(cursor.getLong(indexId), cursor.getString(indexTitle), cursor.getLong(indexFeedFile), - cursor.getInt(indexFileFileType), cursor.getInt(indexSuccessful) > 0, false, true, + return new DownloadResult(cursor.getLong(indexId), cursor.getString(indexTitle), cursor.getLong(indexFeedFile), + cursor.getInt(indexFileFileType), cursor.getInt(indexSuccessful) > 0, DownloadError.fromCode(cursor.getInt(indexReason)), new Date(cursor.getLong(indexCompletionDate)), - cursor.getString(indexReasonDetailed), false); + cursor.getString(indexReasonDetailed)); } } diff --git a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java index 8a19300bb..f2b122fcc 100644 --- a/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java +++ b/storage/preferences/src/main/java/de/danoeh/antennapod/storage/preferences/UserPreferences.java @@ -90,7 +90,6 @@ public class UserPreferences { public static final String PREF_UPDATE_INTERVAL = "prefAutoUpdateIntervall"; private static final String PREF_MOBILE_UPDATE = "prefMobileUpdateTypes"; public static final String PREF_EPISODE_CLEANUP = "prefEpisodeCleanup"; - public static final String PREF_PARALLEL_DOWNLOADS = "prefParallelDownloads"; public static final String PREF_EPISODE_CACHE_SIZE = "prefEpisodeCacheSize"; public static final String PREF_ENABLE_AUTODL = "prefEnableAutoDl"; public static final String PREF_ENABLE_AUTODL_ON_BATTERY = "prefEnableAutoDownloadOnBattery"; @@ -525,10 +524,6 @@ public class UserPreferences { setAllowMobileFor("sync", allow); } - public static int getParallelDownloads() { - return Integer.parseInt(prefs.getString(PREF_PARALLEL_DOWNLOADS, "4")); - } - /** * Returns the capacity of the episode cache. This method will return the * negative integer EPISODE_CACHE_SIZE_UNLIMITED if the cache size is set to |