Search in sources :

Example 76 with Subscribe

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;
        }
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 77 with Subscribe

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);
        }
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 78 with Subscribe

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));
        }
    }
}
Also used : SimpleItemCollection(me.zhanghai.android.douya.network.api.info.frodo.SimpleItemCollection) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 79 with Subscribe

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());
            }
        }
    }
}
Also used : FeedPreferences(de.danoeh.antennapod.model.feed.FeedPreferences) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 80 with Subscribe

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);
        }
    }
}
Also used : Playable(de.danoeh.antennapod.model.playback.Playable) FeedMedia(de.danoeh.antennapod.model.feed.FeedMedia) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)164 Intent (android.content.Intent)20 Bundle (android.os.Bundle)11 EventBus (org.greenrobot.eventbus.EventBus)10 ThreadMode (org.greenrobot.eventbus.ThreadMode)10 View (android.view.View)9 Poi (io.jawg.osmcontributor.model.entities.Poi)9 PoiType (io.jawg.osmcontributor.model.entities.PoiType)9 ArrayList (java.util.ArrayList)9 Context (android.content.Context)8 Handler (android.os.Handler)8 ViewGroup (android.view.ViewGroup)8 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)8 SuppressLint (android.annotation.SuppressLint)6 LayoutInflater (android.view.LayoutInflater)6 MenuItem (android.view.MenuItem)6 DownloaderUpdate (de.danoeh.antennapod.core.event.DownloaderUpdate)6 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)6 Disposable (io.reactivex.disposables.Disposable)6 Schedulers (io.reactivex.schedulers.Schedulers)6