Search in sources :

Example 11 with Broadcast

use of me.zhanghai.android.douya.network.api.info.apiv2.Broadcast in project Douya by DreaminginCodeZH.

the class BroadcastListResource method onBroadcastDeleted.

@Subscribe(threadMode = ThreadMode.MAIN)
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 || (broadcast.rebroadcastedBroadcast != null && broadcast.rebroadcastedBroadcast.id == event.broadcastId)) {
            broadcastList.remove(i);
            getListener().onBroadcastRemoved(getRequestCode(), i);
            --size;
        } else {
            ++i;
        }
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 12 with Broadcast

use of me.zhanghai.android.douya.network.api.info.apiv2.Broadcast in project Douya by DreaminginCodeZH.

the class BroadcastListResource method onBroadcastUpdated.

@Subscribe(threadMode = ThreadMode.MAIN)
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 broadcast = broadcastList.get(i);
        boolean changed = false;
        if (broadcast.id == event.broadcast.id) {
            broadcastList.set(i, event.broadcast);
            changed = true;
        } else if (broadcast.rebroadcastedBroadcast != null && broadcast.rebroadcastedBroadcast.id == event.broadcast.id) {
            broadcast.rebroadcastedBroadcast = event.broadcast;
            changed = true;
        }
        if (changed) {
            getListener().onBroadcastChanged(getRequestCode(), i, broadcastList.get(i));
        }
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 13 with Broadcast

use of me.zhanghai.android.douya.network.api.info.apiv2.Broadcast in project Douya by DreaminginCodeZH.

the class BroadcastResource method get.

@Override
public Broadcast get() {
    Broadcast broadcast = super.get();
    if (broadcast == null) {
        // Can be called before onCreate() is called.
        ensureArguments();
        broadcast = mExtraBroadcast;
    }
    return broadcast;
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast)

Example 14 with Broadcast

use of me.zhanghai.android.douya.network.api.info.apiv2.Broadcast in project Douya by DreaminginCodeZH.

the class BroadcastActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    TransitionUtils.setupTransitionBeforeDecorate(this);
    super.onCreate(savedInstanceState);
    // Calls ensureSubDecor().
    findViewById(android.R.id.content);
    TransitionUtils.postponeTransition(this);
    if (savedInstanceState == null) {
        Intent intent = getIntent();
        long broadcastId = intent.getLongExtra(EXTRA_BROADCAST_ID, -1);
        Broadcast broadcast = intent.getParcelableExtra(EXTRA_BROADCAST);
        boolean showSendComment = intent.getBooleanExtra(EXTRA_SHOW_SEND_COMMENT, false);
        String title = intent.getStringExtra(EXTRA_TITLE);
        FragmentUtils.add(BroadcastFragment.newInstance(broadcastId, broadcast, showSendComment, title), this, android.R.id.content);
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) Intent(android.content.Intent)

Aggregations

Broadcast (me.zhanghai.android.douya.network.api.info.apiv2.Broadcast)12 View (android.view.View)5 BindView (butterknife.BindView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 TextView (android.widget.TextView)3 Context (android.content.Context)2 AppCompatActivity (android.support.v7.app.AppCompatActivity)2 ImageView (android.widget.ImageView)2 Image (me.zhanghai.android.douya.network.api.info.apiv2.Image)2 TimeActionTextView (me.zhanghai.android.douya.ui.TimeActionTextView)2 Subscribe (org.greenrobot.eventbus.Subscribe)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 SharedElementCallback (android.support.v4.app.SharedElementCallback)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 CardView (android.support.v7.widget.CardView)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 LikeBroadcastManager (me.zhanghai.android.douya.broadcast.content.LikeBroadcastManager)1 RebroadcastBroadcastManager (me.zhanghai.android.douya.broadcast.content.RebroadcastBroadcastManager)1 BroadcastUpdatedEvent (me.zhanghai.android.douya.eventbus.BroadcastUpdatedEvent)1