Search in sources :

Example 6 with Broadcast

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

the class SingleBroadcastAdapter method setBroadcast.

public void setBroadcast(Broadcast broadcast) {
    // Don't check for whether mBroadcast == broadcast because we always want to invalidate.
    Broadcast oldBroadcast = mBroadcast;
    mBroadcast = broadcast;
    if (oldBroadcast == null) {
        notifyItemInserted(0);
    } else if (mBroadcast == null) {
        notifyItemRemoved(0);
    } else {
        notifyItemChanged(0);
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast)

Example 7 with Broadcast

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

the class BroadcastResource method onDestroy.

@Override
public void onDestroy() {
    super.onDestroy();
    if (has()) {
        Broadcast broadcast = get();
        setArguments(broadcast.id, broadcast);
    }
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast)

Example 8 with Broadcast

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

the class ProfileBroadcastsLayout method bind.

public void bind(final User user, List<Broadcast> broadcastList) {
    final Context context = getContext();
    View.OnClickListener viewMoreListener = new OnClickListener() {

        @Override
        public void onClick(View view) {
            context.startActivity(BroadcastListActivity.makeIntent(user, context));
        }
    };
    mTitleText.setOnClickListener(viewMoreListener);
    mViewMoreText.setOnClickListener(viewMoreListener);
    int i = 0;
    for (final Broadcast broadcast : broadcastList) {
        if (i >= BROADCAST_COUNT_MAX) {
            break;
        }
        if (broadcast.rebroadcastedBroadcast != null) {
            continue;
        }
        if (i >= mBroadcastList.getChildCount()) {
            ViewUtils.inflateInto(R.layout.profile_broadcast_item, mBroadcastList);
        }
        View broadcastLayout = mBroadcastList.getChildAt(i);
        broadcastLayout.setVisibility(VISIBLE);
        BroadcastLayoutHolder holder = (BroadcastLayoutHolder) broadcastLayout.getTag();
        if (holder == null) {
            holder = new BroadcastLayoutHolder(broadcastLayout);
            broadcastLayout.setTag(holder);
            ViewUtils.setTextViewLinkClickable(holder.textText);
        }
        // HACK: Should not change on rebind.
        if (holder.boundBroadcastId != broadcast.id) {
            String imageUrl = null;
            if (broadcast.attachment != null) {
                imageUrl = broadcast.attachment.image;
            }
            if (TextUtils.isEmpty(imageUrl)) {
                List<Image> images = broadcast.images.size() > 0 ? broadcast.images : Photo.toImageList(broadcast.photos);
                if (images.size() > 0) {
                    imageUrl = images.get(0).medium;
                }
            }
            if (!TextUtils.isEmpty(imageUrl)) {
                holder.image.setVisibility(VISIBLE);
                ImageUtils.loadImage(holder.image, imageUrl);
            } else {
                holder.image.setVisibility(GONE);
            }
            CharSequence text = broadcast.getTextWithEntities(context);
            if (TextUtils.isEmpty(text) && broadcast.attachment != null) {
                text = broadcast.attachment.title;
            }
            holder.textText.setText(text);
            holder.timeActionText.setDoubanTimeAndAction(broadcast.createdAt, broadcast.action);
            broadcastLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    context.startActivity(BroadcastActivity.makeIntent(broadcast, context));
                }
            });
            holder.boundBroadcastId = broadcast.id;
        }
        ++i;
    }
    ViewUtils.setVisibleOrGone(mBroadcastList, i != 0);
    ViewUtils.setVisibleOrGone(mEmptyView, i == 0);
    if (user.broadcastCount > i) {
        mViewMoreText.setText(context.getString(R.string.view_more_with_count_format, user.broadcastCount));
    } else {
        mViewMoreText.setVisibility(GONE);
    }
    for (int count = mBroadcastList.getChildCount(); i < count; ++i) {
        mBroadcastList.getChildAt(i).setVisibility(GONE);
    }
}
Also used : Context(android.content.Context) Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) Image(me.zhanghai.android.douya.network.api.info.apiv2.Image) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TimeActionTextView(me.zhanghai.android.douya.ui.TimeActionTextView) TextView(android.widget.TextView) View(android.view.View) FriendlyCardView(me.zhanghai.android.douya.ui.FriendlyCardView)

Example 9 with Broadcast

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

the class BroadcastAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    Broadcast originalBroadcast = getItem(position);
    holder.rebroadcastedByText.setText(originalBroadcast.getRebroadcastedBy(RecyclerViewUtils.getContext(holder)));
    final Broadcast broadcast = originalBroadcast.rebroadcastedBroadcast != null ? originalBroadcast.rebroadcastedBroadcast : originalBroadcast;
    holder.cardView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mListener.onOpenBroadcast(broadcast, getSharedView(holder));
        }
    });
    holder.broadcastLayout.bindBroadcast(broadcast);
    holder.broadcastLayout.setListener(new BroadcastLayout.Listener() {

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

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

        @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.apiv2.Broadcast) CardView(android.support.v7.widget.CardView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 10 with Broadcast

use of me.zhanghai.android.douya.network.api.info.apiv2.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.copyText(broadcast.getClipboradLabel(), broadcast.getClipboardText(activity), activity);
}
Also used : Broadcast(me.zhanghai.android.douya.network.api.info.apiv2.Broadcast) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity)

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