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);
}
}
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);
}
}
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);
}
}
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());
}
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);
}
Aggregations