Search in sources :

Example 1 with Comment

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);
}
Also used : Comment(me.zhanghai.android.douya.network.api.info.apiv2.Comment) AppCompatActivity(android.support.v7.app.AppCompatActivity) OnVerticalScrollListener(me.zhanghai.android.douya.ui.OnVerticalScrollListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) RecyclerView(android.support.v7.widget.RecyclerView) SharedElementCallback(android.support.v4.app.SharedElementCallback) LoadMoreAdapter(me.zhanghai.android.douya.ui.LoadMoreAdapter) NoChangeAnimationItemAnimator(me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)

Example 2 with Comment

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);
}
Also used : Comment(org.jdom2.Comment) Date(java.util.Date)

Example 3 with 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));
}
Also used : Context(android.content.Context) Comment(me.zhanghai.android.douya.network.api.info.apiv2.Comment) TimeTextView(me.zhanghai.android.douya.ui.TimeTextView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 4 with Comment

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;
        }
    }
}
Also used : Comment(me.zhanghai.android.douya.network.api.info.apiv2.Comment) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Comment (me.zhanghai.android.douya.network.api.info.apiv2.Comment)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 BindView (butterknife.BindView)2 Context (android.content.Context)1 SharedElementCallback (android.support.v4.app.SharedElementCallback)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Date (java.util.Date)1 LoadMoreAdapter (me.zhanghai.android.douya.ui.LoadMoreAdapter)1 NoChangeAnimationItemAnimator (me.zhanghai.android.douya.ui.NoChangeAnimationItemAnimator)1 OnVerticalScrollListener (me.zhanghai.android.douya.ui.OnVerticalScrollListener)1 TimeTextView (me.zhanghai.android.douya.ui.TimeTextView)1 Subscribe (org.greenrobot.eventbus.Subscribe)1 Comment (org.jdom2.Comment)1