summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/feed
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-12-18 17:53:37 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2012-12-18 17:53:37 +0100
commit7b4fe1a99e4b72987c1bf4b01898e613685ba9ca (patch)
treeeef84f388a26f11244f2a44883c0240c2075c4bb /src/de/danoeh/antennapod/feed
parentaa7e58dc42f05f94954a0a4ca6f03420d4c97a74 (diff)
downloadAntennaPod-7b4fe1a99e4b72987c1bf4b01898e613685ba9ca.zip
FeedManager now updates feeds and feeditem attributes
Diffstat (limited to 'src/de/danoeh/antennapod/feed')
-rw-r--r--src/de/danoeh/antennapod/feed/FeedItem.java6
-rw-r--r--src/de/danoeh/antennapod/feed/FeedManager.java50
2 files changed, 37 insertions, 19 deletions
diff --git a/src/de/danoeh/antennapod/feed/FeedItem.java b/src/de/danoeh/antennapod/feed/FeedItem.java
index 94c90295c..06fdc4292 100644
--- a/src/de/danoeh/antennapod/feed/FeedItem.java
+++ b/src/de/danoeh/antennapod/feed/FeedItem.java
@@ -61,8 +61,10 @@ public class FeedItem extends FeedComponent {
pubDate = other.pubDate;
}
if (other.media != null) {
- if (media == null || media.compareWithOther(media)) {
- media.updateFromOther(other.media);
+ if (media == null) {
+ media = other.media;
+ } else if (media.compareWithOther(other)) {
+ media.updateFromOther(other);
}
}
if (other.paymentLink != null) {
diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java
index 9888febc9..338574cff 100644
--- a/src/de/danoeh/antennapod/feed/FeedManager.java
+++ b/src/de/danoeh/antennapod/feed/FeedManager.java
@@ -776,18 +776,7 @@ public class FeedManager {
sendFeedUpdateBroadcast(context);
}
});
- dbExec.execute(new Runnable() {
-
- @Override
- public void run() {
- PodDBAdapter adapter = new PodDBAdapter(context);
- adapter.open();
- adapter.setCompleteFeed(feed);
- feed.cacheDescriptionsOfItems();
- adapter.close();
- }
- });
-
+ setCompleteFeed(context, feed);
}
/**
@@ -811,6 +800,12 @@ public class FeedManager {
if (AppConfig.DEBUG)
Log.d(TAG, "Feed with title " + newFeed.getTitle()
+ " already exists. Syncing new with existing one.");
+ if (savedFeed.compareWithOther(newFeed)) {
+ if (AppConfig.DEBUG)
+ Log.d(TAG,
+ "Feed has updated attribute values. Updating old feed's attributes");
+ savedFeed.updateFromOther(newFeed);
+ }
// Look for new or updated Items
for (int idx = 0; idx < newFeed.getItems().size(); idx++) {
final FeedItem item = newFeed.getItems().get(idx);
@@ -828,12 +823,14 @@ public class FeedManager {
}
});
markItemRead(context, item, false, false);
+ } else {
+ oldItem.updateFromOther(item);
}
}
// update attributes
savedFeed.setLastUpdate(newFeed.getLastUpdate());
savedFeed.setType(newFeed.getType());
- setFeed(context, savedFeed);
+ setCompleteFeed(context, savedFeed);
return savedFeed;
}
@@ -931,6 +928,25 @@ public class FeedManager {
});
}
+
+ /**
+ * Updates Information of an existing Feed and its FeedItems. Creates and opens its own
+ * adapter.
+ */
+ public void setCompleteFeed(final Context context, final Feed feed) {
+ dbExec.execute(new Runnable() {
+
+ @Override
+ public void run() {
+ PodDBAdapter adapter = new PodDBAdapter(context);
+ adapter.open();
+ adapter.setCompleteFeed(feed);
+ feed.cacheDescriptionsOfItems();
+ adapter.close();
+ }
+ });
+
+ }
/**
* Updates information of an existing FeedItem. Creates and opens its own
@@ -1348,9 +1364,9 @@ public class FeedManager {
}
/**
- * Loads description and contentEncoded values from the database and caches it in the feeditem. The task
- * callback will contain a String-array with the description at index 0 and
- * the value of contentEncoded at index 1.
+ * Loads description and contentEncoded values from the database and caches
+ * it in the feeditem. The task callback will contain a String-array with
+ * the description at index 0 and the value of contentEncoded at index 1.
*/
public void loadExtraInformationOfItem(final Context context,
final FeedItem item, FeedManager.TaskCallback<String[]> callback) {
@@ -1375,7 +1391,7 @@ public class FeedManager {
.getString(PodDBAdapter.IDX_FI_EXTRA_CONTENT_ENCODED);
item.setCachedDescription(description);
item.setCachedContentEncoded(contentEncoded);
- setResult(new String[] {description, contentEncoded});
+ setResult(new String[] { description, contentEncoded });
}
adapter.close();
}