Migrated playback history events to EventBus
This commit is contained in:
parent
68da2e022d
commit
d8ffa6c459
|
@ -12,6 +12,7 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.ListView;
|
||||
|
||||
import de.danoeh.antennapod.core.event.PlaybackHistoryEvent;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
@ -42,8 +43,7 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
|
||||
public static final String TAG = "PlaybackHistoryFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.PLAYBACK_HISTORY_UPDATE |
|
||||
EventDistributor.PLAYER_STATUS_UPDATE;
|
||||
private static final int EVENTS = EventDistributor.PLAYER_STATUS_UPDATE;
|
||||
|
||||
private List<FeedItem> playbackHistory;
|
||||
private FeedItemlistAdapter adapter;
|
||||
|
@ -166,6 +166,12 @@ public class PlaybackHistoryFragment extends ListFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onHistoryUpdated(PlaybackHistoryEvent event) {
|
||||
loadItems();
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private final EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package de.danoeh.antennapod.core.event;
|
||||
|
||||
public class PlaybackHistoryEvent {
|
||||
|
||||
private PlaybackHistoryEvent() {
|
||||
}
|
||||
|
||||
public static PlaybackHistoryEvent listUpdated() {
|
||||
return new PlaybackHistoryEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlaybackHistoryEvent";
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ public class EventDistributor extends Observable {
|
|||
|
||||
public static final int FEED_LIST_UPDATE = 1;
|
||||
public static final int UNREAD_ITEMS_UPDATE = 2;
|
||||
public static final int PLAYBACK_HISTORY_UPDATE = 16;
|
||||
public static final int DOWNLOAD_HANDLED = 64;
|
||||
public static final int PLAYER_STATUS_UPDATE = 128;
|
||||
|
||||
|
@ -85,10 +84,6 @@ public class EventDistributor extends Observable {
|
|||
addEvent(FEED_LIST_UPDATE);
|
||||
}
|
||||
|
||||
public void sendPlaybackHistoryUpdateBroadcast() {
|
||||
addEvent(PLAYBACK_HISTORY_UPDATE);
|
||||
}
|
||||
|
||||
public void sendPlayerStatusUpdateBroadcast() { addEvent(PLAYER_STATUS_UPDATE); }
|
||||
|
||||
public abstract static class EventListener implements Observer {
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.util.Log;
|
|||
import androidx.annotation.NonNull;
|
||||
|
||||
import de.danoeh.antennapod.core.event.DownloadLogEvent;
|
||||
import de.danoeh.antennapod.core.event.PlaybackHistoryEvent;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -194,7 +195,7 @@ public class DBWriter {
|
|||
adapter.open();
|
||||
adapter.clearPlaybackHistory();
|
||||
adapter.close();
|
||||
EventDistributor.getInstance().sendPlaybackHistoryUpdateBroadcast();
|
||||
EventBus.getDefault().post(PlaybackHistoryEvent.listUpdated());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -228,7 +229,7 @@ public class DBWriter {
|
|||
adapter.open();
|
||||
adapter.setFeedMediaPlaybackCompletionDate(media);
|
||||
adapter.close();
|
||||
EventDistributor.getInstance().sendPlaybackHistoryUpdateBroadcast();
|
||||
EventBus.getDefault().post(PlaybackHistoryEvent.listUpdated());
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue