Don't send Gpodder actions for items that don't have media.

Fixes AntennaPod/AntennaPod#964
This commit is contained in:
Tom Hennen 2015-06-27 18:09:51 -04:00
parent 5d553394ba
commit 51e3f55561
2 changed files with 11 additions and 21 deletions

View File

@ -97,19 +97,6 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
} else {
if (!item.isRead()) {
DBWriter.markItemRead(context, item, true, true);
if(GpodnetPreferences.loggedIn()) {
// gpodder: send played action
FeedMedia media = item.getMedia();
GpodnetEpisodeAction action = new GpodnetEpisodeAction.Builder(item, GpodnetEpisodeAction.Action.PLAY)
.currentDeviceId()
.currentTimestamp()
.started(media.getDuration() / 1000)
.position(media.getDuration() / 1000)
.total(media.getDuration() / 1000)
.build();
GpodnetPreferences.enqueueEpisodeAction(action);
}
}
}
}

View File

@ -158,14 +158,17 @@ public class FeedItemMenuHandler {
DBWriter.markItemRead(context, selectedItem, true, false);
if(GpodnetPreferences.loggedIn()) {
FeedMedia media = selectedItem.getMedia();
GpodnetEpisodeAction actionPlay = new GpodnetEpisodeAction.Builder(selectedItem, Action.PLAY)
.currentDeviceId()
.currentTimestamp()
.started(media.getDuration() / 1000)
.position(media.getDuration() / 1000)
.total(media.getDuration() / 1000)
.build();
GpodnetPreferences.enqueueEpisodeAction(actionPlay);
// not all items have media, Gpodder only cares about those that do
if (media != null) {
GpodnetEpisodeAction actionPlay = new GpodnetEpisodeAction.Builder(selectedItem, Action.PLAY)
.currentDeviceId()
.currentTimestamp()
.started(media.getDuration() / 1000)
.position(media.getDuration() / 1000)
.total(media.getDuration() / 1000)
.build();
GpodnetPreferences.enqueueEpisodeAction(actionPlay);
}
}
break;
case R.id.mark_unread_item: