package com.zkjc.common.view;

import android.content.Context;

import android.view.View;
import android.widget.TextView;


import androidx.viewpager.widget.PagerAdapter;

import com.zkjc.utils.R;

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

/**
 * ���ViewPager��ҳ��������
 */
public class LViewPagerAdapter extends PagerAdapter {
    private Context context;
    private List<String> texts;
    private List<View> list;

    public LViewPagerAdapter(Context context, List<String> texts) {
        this.context = context;
        this.texts = texts;
        list = new ArrayList<View>();
    }

    @Override
    public void destroyItem(View container, int position, Object object) {
        ((LazyViewPager) container).removeView(list.get(position));
    }

    @Override
    public Object instantiateItem(View container, int position) {
        View view = View.inflate(context, R.layout.layout_slide_item, null);
        TextView textView = (TextView) view.findViewById(R.id.tv_text);
        textView.setText(texts.get(position));
        list.add(view);
        ((LazyViewPager) container).addView(view);
        return view;
    }

    @Override
    public int getCount() {
        return texts.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }
}
