use of org.greenrobot.eventbus.Subscribe in project Douya by DreaminginCodeZH.
the class BaseBroadcastListResource method onBroadcastDeleted.
@Subscribe(threadMode = ThreadMode.POSTING)
public void onBroadcastDeleted(BroadcastDeletedEvent event) {
if (event.isFromMyself(this) || isEmpty()) {
return;
}
List<Broadcast> broadcastList = get();
for (int i = 0, size = broadcastList.size(); i < size; ) {
Broadcast broadcast = broadcastList.get(i);
if (broadcast.id == event.broadcastId) {
broadcastList.remove(i);
getListener().onBroadcastRemoved(getRequestCode(), i);
--size;
} else {
if (broadcast.parentBroadcast != null && broadcast.parentBroadcast.id == event.broadcastId) {
// Same behavior as Frodo API.
// FIXME: Won't reach here if another list shares this broadcast instance.
broadcast.parentBroadcast = null;
getListener().onBroadcastChanged(getRequestCode(), i, broadcast);
} else if (broadcast.rebroadcastedBroadcast != null && broadcast.rebroadcastedBroadcast.id == event.broadcastId) {
broadcast.rebroadcastedBroadcast.isDeleted = true;
getListener().onBroadcastChanged(getRequestCode(), i, broadcast);
}
++i;
}
}
}
use of org.greenrobot.eventbus.Subscribe in project Douya by DreaminginCodeZH.
the class BaseBroadcastListResource method onBroadcastUpdated.
@Subscribe(threadMode = ThreadMode.POSTING)
public void onBroadcastUpdated(BroadcastUpdatedEvent event) {
if (event.isFromMyself(this) || isEmpty()) {
return;
}
List<Broadcast> broadcastList = get();
for (int i = 0, size = broadcastList.size(); i < size; ++i) {
Broadcast updatedBroadcast = event.update(broadcastList.get(i), this);
if (updatedBroadcast != null) {
broadcastList.set(i, updatedBroadcast);
getListener().onBroadcastChanged(getRequestCode(), i, updatedBroadcast);
}
}
}
use of org.greenrobot.eventbus.Subscribe in project Douya by DreaminginCodeZH.
the class ItemCollectionListResource method onItemCollectionUpdated.
@Subscribe(threadMode = ThreadMode.POSTING)
public void onItemCollectionUpdated(ItemCollectionUpdatedEvent event) {
if (event.isFromMyself(this) || isEmpty()) {
return;
}
List<SimpleItemCollection> itemCollectionList = get();
for (int i = 0, size = itemCollectionList.size(); i < size; ++i) {
SimpleItemCollection itemCollection = itemCollectionList.get(i);
if (itemCollection.id == event.itemCollection.id) {
itemCollectionList.set(i, event.itemCollection);
getListener().onItemCollectionListItemChanged(getRequestCode(), i, itemCollectionList.get(i));
}
}
}
use of org.greenrobot.eventbus.Subscribe in project AntennaPod by AntennaPod.
the class PlaybackService method skipIntroEndingPresetChanged.
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void skipIntroEndingPresetChanged(SkipIntroEndingChangedEvent event) {
if (getPlayable() instanceof FeedMedia) {
if (((FeedMedia) getPlayable()).getItem().getFeed().getId() == event.getFeedId()) {
if (event.getSkipEnding() != 0) {
FeedPreferences feedPreferences = ((FeedMedia) getPlayable()).getItem().getFeed().getPreferences();
feedPreferences.setFeedSkipIntro(event.getSkipIntro());
feedPreferences.setFeedSkipEnding(event.getSkipEnding());
}
}
}
}
use of org.greenrobot.eventbus.Subscribe in project AntennaPod by AntennaPod.
the class PlaybackService method bufferUpdate.
@Subscribe(threadMode = ThreadMode.MAIN)
@SuppressWarnings("unused")
public void bufferUpdate(BufferUpdateEvent event) {
if (event.hasEnded()) {
Playable playable = getPlayable();
if (getPlayable() instanceof FeedMedia && playable.getDuration() <= 0 && mediaPlayer.getDuration() > 0) {
// Playable is being streamed and does not have a duration specified in the feed
playable.setDuration(mediaPlayer.getDuration());
DBWriter.setFeedMedia((FeedMedia) playable);
updateNotificationAndMediaSession(playable);
}
}
}
Aggregations