package com.xunao.effectdemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.hpplay.sdk.source.browse.api.LelinkServiceInfo;
import com.xunao.effectdemo.R;

import java.util.List;

/**
 * author : 程中强
 * e-mail : 740479946@qq.com
 * date : 2022/9/2617:36
 * desc :
 * version: 1.0
 */
public class ClassItemAdapter extends RecyclerView.Adapter<ClassItemAdapter.ViewHolder> {

	private List<String> data;
	private Context context;

	public ClassItemAdapter(Context context, @Nullable List<String> data) {

		this.context = context;
		this.data = data;
	}

	@NonNull
	@Override
	public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext())
				.inflate(R.layout.item_class,parent,false);
		ViewHolder holder = new ViewHolder(view);
		return holder;

	}

	@Override
	public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
		if (position%2==0){
			holder.v.setVisibility(View.GONE);
		}else{
			holder.v.setVisibility(View.VISIBLE);
		}
	}

	@Override
	public int getItemCount() {
		return data.isEmpty()?null:data.size();
	}


	public static class ViewHolder extends RecyclerView.ViewHolder {

		private View v;

		public ViewHolder(@NonNull View itemView) {
			super(itemView);
			v = itemView.findViewById(R.id.view);
		}
	}
}
