Add generatedBySystem to DownloadStatus
This commit is contained in:
parent
b5244bbe99
commit
895af777cf
@ -265,6 +265,8 @@ public class DownloadRequest implements Parcelable {
|
|||||||
return mediaEnqueued;
|
return mediaEnqueued;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGeneratedBySystem() { return generatedBySystem; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to true if the media is enqueued because of this download.
|
* 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.
|
* 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
|
* FEEDFILETYPE_FEEDIMAGE or FEEDFILETYPE_FEEDMEDIA
|
||||||
*/
|
*/
|
||||||
private final int feedfileType;
|
private final int feedfileType;
|
||||||
|
private final boolean generatedBySystem;
|
||||||
|
|
||||||
// ------------------------------------ NOT STORED IN DB
|
// ------------------------------------ NOT STORED IN DB
|
||||||
private boolean done;
|
private boolean done;
|
||||||
@ -49,7 +50,7 @@ public class DownloadStatus {
|
|||||||
/** Constructor for restoring Download status entries from DB. */
|
/** Constructor for restoring Download status entries from DB. */
|
||||||
private DownloadStatus(long id, String title, long feedfileId,
|
private DownloadStatus(long id, String title, long feedfileId,
|
||||||
int feedfileType, boolean successful, DownloadError reason,
|
int feedfileType, boolean successful, DownloadError reason,
|
||||||
Date completionDate, String reasonDetailed) {
|
Date completionDate, String reasonDetailed, boolean generatedBySystem) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.done = true;
|
this.done = true;
|
||||||
@ -59,10 +60,11 @@ public class DownloadStatus {
|
|||||||
this.completionDate = (Date) completionDate.clone();
|
this.completionDate = (Date) completionDate.clone();
|
||||||
this.reasonDetailed = reasonDetailed;
|
this.reasonDetailed = reasonDetailed;
|
||||||
this.feedfileType = feedfileType;
|
this.feedfileType = feedfileType;
|
||||||
|
this.generatedBySystem = generatedBySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadStatus(@NonNull DownloadRequest request, DownloadError reason,
|
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.title = request.getTitle();
|
||||||
this.feedfileId = request.getFeedfileId();
|
this.feedfileId = request.getFeedfileId();
|
||||||
this.feedfileType = request.getFeedfileType();
|
this.feedfileType = request.getFeedfileType();
|
||||||
@ -71,11 +73,12 @@ public class DownloadStatus {
|
|||||||
this.cancelled = cancelled;
|
this.cancelled = cancelled;
|
||||||
this.reasonDetailed = reasonDetailed;
|
this.reasonDetailed = reasonDetailed;
|
||||||
this.completionDate = new Date();
|
this.completionDate = new Date();
|
||||||
|
this.generatedBySystem = generatedBySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Constructor for creating new completed downloads. */
|
/** Constructor for creating new completed downloads. */
|
||||||
public DownloadStatus(@NonNull FeedFile feedfile, String title, DownloadError reason,
|
public DownloadStatus(@NonNull FeedFile feedfile, String title, DownloadError reason,
|
||||||
boolean successful, String reasonDetailed) {
|
boolean successful, String reasonDetailed, boolean generatedBySystem) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.done = true;
|
this.done = true;
|
||||||
this.feedfileId = feedfile.getId();
|
this.feedfileId = feedfile.getId();
|
||||||
@ -84,11 +87,12 @@ public class DownloadStatus {
|
|||||||
this.successful = successful;
|
this.successful = successful;
|
||||||
this.completionDate = new Date();
|
this.completionDate = new Date();
|
||||||
this.reasonDetailed = reasonDetailed;
|
this.reasonDetailed = reasonDetailed;
|
||||||
|
this.generatedBySystem = generatedBySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Constructor for creating new completed downloads. */
|
/** Constructor for creating new completed downloads. */
|
||||||
public DownloadStatus(long feedfileId, int feedfileType, String title,
|
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.title = title;
|
||||||
this.done = true;
|
this.done = true;
|
||||||
this.feedfileId = feedfileId;
|
this.feedfileId = feedfileId;
|
||||||
@ -97,6 +101,7 @@ public class DownloadStatus {
|
|||||||
this.successful = successful;
|
this.successful = successful;
|
||||||
this.completionDate = new Date();
|
this.completionDate = new Date();
|
||||||
this.reasonDetailed = reasonDetailed;
|
this.reasonDetailed = reasonDetailed;
|
||||||
|
this.generatedBySystem = generatedBySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadStatus fromCursor(Cursor cursor) {
|
public static DownloadStatus fromCursor(Cursor cursor) {
|
||||||
@ -108,6 +113,7 @@ public class DownloadStatus {
|
|||||||
int indexReason = cursor.getColumnIndex(PodDBAdapter.KEY_REASON);
|
int indexReason = cursor.getColumnIndex(PodDBAdapter.KEY_REASON);
|
||||||
int indexCompletionDate = cursor.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE);
|
int indexCompletionDate = cursor.getColumnIndex(PodDBAdapter.KEY_COMPLETION_DATE);
|
||||||
int indexReasonDetailed = cursor.getColumnIndex(PodDBAdapter.KEY_REASON_DETAILED);
|
int indexReasonDetailed = cursor.getColumnIndex(PodDBAdapter.KEY_REASON_DETAILED);
|
||||||
|
int indexGeneratedBySystem = cursor.getColumnIndex(PodDBAdapter.KEY_GENERATED_BY_SYSTEM);
|
||||||
|
|
||||||
long id = cursor.getLong(indexId);
|
long id = cursor.getLong(indexId);
|
||||||
String title = cursor.getString(indexTitle);
|
String title = cursor.getString(indexTitle);
|
||||||
@ -117,10 +123,12 @@ public class DownloadStatus {
|
|||||||
int reason = cursor.getInt(indexReason);
|
int reason = cursor.getInt(indexReason);
|
||||||
Date completionDate = new Date(cursor.getLong(indexCompletionDate));
|
Date completionDate = new Date(cursor.getLong(indexCompletionDate));
|
||||||
String reasonDetailed = cursor.getString(indexReasonDetailed);
|
String reasonDetailed = cursor.getString(indexReasonDetailed);
|
||||||
|
boolean generatedBySystem = cursor.getInt(indexGeneratedBySystem) > 0;
|
||||||
|
|
||||||
|
|
||||||
return new DownloadStatus(id, title, feedfileId,
|
return new DownloadStatus(id, title, feedfileId,
|
||||||
feedfileType, successful, DownloadError.fromCode(reason), completionDate,
|
feedfileType, successful, DownloadError.fromCode(reason), completionDate,
|
||||||
reasonDetailed);
|
reasonDetailed, generatedBySystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,6 +173,8 @@ public class DownloadStatus {
|
|||||||
return feedfileType;
|
return feedfileType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isGeneratedBySystem() { return generatedBySystem; }
|
||||||
|
|
||||||
public boolean isDone() {
|
public boolean isDone() {
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public abstract class Downloader implements Callable<Downloader> {
|
|||||||
this.request = request;
|
this.request = request;
|
||||||
this.request.setStatusMsg(R.string.download_pending);
|
this.request.setStatusMsg(R.string.download_pending);
|
||||||
this.cancelled = false;
|
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();
|
protected abstract void download();
|
||||||
|
@ -78,12 +78,12 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (successful) {
|
if (successful) {
|
||||||
downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(),
|
downloadStatus = new DownloadStatus(feed, feed.getHumanReadableIdentifier(), DownloadError.SUCCESS,
|
||||||
DownloadError.SUCCESS, successful, reasonDetailed);
|
successful, reasonDetailed, request.isGeneratedBySystem());
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
downloadStatus = new DownloadStatus(feed, request.getTitle(),
|
downloadStatus = new DownloadStatus(feed, request.getTitle(), reason, successful, reasonDetailed,
|
||||||
reason, successful, reasonDetailed);
|
request.isGeneratedBySystem());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class MediaDownloadedHandler implements Runnable {
|
|||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
Log.e(TAG, "ExecutionException in MediaHandlerThread: " + e.getMessage());
|
Log.e(TAG, "ExecutionException in MediaHandlerThread: " + e.getMessage());
|
||||||
updatedStatus = new DownloadStatus(media, media.getEpisodeTitle(),
|
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) {
|
if (GpodnetPreferences.loggedIn() && item != null) {
|
||||||
|
@ -151,7 +151,8 @@ public final class DBTasks {
|
|||||||
new DownloadStatus(feed, feed
|
new DownloadStatus(feed, feed
|
||||||
.getHumanReadableIdentifier(),
|
.getHumanReadableIdentifier(),
|
||||||
DownloadError.ERROR_REQUEST_ERROR, false, e
|
DownloadError.ERROR_REQUEST_ERROR, false, e
|
||||||
.getMessage()
|
.getMessage(),
|
||||||
|
true
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -175,7 +176,8 @@ public final class DBTasks {
|
|||||||
new DownloadStatus(feed, feed
|
new DownloadStatus(feed, feed
|
||||||
.getHumanReadableIdentifier(),
|
.getHumanReadableIdentifier(),
|
||||||
DownloadError.ERROR_REQUEST_ERROR, false, e
|
DownloadError.ERROR_REQUEST_ERROR, false, e
|
||||||
.getMessage()
|
.getMessage(),
|
||||||
|
true
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class DownloadRequester implements DownloadStateProvider {
|
|||||||
.getMedia()
|
.getMedia()
|
||||||
.getHumanReadableIdentifier(),
|
.getHumanReadableIdentifier(),
|
||||||
DownloadError.ERROR_REQUEST_ERROR,
|
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_INCLUDE_FILTER = "include_filter";
|
||||||
public static final String KEY_EXCLUDE_FILTER = "exclude_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_FEED_PLAYBACK_SPEED = "feed_playback_speed";
|
||||||
|
public static final String KEY_GENERATED_BY_SYSTEM = "generated_by_system";
|
||||||
|
|
||||||
// Table names
|
// Table names
|
||||||
static final String TABLE_NAME_FEEDS = "Feeds";
|
static final String TABLE_NAME_FEEDS = "Feeds";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user