package com.sheep.gamegroup.view.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
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.Applications;
import com.sheep.gamegroup.util.GlideImageLoader;
import com.sheep.gamegroup.util.Jump2View;
import com.sheep.gamegroup.util.ViewUtil;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;

/**
 * Created by realicing on 2018/11/5.
 * realicing@sina.com
 */
public class AdpGcGameAppList extends RecyclerViewAdapter<Applications> {

    public AdpGcGameAppList(Context context, int layoutId, List<Applications> datas) {
        super(context, layoutId, datas);
    }

    @Override
    public void convert(ViewHolder viewHolder, final Applications item, int position) {
        ImageView item_gc_game_app_iv = viewHolder.itemView.findViewById(R.id.item_gc_game_app_iv);
        TextView item_gc_game_app_tv = viewHolder.itemView.findViewById(R.id.item_gc_game_app_tv);
        if (item == null) {
            ViewUtil.setDefaultText(item_gc_game_app_tv);
        } else {
            // 加载数据
            ViewUtil.setText(item_gc_game_app_tv, item.getName());
            GlideImageLoader.setGameImage(item_gc_game_app_iv, item.getIcon());
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Jump2View.getInstance().goPlayGameDetail(null, item.getId());
                }
            });
        }
    }
}
