summaryrefslogtreecommitdiff
path: root/storage/database
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2023-05-05 23:09:03 +0200
committerGitHub <noreply@github.com>2023-05-05 23:09:03 +0200
commit6d7bfef8a5fe8180f13904739996bb2b8de8a0d4 (patch)
tree84f246b74fe7254678788e9f206d81d1a30ffa5e /storage/database
parent4c286931cd2dbd9038022f808f9d8a73ccbb6759 (diff)
downloadAntennaPod-6d7bfef8a5fe8180f13904739996bb2b8de8a0d4.zip
Download Service Rewrite (#6420)
Diffstat (limited to 'storage/database')
-rw-r--r--storage/database/src/main/java/de/danoeh/antennapod/storage/database/PodDBAdapter.java17
-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
2 files changed, 20 insertions, 13 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));
}
}