use of me.zhanghai.android.douya.network.api.info.apiv2.Comment in project Douya by DreaminginCodeZH.
the class BroadcastFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CustomTabsHelperFragment.attachTo(this);
mBroadcastAndCommentListResource = BroadcastAndCommentListResource.attachTo(mBroadcastId, mBroadcast, this);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setTitle(getTitle());
activity.setSupportActionBar(mToolbar);
mContainerLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityCompat.finishAfterTransition(getActivity());
}
});
ViewCompat.setTransitionName(mSharedView, Broadcast.makeTransitionName(mBroadcastId));
// This magically gives better visual effect when the broadcast is partially visible. Using
// setEnterSharedElementCallback() disables this hack when no transition is used to start
// this Activity.
ActivityCompat.setEnterSharedElementCallback(activity, new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
mBroadcastCommentList.scrollToPosition(0);
}
});
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mBroadcastAndCommentListResource.loadBroadcast();
mBroadcastAndCommentListResource.loadCommentList(false);
}
});
mBroadcastCommentList.setHasFixedSize(true);
mBroadcastCommentList.setItemAnimator(new NoChangeAnimationItemAnimator());
mBroadcastCommentList.setLayoutManager(new LinearLayoutManager(activity));
mBroadcastAdapter = new SingleBroadcastAdapter(null, this);
setBroadcast(mBroadcastAndCommentListResource.getBroadcast());
mCommentAdapter = new CommentAdapter(mBroadcastAndCommentListResource.getCommentList(), new ClickableSimpleAdapter.OnItemClickListener<Comment, CommentAdapter.ViewHolder>() {
@Override
public void onItemClick(RecyclerView parent, Comment item, CommentAdapter.ViewHolder holder) {
onShowCommentAction(item);
}
});
mAdapter = new LoadMoreAdapter(R.layout.load_more_item, mBroadcastAdapter, mCommentAdapter);
mBroadcastCommentList.setAdapter(mAdapter);
mBroadcastCommentList.addOnScrollListener(new OnVerticalScrollListener() {
public void onScrolledToBottom() {
mBroadcastAndCommentListResource.loadCommentList(true);
}
});
CheatSheetUtils.setup(mSendButton);
mSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onSendComment();
}
});
updateSendCommentStatus();
if (savedInstanceState == null) {
if (mShowSendComment) {
TransitionUtils.postAfterTransition(this, new Runnable() {
@Override
public void run() {
onShowSendComment();
}
});
}
}
TransitionUtils.setEnterReturnExplode(this);
TransitionUtils.setupTransitionOnActivityCreated(this);
}
use of me.zhanghai.android.douya.network.api.info.apiv2.Comment in project JMRI by JMRI.
the class XmlFile method addDefaultInfo.
/**
* Add default information to the XML before writing it out.
* <P>
* Currently, this is identification information as an XML comment. This
* includes: <UL>
* <LI>The JMRI version used <LI>Date of writing <LI>A CVS id string, in
* case the file gets checked in or out </UL>
* <P>
* It may be necessary to extend this to check whether the info is already
* present, e.g. if re-writing a file.
*
* @param root The root element of the document that will be written.
*/
public static void addDefaultInfo(Element root) {
String content = "Written by JMRI version " + jmri.Version.name() + " on " + (new Date()).toString() + " $Id$";
Comment comment = new Comment(content);
root.addContent(comment);
}
use of me.zhanghai.android.douya.network.api.info.apiv2.Comment in project Douya by DreaminginCodeZH.
the class CommentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final Comment comment = getItem(position);
ImageUtils.loadAvatar(holder.avatarImage, comment.author.avatar);
final Context context = RecyclerViewUtils.getContext(holder);
holder.avatarImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
context.startActivity(ProfileActivity.makeIntent(comment.author, context));
}
});
holder.nameText.setText(comment.author.name);
holder.timeText.setDoubanTime(comment.createdAt);
holder.textText.setText(comment.getContentWithEntities(context));
}
use of me.zhanghai.android.douya.network.api.info.apiv2.Comment in project Douya by DreaminginCodeZH.
the class CommentListResource method onCommentDeleted.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCommentDeleted(CommentDeletedEvent event) {
if (event.isFromMyself(this) || isEmpty()) {
return;
}
List<Comment> commentList = get();
for (int i = 0, size = commentList.size(); i < size; ) {
Comment comment = commentList.get(i);
if (comment.id == event.commentId) {
commentList.remove(i);
getListener().onCommentRemoved(getRequestCode(), i);
--size;
} else {
++i;
}
}
}
Aggregations