Fixed bug that caused the application to crash when playing the last

played media of a feed that was already deleted
This commit is contained in:
daniel oeh
2012-06-26 13:17:48 +02:00
parent 2148189430
commit 6488e79827
2 changed files with 14 additions and 8 deletions

View File

@ -145,9 +145,10 @@ public class FeedManager {
unreadItems.add(item); unreadItems.add(item);
} }
} }
/** /**
* Sets the 'read' attribute of all FeedItems of a specific feed to true * Sets the 'read' attribute of all FeedItems of a specific feed to true
*
* @param context * @param context
*/ */
public void markFeedRead(Context context, Feed feed) { public void markFeedRead(Context context, Feed feed) {
@ -323,12 +324,15 @@ public class FeedManager {
/** Get a FeedMedia object by the id of the Media object and the feed object */ /** Get a FeedMedia object by the id of the Media object and the feed object */
public FeedMedia getFeedMedia(long id, Feed feed) { public FeedMedia getFeedMedia(long id, Feed feed) {
for (FeedItem item : feed.getItems()) { if (feed != null) {
if (item.getMedia().getId() == id) { for (FeedItem item : feed.getItems()) {
return item.getMedia(); if (item.getMedia().getId() == id) {
return item.getMedia();
}
} }
} }
Log.e(TAG, "Couldn't find FeedMedia with id " + id); Log.e(TAG, "Couldn't find FeedMedia with id " + id);
if (feed == null) Log.e(TAG, "Feed was null");
return null; return null;
} }
@ -371,7 +375,7 @@ public class FeedManager {
} }
private void extractFeedlistFromCursor(Context context, PodDBAdapter adapter) { private void extractFeedlistFromCursor(Context context, PodDBAdapter adapter) {
Cursor feedlistCursor = adapter.getAllFeedsCursor(); Cursor feedlistCursor = adapter.getAllFeedsCursor();
if (feedlistCursor.moveToFirst()) { if (feedlistCursor.moveToFirst()) {
do { do {
@ -407,7 +411,7 @@ public class FeedManager {
} while (feedlistCursor.moveToNext()); } while (feedlistCursor.moveToNext());
} }
feedlistCursor.close(); feedlistCursor.close();
} }
private ArrayList<FeedItem> extractFeedItemsFromCursor(Context context, private ArrayList<FeedItem> extractFeedItemsFromCursor(Context context,
@ -447,7 +451,8 @@ public class FeedManager {
return items; return items;
} }
private void extractDownloadLogFromCursor(Context context, PodDBAdapter adapter) { private void extractDownloadLogFromCursor(Context context,
PodDBAdapter adapter) {
Cursor logCursor = adapter.getDownloadLogCursor(); Cursor logCursor = adapter.getDownloadLogCursor();
if (logCursor.moveToFirst()) { if (logCursor.moveToFirst()) {
do { do {

View File

@ -187,6 +187,7 @@ public class PlaybackService extends Service {
} else { } else {
Log.e(TAG, "Media is null"); Log.e(TAG, "Media is null");
stopSelf();
} }
} else if (media != null && status != PlayerStatus.PLAYING) { } else if (media != null && status != PlayerStatus.PLAYING) {