summaryrefslogtreecommitdiff
path: root/src/de/podfetcher/storage
diff options
context:
space:
mode:
authorDaniel Oeh <daniel@danielpc.(none)>2012-05-27 23:52:30 +0200
committerDaniel Oeh <daniel@danielpc.(none)>2012-05-27 23:52:30 +0200
commit593af6970a5bf8e1617caec1ba71a7d990a25a2a (patch)
treeb01bb71b0687499d10c873e0d124d84557f77e0e /src/de/podfetcher/storage
parent4b5160c30c87972026e65876ee3a5707895f0c19 (diff)
downloadAntennaPod-593af6970a5bf8e1617caec1ba71a7d990a25a2a.zip
Fixed DownloadObserver
Diffstat (limited to 'src/de/podfetcher/storage')
-rw-r--r--src/de/podfetcher/storage/DownloadRequester.java105
1 files changed, 0 insertions, 105 deletions
diff --git a/src/de/podfetcher/storage/DownloadRequester.java b/src/de/podfetcher/storage/DownloadRequester.java
index d18d442fe..fabe1bfb5 100644
--- a/src/de/podfetcher/storage/DownloadRequester.java
+++ b/src/de/podfetcher/storage/DownloadRequester.java
@@ -160,111 +160,6 @@ public class DownloadRequester {
return "image-" + NumberGenerator.generateLong(image.getDownload_url());
}
- /* ------------ Methods for communicating with the DownloadManager ------------- */
-
-
- /** observes the status of a specific Download */
- public static class DownloadObserver extends Thread {
- private static final String TAG = "DownloadObserver";
- long id;
- Context context;
- Callable client;
- long waiting_intervall;
- private volatile int result;
- private volatile boolean done;
- private Cursor cursor;
- private final long DEFAULT_WAITING_INTERVALL = 500L;
- private DownloadRequester requester;
-
- public DownloadObserver(long id, Context c) {
- this.id = id;
- this.context = c;
- this.client = client;
- this.waiting_intervall = DEFAULT_WAITING_INTERVALL;
- done = false;
- requester = DownloadRequester.getInstance();
- }
-
- public void run() {
- Log.d(TAG, "Thread started.");
- while(!isInterrupted()) {
- cursor = getDownloadCursor();
- int status = getDownloadStatus(cursor, DownloadManager.COLUMN_STATUS);
- switch(status) {
- case DownloadManager.STATUS_SUCCESSFUL:
- Log.d(TAG, "Download was successful.");
- done = true;
- result = R.string.download_successful;
- break;
- case DownloadManager.STATUS_RUNNING:
- Log.d(TAG, "Download is running.");
- result = R.string.download_running;
- break;
- case DownloadManager.STATUS_FAILED:
- Log.d(TAG, "Download failed.");
- result = R.string.download_failed;
- done = true;
- requester.notifyDownloadService(context);
- break;
- case DownloadManager.STATUS_PENDING:
- Log.d(TAG, "Download pending.");
- result = R.string.download_pending;
- break;
-
- }
- try {
- client.call();
- }catch (Exception e) {
- Log.e(TAG, "Error happened when calling client: " + e.getMessage());
- }
-
- if(done) {
- break;
- } else {
- try {
- sleep(waiting_intervall);
- }catch (InterruptedException e) {
- Log.w(TAG, "Thread was interrupted while waiting.");
- }
- }
- }
- Log.d(TAG, "Thread stopped.");
- }
-
- public void setClient(Callable callable) {
- this.client = callable;
- }
-
- public Cursor getDownloadCursor() {
- DownloadManager.Query query = buildQuery(id);
- DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
-
- Cursor result = manager.query(query);
- return result;
- }
- public int getDownloadStatus(Cursor c, String column) {
- if(c.moveToFirst()) {
- int status = c.getInt(c.getColumnIndex(column));
- return status;
- } else {
- return -1;
- }
- }
-
- private DownloadManager.Query buildQuery(long id) {
- DownloadManager.Query query = new DownloadManager.Query();
- query.setFilterById(id);
- return query;
- }
-
- public int getResult() {
- return result;
- }
-
- public boolean getDone() {
- return done;
- }
- }
/* ------------ Methods for communicating with the DownloadService ------------- */
private Messenger mService = null;