package com.jimind.sportdemo.base;

import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.View;

/**
 * 普通item的holder
 *
 * @author Any
 */

public class BaseViewHolder extends RecyclerView.ViewHolder {

    private View mItemView;
    private SparseArray<View> views;

    public BaseViewHolder(View itemView) {
        super(itemView);
        this.mItemView=itemView;
        this.views = new SparseArray<>();
    }

    @SuppressWarnings("unchecked")
    public <T extends View> T getView(int viewId) {
        View view = views.get(viewId);
        if (view == null) {
            view = mItemView.findViewById(viewId);
            views.put(viewId, view);
        }
        return (T) view;
    }
}

