Downloadstatus entries for feeds are now created correctly
This commit is contained in:
parent
3b4bf9374a
commit
704e974940
|
@ -233,18 +233,9 @@ public class FeedManager {
|
||||||
adapter.close();
|
adapter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/** Updates an existing feed or adds it as a new one if it doesn't exist.
|
||||||
* TODO Decide if still useful
|
* @return The saved Feed with a database ID*/
|
||||||
*
|
public Feed updateFeed(Context context, final Feed newFeed) {
|
||||||
* public void addFeedItem(Context context, FeedItem item) { PodDBAdapter
|
|
||||||
* adapter = new PodDBAdapter(context); // Search list for feeditem Feed
|
|
||||||
* feed = item.getFeed(); FeedItem foundItem = searchFeedItemByLink(feed,
|
|
||||||
* item.getLink()); if (foundItem != null) { // Update Information item.id =
|
|
||||||
* foundItem.id; foundItem = item; item.setRead(foundItem.isRead());
|
|
||||||
* adapter.setFeedItem(item); } else { feed.getItems().add(item); item.id =
|
|
||||||
* adapter.setFeedItem(item); } }
|
|
||||||
*/
|
|
||||||
public void updateFeed(Context context, final Feed newFeed) {
|
|
||||||
// Look up feed in the feedslist
|
// Look up feed in the feedslist
|
||||||
final Feed savedFeed = searchFeedByLink(newFeed.getLink());
|
final Feed savedFeed = searchFeedByLink(newFeed.getLink());
|
||||||
if (savedFeed == null) {
|
if (savedFeed == null) {
|
||||||
|
@ -254,6 +245,7 @@ public class FeedManager {
|
||||||
// Add a new Feed
|
// Add a new Feed
|
||||||
markItemRead(context, newFeed.getItems().get(0), false);
|
markItemRead(context, newFeed.getItems().get(0), false);
|
||||||
addNewFeed(context, newFeed);
|
addNewFeed(context, newFeed);
|
||||||
|
return newFeed;
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Feed with title " + newFeed.getTitle()
|
Log.d(TAG, "Feed with title " + newFeed.getTitle()
|
||||||
+ " already exists. Syncing new with existing one.");
|
+ " already exists. Syncing new with existing one.");
|
||||||
|
@ -271,7 +263,7 @@ public class FeedManager {
|
||||||
}
|
}
|
||||||
savedFeed.setLastUpdate(newFeed.getLastUpdate());
|
savedFeed.setLastUpdate(newFeed.getLastUpdate());
|
||||||
setFeed(context, savedFeed);
|
setFeed(context, savedFeed);
|
||||||
|
return savedFeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,6 +277,7 @@ public class DownloadService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Feed savedFeed = null;
|
||||||
long imageId = 0;
|
long imageId = 0;
|
||||||
boolean hasImage = false;
|
boolean hasImage = false;
|
||||||
long downloadId = feed.getDownloadId();
|
long downloadId = feed.getDownloadId();
|
||||||
|
@ -298,7 +299,7 @@ public class DownloadService extends Service {
|
||||||
|
|
||||||
feed.setDownloadId(0);
|
feed.setDownloadId(0);
|
||||||
// Save information of feed in DB
|
// Save information of feed in DB
|
||||||
manager.updateFeed(service, feed);
|
savedFeed = manager.updateFeed(service, feed);
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
successful = false;
|
successful = false;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -319,7 +320,7 @@ public class DownloadService extends Service {
|
||||||
|
|
||||||
requester.removeDownload(feed);
|
requester.removeDownload(feed);
|
||||||
cleanup();
|
cleanup();
|
||||||
long statusId = manager.addDownloadStatus(service, new DownloadStatus(feed, reason, successful));
|
long statusId = manager.addDownloadStatus(service, new DownloadStatus(savedFeed, reason, successful));
|
||||||
sendDownloadHandledIntent(downloadId, statusId, hasImage, imageId);
|
sendDownloadHandledIntent(downloadId, statusId, hasImage, imageId);
|
||||||
queryDownloads();
|
queryDownloads();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue