Changed behavior of download reports

This commit is contained in:
daniel oeh 2012-10-04 13:02:38 +02:00
parent c042145875
commit cd7cb59175
1 changed files with 4 additions and 12 deletions

View File

@ -44,7 +44,7 @@ import android.webkit.URLUtil;
import de.danoeh.antennapod.AppConfig; import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R; import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.DownloadActivity; import de.danoeh.antennapod.activity.DownloadActivity;
import de.danoeh.antennapod.activity.MainActivity; import de.danoeh.antennapod.activity.DownloadLogActivity;
import de.danoeh.antennapod.asynctask.DownloadStatus; import de.danoeh.antennapod.asynctask.DownloadStatus;
import de.danoeh.antennapod.feed.Feed; import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedFile; import de.danoeh.antennapod.feed.FeedFile;
@ -416,17 +416,13 @@ public class DownloadService extends Service {
private void updateReport() { private void updateReport() {
// check if report should be created // check if report should be created
boolean createReport = false; boolean createReport = false;
int successfulFeedDownloads = 0;
int successfulDownloads = 0; int successfulDownloads = 0;
int failedDownloads = 0; int failedDownloads = 0;
// a download report is created if at least one download has failed
// (excluding failed image downloads)
for (DownloadStatus status : completedDownloads) { for (DownloadStatus status : completedDownloads) {
if (status.isSuccessful()) { if (status.isSuccessful()) {
if (status.getFeedFile().getClass() == Feed.class) {
successfulFeedDownloads++;
} else if (status.getFeedFile().getClass() == FeedMedia.class) {
createReport = true;
}
successfulDownloads++; successfulDownloads++;
} else if (!status.isCancelled()) { } else if (!status.isCancelled()) {
if (status.getFeedFile().getClass() != FeedImage.class) { if (status.getFeedFile().getClass() != FeedImage.class) {
@ -436,10 +432,6 @@ public class DownloadService extends Service {
} }
} }
if (successfulFeedDownloads > 1) {
createReport = true;
}
if (createReport) { if (createReport) {
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Creating report"); Log.d(TAG, "Creating report");
@ -459,7 +451,7 @@ public class DownloadService extends Service {
android.R.drawable.stat_notify_sync)) android.R.drawable.stat_notify_sync))
.setContentIntent( .setContentIntent(
PendingIntent.getActivity(this, 0, new Intent(this, PendingIntent.getActivity(this, 0, new Intent(this,
MainActivity.class), 0)) DownloadLogActivity.class), 0))
.setAutoCancel(true).getNotification(); .setAutoCancel(true).getNotification();
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(REPORT_ID, notification); nm.notify(REPORT_ID, notification);