package com.wasu.cs.ui;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wasu.cs.adapter.BaseRecyclerViewAdapter;
import com.wasu.cs.adapter.BaseRecyclerViewHolder;
import com.wasu.cs.widget.FocusGridLayoutManager;
import com.wasu.module.log.WLog;

import java.util.ArrayList;
import java.util.List;

import cn.com.wasu.main.R;

/**
 * 电子竞技视频合集
 * created by danxingxi on 2016/03/31 21:50
 */
public class ActivityGameVideoCollection extends ActivityBase {
    private String TAG = "ActivityGameVideoCollection";

    private TextView tvCollectionName;
    private RecyclerView gRecyclerView;

    private GridAdapter mAdapter;

    private List<Integer> data = new ArrayList<Integer>();

    @Override
    protected void doCreate(Bundle savedInstanceState) {
        WLog.i(TAG,"doCreate()");

        setContentView(R.layout.activity_game_video_collection);

        for (int i=0;i<80 ;i++){
            data.add(i);
        }
        initView();
    }

    private void initView(){
        tvCollectionName = (TextView) findViewById(R.id.tvCollectionName);
        gRecyclerView = (RecyclerView) findViewById(R.id.gRecyclerView);
        FocusGridLayoutManager gridLayoutManager = new FocusGridLayoutManager(this ,5);
        gRecyclerView.setLayoutManager(gridLayoutManager);
        mAdapter = new GridAdapter(this);
        mAdapter.setData(data);
        View  headerView = LayoutInflater.from(this).inflate(R.layout.layout_header_view, gRecyclerView ,false);
        mAdapter.setHeaderView(headerView);
        gRecyclerView.setAdapter(mAdapter);

    }

     class GridAdapter extends BaseRecyclerViewAdapter{

         private Context mContext;
         private LayoutInflater lInflater;

         public GridAdapter(Context context){
             this.mContext = context;
             lInflater = LayoutInflater.from(context);
         }

        @Override
        protected BaseRecyclerViewHolder createItem(ViewGroup parent, int viewType) {
            MyViewHolder viewHolder;
            View view = lInflater.inflate(R.layout.item_grid_recycler_view , null);
            viewHolder = new MyViewHolder(view);
            viewHolder.tv = (TextView) view.findViewById(R.id.ttvv);
            return viewHolder;
        }

        @Override
        protected void bindData(BaseRecyclerViewHolder holder, int position) {
            ((MyViewHolder)holder).tv.setText("位置"+getItemData(position));
        }

         class MyViewHolder extends BaseRecyclerViewHolder{
            TextView tv;
            public MyViewHolder(View itemView) {
                super(itemView);
            }

            @Override
            protected View getView() {
                return null;
            }
        }
    }

}
