Add generatedBySystem to DownloadStatus
This commit is contained in:
parent
b5244bbe99
commit
895af777cf
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ public class DownloadRequester implements DownloadStateProvider {
|
|||
.getMedia()
|
||||
.getHumanReadableIdentifier(),
|
||||
DownloadError.ERROR_REQUEST_ERROR,
|
||||
false, e.getMessage()
|
||||
false, e.getMessage(), generatedBySystem
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue