package com.prank.funny.pranks.pager;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;

import com.prank.funny.pranks.FunnyApp;
import com.prank.funny.pranks.adapter.AdMain;
import com.prank.funny.pranks.bean.Info;
import com.prank.funny.pranks.bean.MyBean;
import com.prank.funny.pranks.databinding.FragHomeBinding;
import com.prank.funny.pranks.tools.ItemSpace;

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


public class FragmentMain extends Fragment {


    private FragHomeBinding binding;

    private List<Info> list;
    private boolean first = true;

    public FragmentMain() {
    }

    @SuppressWarnings("unused")
    public static FragmentMain newInstance() {
        FragmentMain fragment = new FragmentMain();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragHomeBinding.inflate(inflater);

        ItemSpace itemHelper = new ItemSpace(10, 10, 10);
        binding.recyclerView.addItemDecoration(itemHelper);
        binding.recyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
        binding.recyclerView.setAdapter(new AdMain(requireContext(), FunnyApp.bean));
        initAudioData();


        return binding.getRoot();
    }

    private void initAudioData() {
        list = new ArrayList<>();
        for (MyBean category : FunnyApp.bean) {
            list.addAll(category.getInfoList());
        }
        initAudio();
    }

    private void initAudio() {

    }

}