summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-07-10 16:45:48 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-07-10 16:45:48 +0200
commit7088df944ceb23f2bbaa1eaeb93384c78adb4817 (patch)
treed3a02064c26cb2ee3c44982b63cad8c30ed33c14 /src/de
parentfc98cc8c79e6d9de2acbbb9b16a3f528aff02239 (diff)
downloadAntennaPod-7088df944ceb23f2bbaa1eaeb93384c78adb4817.zip
Fixed issue in the downloadObserver class that could cause a crash
Diffstat (limited to 'src/de')
-rw-r--r--src/de/podfetcher/activity/DownloadActivity.java3
-rw-r--r--src/de/podfetcher/asynctask/DownloadObserver.java74
2 files changed, 40 insertions, 37 deletions
diff --git a/src/de/podfetcher/activity/DownloadActivity.java b/src/de/podfetcher/activity/DownloadActivity.java
index c71c74743..dddda6f4a 100644
--- a/src/de/podfetcher/activity/DownloadActivity.java
+++ b/src/de/podfetcher/activity/DownloadActivity.java
@@ -179,7 +179,8 @@ public class DownloadActivity extends SherlockListActivity implements
@Override
public void onFinish() {
+ Log.d(TAG, "Observer has finished, clearing adapter");
dla.clear();
- dla.notifyDataSetChanged();
+ dla.notifyDataSetInvalidated();
}
}
diff --git a/src/de/podfetcher/asynctask/DownloadObserver.java b/src/de/podfetcher/asynctask/DownloadObserver.java
index 65d3e6129..9234539ef 100644
--- a/src/de/podfetcher/asynctask/DownloadObserver.java
+++ b/src/de/podfetcher/asynctask/DownloadObserver.java
@@ -50,8 +50,6 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
callback.onFinish();
}
}
-
-
@Override
protected void onPostExecute(Void result) {
@@ -94,40 +92,43 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
long downloadId = getDownloadStatus(cursor,
DownloadManager.COLUMN_ID);
FeedFile feedFile = requester.getFeedFile(downloadId);
- DownloadStatus status = findDownloadStatus(feedFile);
- if (status == null) {
- status = new DownloadStatus(feedFile);
- statusList.add(status);
- } else {
- unhandledItems.remove(status);
- }
-
- // refresh status
- int statusId = getDownloadStatus(cursor,
- DownloadManager.COLUMN_STATUS);
- getDownloadProgress(cursor, status);
- switch (statusId) {
- case DownloadManager.STATUS_SUCCESSFUL:
- status.statusMsg = R.string.download_successful;
- status.successful = true;
- status.done = true;
- case DownloadManager.STATUS_RUNNING:
- status.statusMsg = R.string.download_running;
- break;
- case DownloadManager.STATUS_FAILED:
- status.statusMsg = R.string.download_failed;
- requester.notifyDownloadService(context);
- status.successful = false;
- status.done = true;
- status.reason = getDownloadStatus(cursor,
- DownloadManager.COLUMN_REASON);
- case DownloadManager.STATUS_PENDING:
- status.statusMsg = R.string.download_pending;
- break;
- default:
- status.done = true;
- status.successful = false;
- status.statusMsg = R.string.download_cancelled_msg;
+ if (feedFile != null) {
+ DownloadStatus status = findDownloadStatus(feedFile);
+
+ if (status == null) {
+ status = new DownloadStatus(feedFile);
+ statusList.add(status);
+ } else {
+ unhandledItems.remove(status);
+ }
+
+ // refresh status
+ int statusId = getDownloadStatus(cursor,
+ DownloadManager.COLUMN_STATUS);
+ getDownloadProgress(cursor, status);
+ switch (statusId) {
+ case DownloadManager.STATUS_SUCCESSFUL:
+ status.statusMsg = R.string.download_successful;
+ status.successful = true;
+ status.done = true;
+ case DownloadManager.STATUS_RUNNING:
+ status.statusMsg = R.string.download_running;
+ break;
+ case DownloadManager.STATUS_FAILED:
+ status.statusMsg = R.string.download_failed;
+ requester.notifyDownloadService(context);
+ status.successful = false;
+ status.done = true;
+ status.reason = getDownloadStatus(cursor,
+ DownloadManager.COLUMN_REASON);
+ case DownloadManager.STATUS_PENDING:
+ status.statusMsg = R.string.download_pending;
+ break;
+ default:
+ status.done = true;
+ status.successful = false;
+ status.statusMsg = R.string.download_cancelled_msg;
+ }
}
} while (cursor.moveToNext());
}
@@ -203,6 +204,7 @@ public class DownloadObserver extends AsyncTask<Void, Void, Void> {
public interface Callback {
public void onProgressUpdate();
+
public void onFinish();
}