Merge pull request #5810 from ByteHamster/ensure-status-nonnull
Ensure that download status is never null
This commit is contained in:
commit
433314d1ee
|
@ -546,7 +546,7 @@ public class DownloadService extends Service {
|
|||
*
|
||||
* @param status the download that is going to be saved
|
||||
*/
|
||||
private void saveDownloadStatus(DownloadStatus status) {
|
||||
private void saveDownloadStatus(@NonNull DownloadStatus status) {
|
||||
reportQueue.add(status);
|
||||
DBWriter.addDownloadStatus(status);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.danoeh.antennapod.core.service.download.handler;
|
||||
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedPreferences;
|
||||
|
@ -27,6 +28,8 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
|||
|
||||
public FeedParserTask(DownloadRequest request) {
|
||||
this.request = request;
|
||||
downloadStatus = new DownloadStatus(request, DownloadError.ERROR_REQUEST_ERROR,
|
||||
false, false, "Unknown error: Status not set");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,6 +111,7 @@ public class FeedParserTask implements Callable<FeedHandlerResult> {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public DownloadStatus getDownloadStatus() {
|
||||
return downloadStatus;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.download.handler;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import de.danoeh.antennapod.model.feed.Feed;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadRequest;
|
||||
import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
||||
|
@ -9,22 +10,19 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
|||
import de.danoeh.antennapod.parser.feed.FeedHandlerResult;
|
||||
|
||||
public class FeedSyncTask {
|
||||
private static final String TAG = "FeedParserTask";
|
||||
private final DownloadRequest request;
|
||||
private final Context context;
|
||||
private DownloadStatus downloadStatus;
|
||||
private Feed savedFeed;
|
||||
private final FeedParserTask task;
|
||||
|
||||
public FeedSyncTask(Context context, DownloadRequest request) {
|
||||
this.request = request;
|
||||
this.context = context;
|
||||
this.task = new FeedParserTask(request);
|
||||
}
|
||||
|
||||
public boolean run() {
|
||||
FeedParserTask task = new FeedParserTask(request);
|
||||
FeedHandlerResult result = task.call();
|
||||
downloadStatus = task.getDownloadStatus();
|
||||
|
||||
if (!task.isSuccessful()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -40,8 +38,9 @@ public class FeedSyncTask {
|
|||
return true;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public DownloadStatus getDownloadStatus() {
|
||||
return downloadStatus;
|
||||
return task.getDownloadStatus();
|
||||
}
|
||||
|
||||
public Feed getSavedFeed() {
|
||||
|
|
|
@ -29,20 +29,18 @@ import de.danoeh.antennapod.net.sync.model.EpisodeAction;
|
|||
public class MediaDownloadedHandler implements Runnable {
|
||||
private static final String TAG = "MediaDownloadedHandler";
|
||||
private final DownloadRequest request;
|
||||
private final DownloadStatus status;
|
||||
private final Context context;
|
||||
private DownloadStatus updatedStatus;
|
||||
|
||||
public MediaDownloadedHandler(@NonNull Context context, @NonNull DownloadStatus status,
|
||||
@NonNull DownloadRequest request) {
|
||||
this.status = status;
|
||||
this.request = request;
|
||||
this.context = context;
|
||||
this.updatedStatus = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updatedStatus = status;
|
||||
FeedMedia media = DBReader.getFeedMedia(request.getFeedfileId());
|
||||
if (media == null) {
|
||||
Log.e(TAG, "Could not find downloaded media object in database");
|
||||
|
@ -108,6 +106,7 @@ public class MediaDownloadedHandler implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public DownloadStatus getUpdatedStatus() {
|
||||
return updatedStatus;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue