Search in sources :

Example 1 with NodeListBean

use of com.codeest.geeknews.model.bean.NodeListBean in project GeekNews by codeestX.

the class NodeListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof TopViewHolder) {
        TopViewHolder topHolder = ((TopViewHolder) holder);
        if (mTopBean == null)
            return;
        ImageLoader.load(mContext, VtexPresenter.parseImg(mTopBean.getavatar_normal()), topHolder.ivNodeFace);
        topHolder.tvNodeContent.setText(mTopBean.getHeader());
        topHolder.tvNodesTips.setText(String.format("%d个主题\n%d次收藏", mTopBean.getTopics(), mTopBean.getStars()));
        topHolder.tvNodeName.setText(mTopBean.getTitle());
    } else {
        ViewHolder contentHolder = ((ViewHolder) holder);
        NodeListBean bean = mList.get(position - 1);
        if (bean == null)
            return;
        ImageLoader.load(mContext, VtexPresenter.parseImg(bean.getMember().getavatar_normal()), contentHolder.ivTopicFace);
        contentHolder.tvTopicName.setText(bean.getMember().getUsername());
        contentHolder.tvTopicTips.setText(DateUtil.formatTime2String(bean.getCreated()));
        contentHolder.tvTopicComment.setText(String.valueOf(bean.getReplies()));
        contentHolder.tvTopicTitle.setText(bean.getTitle());
        contentHolder.tvTopicNode.setText(bean.getNode().getTitle());
        contentHolder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(mContext, RepliesActivity.class);
                if (holder.getAdapterPosition() - 1 < 0 || mList.get(holder.getAdapterPosition() - 1) == null)
                    return;
                intent.putExtra(Constants.IT_VTEX_TOPIC_ID, mList.get(holder.getAdapterPosition() - 1).getId());
                intent.putExtra(Constants.IT_VTEX_REPLIES_TOP, mList.get(holder.getAdapterPosition() - 1));
                mContext.startActivity(intent);
            }
        });
    }
}
Also used : NodeListBean(com.codeest.geeknews.model.bean.NodeListBean) Intent(android.content.Intent) SquareImageView(com.codeest.geeknews.widget.SquareImageView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) CircleImageView(com.codeest.geeknews.widget.CircleImageView) RepliesActivity(com.codeest.geeknews.ui.vtex.activity.RepliesActivity)

Example 2 with NodeListBean

use of com.codeest.geeknews.model.bean.NodeListBean in project GeekNews by codeestX.

the class NodePresenter method getContent.

@Override
public void getContent(String node_name) {
    Subscription rxSubscription = mRetrofitHelper.fetchTopicList(node_name).compose(RxUtil.<List<NodeListBean>>rxSchedulerHelper()).subscribe(new CommonSubscriber<List<NodeListBean>>(mView) {

        @Override
        public void onNext(List<NodeListBean> nodeListBeen) {
            mView.showContent(nodeListBeen);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : NodeListBean(com.codeest.geeknews.model.bean.NodeListBean) List(java.util.List) Subscription(rx.Subscription)

Example 3 with NodeListBean

use of com.codeest.geeknews.model.bean.NodeListBean in project GeekNews by codeestX.

the class RepliesPresenter method getTopInfo.

@Override
public void getTopInfo(String topic_id) {
    Subscription rxSubscription = mRetrofitHelper.fetchTopicInfo(topic_id).compose(RxUtil.<List<NodeListBean>>rxSchedulerHelper()).filter(new Func1<List<NodeListBean>, Boolean>() {

        @Override
        public Boolean call(List<NodeListBean> nodeListBeen) {
            return nodeListBeen.size() > 0;
        }
    }).map(new Func1<List<NodeListBean>, NodeListBean>() {

        @Override
        public NodeListBean call(List<NodeListBean> nodeListBeen) {
            return nodeListBeen.get(0);
        }
    }).subscribe(new CommonSubscriber<NodeListBean>(mView) {

        @Override
        public void onNext(NodeListBean nodeListBean) {
            mView.showTopInfo(nodeListBean);
        }
    });
    addSubscrebe(rxSubscription);
}
Also used : NodeListBean(com.codeest.geeknews.model.bean.NodeListBean) List(java.util.List) Subscription(rx.Subscription) Func1(rx.functions.Func1)

Aggregations

NodeListBean (com.codeest.geeknews.model.bean.NodeListBean)3 List (java.util.List)2 Subscription (rx.Subscription)2 Intent (android.content.Intent)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 RepliesActivity (com.codeest.geeknews.ui.vtex.activity.RepliesActivity)1 CircleImageView (com.codeest.geeknews.widget.CircleImageView)1 SquareImageView (com.codeest.geeknews.widget.SquareImageView)1 Func1 (rx.functions.Func1)1