use of me.zhanghai.android.douya.network.api.info.frodo.Broadcast in project Douya by DreaminginCodeZH.
the class TimelineBroadcastListResource 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 me.zhanghai.android.douya.network.api.info.frodo.Broadcast in project Douya by DreaminginCodeZH.
the class BaseBroadcastListResource method onLoadFinished.
@Override
protected void onLoadFinished(boolean more, int count, boolean successful, List<Broadcast> response, ApiError error) {
if (successful) {
if (more) {
append(response);
getListener().onLoadBroadcastListFinished(getRequestCode());
getListener().onBroadcastListAppended(getRequestCode(), Collections.unmodifiableList(response));
} else {
set(response);
getListener().onLoadBroadcastListFinished(getRequestCode());
getListener().onBroadcastListChanged(getRequestCode(), Collections.unmodifiableList(get()));
}
for (Broadcast broadcast : response) {
EventBusUtils.postAsync(new BroadcastUpdatedEvent(broadcast, this));
}
} else {
getListener().onLoadBroadcastListFinished(getRequestCode());
getListener().onLoadBroadcastListError(getRequestCode(), error);
}
}
Aggregations