package com.sheep.gamegroup.util;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
import com.sheep.gamegroup.model.entity.GameListTag;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.SheepApp;

import java.util.List;

/**
 * Created by realicing on 2018/10/31.
 * realicing@sina.com
 */
public class TagListUtil {

    //设置tag标签横向列表
    public static void setTagList(RecyclerView recyclerView, List<GameListTag> tagList) {
        LinearLayoutManager playGameActManager = new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
        recyclerView.setHasFixedSize(true);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.setLayoutManager(playGameActManager);
        recyclerView.setAdapter(new RecyclerViewAdapter<GameListTag>(SheepApp.getInstance(), R.layout.item_tag, tagList) {
            @Override
            public void convert(ViewHolder viewHolder, final GameListTag item, int position) {
                if(item == null)
                    return;
                if(viewHolder.itemView instanceof TextView){
                    ViewUtil.setText((TextView) viewHolder.itemView, item.getName());
                }
                viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Jump2View.getInstance().goActPlayGameList(ActivityManager.getInstance().currentActivity(), item);
                    }
                });
            }
        });


    }
}
