package com.sheep.gamegroup.view.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sheep.gamegroup.model.entity.UserComment;
import com.sheep.gamegroup.util.Jump2View;
import com.sheep.gamegroup.util.ViewUtil;
import com.sheep.gamegroup.util.viewHelper.UserCommentHelper;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;

/**
 * Created by realicing on 2018/11/1.
 * realicing@sina.com
 * 用户主页评论列表adapter
 */
public class AdpUserAppHomeComment extends BaseQuickAdapter<UserComment, BaseViewHolder> {
    public AdpUserAppHomeComment(List<UserComment> list) {
        super(R.layout.item_user_app_home_comment, list);
    }

    @Override
    protected void convert(BaseViewHolder helper, final UserComment item) {
        int position = helper.getAdapterPosition() - getHeaderLayoutCount();
        View user_comment_detail_line_top = helper.itemView.findViewById(R.id.user_comment_detail_line_top);
        ViewUtil.setVisibility(user_comment_detail_line_top, position != 0);
        Object tag = helper.itemView.getTag();
        UserCommentHelper headerViewHelper;
        if(tag instanceof UserCommentHelper)
            headerViewHelper= (UserCommentHelper) tag;
        else
            headerViewHelper = new UserCommentHelper(helper.itemView);
        headerViewHelper.loadHeaderViewData(item);
        headerViewHelper.getUser_comment_detail_game_icon().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Jump2View.getInstance().goPlayGameDetail(null, item.getApp_id());
            }
        });
    }
}
