diff --git a/src/de/danoeh/antennapod/PodcastApp.java b/src/de/danoeh/antennapod/PodcastApp.java index 9bca9a5e2..b47688b87 100644 --- a/src/de/danoeh/antennapod/PodcastApp.java +++ b/src/de/danoeh/antennapod/PodcastApp.java @@ -41,6 +41,8 @@ public class PodcastApp extends Application implements private static PodcastApp singleton; private boolean displayOnlyEpisodes; + + private static long lastPlayedMediaId; public static PodcastApp getInstance() { return singleton; @@ -54,6 +56,7 @@ public class PodcastApp extends Application implements SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(this); displayOnlyEpisodes = prefs.getBoolean(PREF_DISPLAY_ONLY_EPISODES, false); + lastPlayedMediaId = prefs.getLong(PlaybackService.PREF_LAST_PLAYED_ID, -1); createImportDirectory(); createNoMediaFile(); prefs.registerOnSharedPreferenceChangeListener(this); @@ -135,6 +138,10 @@ public class PodcastApp extends Application implements } else if (key.equals(PlaybackService.PREF_LAST_PLAYED_ID)) { if (AppConfig.DEBUG) Log.d(TAG, "PREF_LAST_PLAYED_ID changed"); long mediaId = sharedPreferences.getLong(PlaybackService.PREF_AUTODELETE_MEDIA_ID, -1); + long lastPlayedId = sharedPreferences.getLong(PlaybackService.PREF_LAST_PLAYED_ID, -1); + if (lastPlayedId != lastPlayedMediaId) { + lastPlayedMediaId = lastPlayedId; + } if (mediaId != -1) { FeedManager manager = FeedManager.getInstance(); FeedMedia media = manager.getFeedMedia(mediaId); @@ -152,6 +159,10 @@ public class PodcastApp extends Application implements public boolean displayOnlyEpisodes() { return displayOnlyEpisodes; } + + public static long getLastPlayedMediaId() { + return lastPlayedMediaId; + } public boolean isLargeScreen() { return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE || (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE; diff --git a/src/de/danoeh/antennapod/feed/FeedItem.java b/src/de/danoeh/antennapod/feed/FeedItem.java index 8be4714a2..6a100f430 100644 --- a/src/de/danoeh/antennapod/feed/FeedItem.java +++ b/src/de/danoeh/antennapod/feed/FeedItem.java @@ -3,6 +3,8 @@ package de.danoeh.antennapod.feed; import java.util.Date; import java.util.List; +import de.danoeh.antennapod.PodcastApp; + /** * Data Object for a XML message * @@ -175,4 +177,13 @@ public class FeedItem extends FeedComponent { return media != null; } + public boolean isPlaying() { + if (media != null) { + if (PodcastApp.getLastPlayedMediaId() == media.getId()) { + return true; + } + } + return false; + } + } diff --git a/src/de/danoeh/antennapod/feed/FeedManager.java b/src/de/danoeh/antennapod/feed/FeedManager.java index cdde4d0a5..f149f000e 100644 --- a/src/de/danoeh/antennapod/feed/FeedManager.java +++ b/src/de/danoeh/antennapod/feed/FeedManager.java @@ -39,7 +39,7 @@ import de.danoeh.antennapod.util.comparator.PlaybackCompletionDateComparator; public class FeedManager { private static final String TAG = "FeedManager"; - public static final String ACITON_FEED_LIST_UPDATE = "de.danoeh.antennapod.action.feed.feedlistUpdate"; + public static final String ACTION_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"; @@ -264,7 +264,7 @@ public class FeedManager { } private void sendFeedUpdateBroadcast(Context context) { - context.sendBroadcast(new Intent(ACITON_FEED_LIST_UPDATE)); + context.sendBroadcast(new Intent(ACTION_FEED_LIST_UPDATE)); } private void sendPlaybackHistoryUpdateBroadcast(Context context) { diff --git a/src/de/danoeh/antennapod/fragment/FeedlistFragment.java b/src/de/danoeh/antennapod/fragment/FeedlistFragment.java index 1a205f521..caf6c6a7f 100644 --- a/src/de/danoeh/antennapod/fragment/FeedlistFragment.java +++ b/src/de/danoeh/antennapod/fragment/FeedlistFragment.java @@ -116,7 +116,7 @@ public class FeedlistFragment extends SherlockFragment implements IntentFilter filter = new IntentFilter(); filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED); filter.addAction(FeedManager.ACTION_UNREAD_ITEMS_UPDATE); - filter.addAction(FeedManager.ACITON_FEED_LIST_UPDATE); + filter.addAction(FeedManager.ACTION_FEED_LIST_UPDATE); filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED); pActivity.registerReceiver(contentUpdate, filter); fla.notifyDataSetChanged();