summaryrefslogtreecommitdiff
path: root/core/src/main/java/de
diff options
context:
space:
mode:
authorNathan Mascitelli <mascitelli.nathan@gmail.com>2020-02-07 10:55:11 -0500
committerNathan Mascitelli <mascitelli.nathan@gmail.com>2020-03-22 16:19:31 -0400
commit895af777cf761aa0edba7b89dd04318ab6ede1d2 (patch)
tree24d1d513e0fc88d4d62ab14cce217cf1841099f2 /core/src/main/java/de
parentb5244bbe99e423bfe5a2377728a086343a4c2fff (diff)
downloadAntennaPod-895af777cf761aa0edba7b89dd04318ab6ede1d2.zip
Add generatedBySystem to DownloadStatus
Diffstat (limited to 'core/src/main/java/de')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java20
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java6
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java2
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java1
8 files changed, 29 insertions, 14 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
index 90f4f0ff4..09ca15712 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadRequest.java
@@ -265,6 +265,8 @@ public class DownloadRequest implements Parcelable {
return mediaEnqueued;
}
+ public boolean isGeneratedBySystem() { return generatedBySystem; }
+
/**
* Set to true if the media is enqueued because of this download.
* The state is helpful if the download is cancelled, and undoing the enqueue is needed.
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
index 675115bc7..2ff4035c9 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadStatus.java
@@ -41,6 +41,7 @@ public class DownloadStatus {
* FEEDFILETYPE_FEEDIMAGE or FEEDFILETYPE_FEEDMEDIA
*/
private final int feedfileType;
+ private final boolean generatedBySystem;
// ------------------------------------ NOT STORED IN DB
private boolean done;
@@ -49,7 +50,7 @@ public class DownloadStatus {
/** Constructor for restoring Download status entries from DB. */
private DownloadStatus(long id, String title, long feedfileId,
int feedfileType, boolean successful, DownloadError reason,
- Date completionDate, String reasonDetailed) {
+ Date completionDate, String reasonDetailed, boolean generatedBySystem) {
this.id = id;
this.title = title;
this.done = true;
@@ -59,10 +60,11 @@ public class DownloadStatus {
this.completionDate = (Date) completionDate.clone();
this.reasonDetailed = reasonDetailed;
this.feedfileType = feedfileType;
+ this.generatedBySystem = generatedBySystem;
}
public DownloadStatus(@NonNull DownloadRequest request, DownloadError reason,
- boolean successful, boolean cancelled, String reasonDetailed) {
+ boolean successful, boolean cancelled, String reasonDetailed, boolean generatedBySystem) {
this.title = request.getTitle();
this.feedfileId = request.getFeedfileId();
this.feedfileType = request.getFeedfileType();
@@ -71,11 +73,12 @@ public class DownloadStatus {
this.cancelled = cancelled;
this.reasonDetailed = reasonDetailed;
this.completionDate = new Date();
+ this.generatedBySystem = generatedBySystem;
}
/** Constructor for creating new completed downloads. */
public DownloadStatus(@NonNull FeedFile feedfile, String title, DownloadError reason,
- boolean successful, String reasonDetailed) {
+ boolean successful, String reasonDetailed, boolean generatedBySystem) {
this.title = title;
this.done = true;
this.feedfileId = feedfile.getId();
@@ -84,11 +87,12 @@ public class DownloadStatus {
this.successful = successful;
this.completionDate = new Date();
this.reasonDetailed = reasonDetailed;
+ this.generatedBySystem = generatedBySystem;
}
/** Constructor for creating new completed downloads. */
public DownloadStatus(long feedfileId, int feedfileType, String title,
- DownloadError reason, boolean successful, String reasonDetailed) {
+ DownloadError reason, boolean successful, String reasonDetailed, boolean generatedBySystem) {
this.title = title;
this.done = true;
this.feedfileId = feedfileId;
@@ -97,6 +101,7 @@ public class DownloadStatus {
this.successful = successful;
this.completionDate = new Date();
this.reasonDetailed = reasonDetailed;
+ this.generatedBySystem = generatedBySystem;
}
public static DownloadStatus fromCursor(Cursor cursor) {
@@ -108,6 +113,7 @@ public class DownloadStatus {
int indexReason = cursor.getColumnIndex(PodDBAdapter.KEY_REASON);
int indexCompletionDate = cursor.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE);
int indexReasonDetailed = cursor.getColumnIndex(PodDBAdapter.KEY_REASON_DETAILED);
+ int indexGeneratedBySystem = cursor.getColumnIndex(PodDBAdapter.KEY_GENERATED_BY_SYSTEM);
long id = cursor.getLong(indexId);
String title = cursor.getString(indexTitle);
@@ -117,10 +123,12 @@ public class DownloadStatus {
int reason = cursor.getInt(indexReason);
Date completionDate = new Date(cursor.getLong(indexCompletionDate));
String reasonDetailed = cursor.getString(indexReasonDetailed);
+ boolean generatedBySystem = cursor.getInt(indexGeneratedBySystem) > 0;
+
return new DownloadStatus(id, title, feedfileId,
feedfileType, successful, DownloadError.fromCode(reason), completionDate,
- reasonDetailed);
+ reasonDetailed, generatedBySystem);
}
@Override
@@ -165,6 +173,8 @@ public class DownloadStatus {
return feedfileType;
}
+ public boolean isGeneratedBySystem() { return generatedBySystem; }
+
public boolean isDone() {
return done;
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java
index 2a0989d23..f5bf0d1d1 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/Downloader.java
@@ -29,7 +29,7 @@ public abstract class Downloader implements Callable<Downloader> {
this.request = request;
this.request.setStatusMsg(R.string.download_pending);
this.cancelled = false;
- this.result = new DownloadStatus(request, null, false, false, null);
+ this.result = new DownloadStatus(request, null, false, false, null, request.isGeneratedBySystem());
}
protected abstract void download();
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
index c418db214..552fa3057 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/FeedParserTask.java
@@ -78,12 +78,12 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
}
if (successful) {
- downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(),
- DownloadError.SUCCESS, successful, reasonDetailed);
+ downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), DownloadError.SUCCESS,
+ successful, reasonDetailed, request.isGeneratedBySystem());
return result;
} else {
- downloadStatus = new DownloadStatus(feed, request.getTitle(),
- reason, successful, reasonDetailed);
+ downloadStatus = new DownloadStatus(feed, request.getTitle(), reason, successful, reasonDetailed,
+ request.isGeneratedBySystem());
return null;
}
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java
index 9ecabd14b..4379fe6de 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/handler/MediaDownloadedHandler.java
@@ -96,7 +96,7 @@ public class MediaDownloadedHandler implements Runnable {
} catch (ExecutionException e) {
Log.e(TAG, "ExecutionException in MediaHandlerThread: " + e.getMessage());
updatedStatus = new DownloadStatus(media, media.getEpisodeTitle(),
- DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage());
+ DownloadError.ERROR_DB_ACCESS_ERROR, false, e.getMessage(), false);
}
if (GpodnetPreferences.loggedIn() && item != null) {
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
index 9360f7c4b..6c562b972 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java
@@ -151,7 +151,8 @@ public final class DBTasks {
new DownloadStatus(feed, feed
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR, false, e
- .getMessage()
+ .getMessage(),
+ true
)
);
}
@@ -175,7 +176,8 @@ public final class DBTasks {
new DownloadStatus(feed, feed
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR, false, e
- .getMessage()
+ .getMessage(),
+ true
)
);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
index c91029040..9b871da0d 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DownloadRequester.java
@@ -247,7 +247,7 @@ public class DownloadRequester implements DownloadStateProvider {
.getMedia()
.getHumanReadableIdentifier(),
DownloadError.ERROR_REQUEST_ERROR,
- false, e.getMessage()
+ false, e.getMessage(), generatedBySystem
)
);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
index af6a8ef81..f091874c6 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java
@@ -110,6 +110,7 @@ public class PodDBAdapter {
public static final String KEY_INCLUDE_FILTER = "include_filter";
public static final String KEY_EXCLUDE_FILTER = "exclude_filter";
public static final String KEY_FEED_PLAYBACK_SPEED = "feed_playback_speed";
+ public static final String KEY_GENERATED_BY_SYSTEM = "generated_by_system";
// Table names
static final String TABLE_NAME_FEEDS = "Feeds";