Search in sources :

Example 16 with Broadcast

use of me.zhanghai.android.douya.network.api.info.frodo.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);
        mFragment = BroadcastFragment.newInstance(broadcastId, broadcast, showSendComment, title);
        FragmentUtils.add(mFragment, this, android.R.id.content);
    } else {
        mFragment = FragmentUtils.findById(this, android.R.id.content);
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) Intent(android.content.Intent)

Example 17 with Broadcast

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

the class BroadcastAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Broadcast broadcast = getItem(position);
    holder.rebroadcastedByText.setText(broadcast.isSimpleRebroadcast() ? broadcast.getRebroadcastedBy(holder.rebroadcastedByText.getContext()) : null);
    Broadcast effectiveBroadcast = broadcast.getEffectiveBroadcast();
    holder.cardView.setOnClickListener(view -> mListener.onOpenBroadcast(broadcast, getSharedView(holder)));
    holder.broadcastLayout.bind(broadcast);
    holder.broadcastLayout.setListener(new BroadcastLayout.Listener() {

        @Override
        public void onLikeClicked() {
            mListener.onLikeBroadcast(effectiveBroadcast, !effectiveBroadcast.isLiked);
        }

        @Override
        public void onRebroadcastClicked(boolean isLongClick) {
            mListener.onRebroadcastBroadcast(broadcast, !broadcast.isSimpleRebroadcastByOneself(), isLongClick);
        }

        @Override
        public void onCommentClicked() {
            // Not setting button disabled because we are using enabled state for indeterminate
            // state due to network, and we want the click to always open the broadcast for our
            // user.
            mListener.onCommentBroadcast(broadcast, getSharedView(holder));
        }
    });
    ViewCompat.setTransitionName(getSharedView(holder), broadcast.makeTransitionName());
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast)

Example 18 with Broadcast

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

the class BroadcastResource method get.

/**
 * @deprecated In most cases you may want to use {@link #getEffectiveBroadcast()}.
 */
@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.frodo.Broadcast)

Example 19 with Broadcast

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

the class DeleteBroadcastWriter method onResponse.

@Override
public void onResponse(Void response) {
    ToastUtils.show(mBroadcast != null && mBroadcast.isSimpleRebroadcast() ? R.string.broadcast_unrebroadcast_successful : R.string.broadcast_delete_successful, getContext());
    if (mBroadcast != null) {
        Broadcast rebroadcastedBroadcast;
        if (mBroadcast.parentBroadcast != null) {
            rebroadcastedBroadcast = mBroadcast.parentBroadcast;
        } else if (mBroadcast.getParentBroadcastId() != null) {
            rebroadcastedBroadcast = null;
        } else {
            rebroadcastedBroadcast = mBroadcast.rebroadcastedBroadcast;
        }
        if (rebroadcastedBroadcast != null) {
            --rebroadcastedBroadcast.rebroadcastCount;
            EventBusUtils.postAsync(new BroadcastUpdatedEvent(rebroadcastedBroadcast, this));
        }
    }
    EventBusUtils.postAsync(new BroadcastDeletedEvent(mBroadcastId, this));
    stopSelf();
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) BroadcastDeletedEvent(me.zhanghai.android.douya.eventbus.BroadcastDeletedEvent) BroadcastUpdatedEvent(me.zhanghai.android.douya.eventbus.BroadcastUpdatedEvent)

Example 20 with Broadcast

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

the class BroadcastFragment method copyText.

private void copyText() {
    Broadcast broadcast = mBroadcastAdapter.getBroadcast();
    Activity activity = getActivity();
    if (broadcast == null) {
        ToastUtils.show(R.string.broadcast_copy_text_not_loaded, activity);
        return;
    }
    ClipboardUtils.copy(broadcast, activity);
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.frodo.Broadcast) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) WebViewActivity(me.zhanghai.android.douya.ui.WebViewActivity) Activity(android.app.Activity)

Aggregations

Broadcast (me.zhanghai.android.douya.network.api.info.frodo.Broadcast)22 Subscribe (org.greenrobot.eventbus.Subscribe)7 Context (android.content.Context)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 TextUtils (android.text.TextUtils)2 View (android.view.View)2 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)2 BindView (butterknife.BindView)2 ButterKnife (butterknife.ButterKnife)2 List (java.util.List)2 R (me.zhanghai.android.douya.R)2 BroadcastUpdatedEvent (me.zhanghai.android.douya.eventbus.BroadcastUpdatedEvent)2 ApiError (me.zhanghai.android.douya.network.api.ApiError)2 SizedImageItem (me.zhanghai.android.douya.ui.SizedImageItem)2 ViewUtils (me.zhanghai.android.douya.util.ViewUtils)2 Bundle (android.os.Bundle)1 AttributeSet (android.util.AttributeSet)1 LayoutInflater (android.view.LayoutInflater)1 Menu (android.view.Menu)1