summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-08-17 14:53:14 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-08-17 14:53:14 +0200
commit28784ab1bf4ddeedfa8157129fcdbf2ecad2d39d (patch)
tree089ba9ae9c6b6ad7d9cee35fd1f456b2c0128841 /src/de
parent10576828602d4d6d8326a30044b062811c4ed483 (diff)
downloadAntennaPod-28784ab1bf4ddeedfa8157129fcdbf2ecad2d39d.zip
Fixed problems with the Downloadlog listadapter
Diffstat (limited to 'src/de')
-rw-r--r--src/de/danoeh/antennapod/activity/DownloadLogActivity.java34
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java29
2 files changed, 55 insertions, 8 deletions
diff --git a/src/de/danoeh/antennapod/activity/DownloadLogActivity.java b/src/de/danoeh/antennapod/activity/DownloadLogActivity.java
index 11a15accb..2c19b5649 100644
--- a/src/de/danoeh/antennapod/activity/DownloadLogActivity.java
+++ b/src/de/danoeh/antennapod/activity/DownloadLogActivity.java
@@ -1,5 +1,9 @@
package de.danoeh.antennapod.activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockListActivity;
@@ -9,7 +13,10 @@ import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
import de.danoeh.antennapod.feed.FeedManager;
-/** Displays completed and failed downloads in a list. The data comes from the FeedManager. */
+/**
+ * Displays completed and failed downloads in a list. The data comes from the
+ * FeedManager.
+ */
public class DownloadLogActivity extends SherlockListActivity {
private static final String TAG = "DownloadLogActivity";
@@ -27,6 +34,20 @@ public class DownloadLogActivity extends SherlockListActivity {
}
@Override
+ protected void onPause() {
+ super.onPause();
+ unregisterReceiver(contentUpdate);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ registerReceiver(contentUpdate, new IntentFilter(
+ FeedManager.ACTION_DOWNLOADLOG_UPDATE));
+ dla.notifyDataSetChanged();
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@@ -43,4 +64,15 @@ public class DownloadLogActivity extends SherlockListActivity {
return true;
}
+ private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction()
+ .equals(FeedManager.ACTION_DOWNLOADLOG_UPDATE)) {
+ dla.notifyDataSetChanged();
+ }
+ }
+ };
+
}
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index d49e73e0c..f0e119b64 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -37,6 +37,7 @@ public class FeedManager {
public static final String ACITON_FEED_LIST_UPDATE = "de.danoeh.antennapod.action.feed.feedlistUpdate";
public static final String ACTION_UNREAD_ITEMS_UPDATE = "de.danoeh.antennapod.action.feed.unreadItemsUpdate";
public static final String ACTION_QUEUE_UPDATE = "de.danoeh.antennapod.action.feed.queueUpdate";
+ public static final String ACTION_DOWNLOADLOG_UPDATE = "de.danoeh.antennapod.action.feed.downloadLogUpdate";
public static final String EXTRA_FEED_ITEM_ID = "de.danoeh.antennapod.extra.feed.feedItemId";
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feed.feedId";
@@ -332,20 +333,34 @@ public class FeedManager {
public void addDownloadStatus(final Context context,
final DownloadStatus status) {
- downloadLog.add(status);
- dbExec.execute(new Runnable() {
+ contentChanger.post(new Runnable() {
@Override
public void run() {
- PodDBAdapter adapter = new PodDBAdapter(context);
- adapter.open();
+ downloadLog.add(status);
+ final DownloadStatus removedStatus;
if (downloadLog.size() > DOWNLOAD_LOG_SIZE) {
- adapter.removeDownloadStatus(downloadLog.remove(0));
+ removedStatus = downloadLog.remove(0);
+ } else {
+ removedStatus = null;
}
- adapter.setDownloadStatus(status);
- adapter.close();
+ context.sendBroadcast(new Intent(ACTION_DOWNLOADLOG_UPDATE));
+ dbExec.execute(new Runnable() {
+
+ @Override
+ public void run() {
+ PodDBAdapter adapter = new PodDBAdapter(context);
+ adapter.open();
+ if (removedStatus != null) {
+ adapter.removeDownloadStatus(removedStatus);
+ }
+ adapter.setDownloadStatus(status);
+ adapter.close();
+ }
+ });
}
});
+
}
public void addQueueItem(final Context context, final FeedItem item) {