package com.youra.qlicker.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import com.youra.qlicker.R;

public class SliderAdapter extends PagerAdapter {
    Context context;

    int sliders[] = {

            R.layout.slider_onbording1,
            R.layout.slider_onbording2,
            R.layout.slider_onbording3,
            R.layout.slider_onbording4

    };



    public SliderAdapter(Context context){

        this.context = context;

    }

    @Override
    public int getCount() {
        return  sliders.length;
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view == (RelativeLayout) object;
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {

        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
        View view = layoutInflater.inflate(sliders[position],container,false);

        container.addView(view);

        return view;

    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {

        container.removeView((RelativeLayout)object);

    }
}
