package com.prank.sounds.fart.frag;

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.sounds.fart.MyApp;
import com.prank.sounds.fart.bean.Info;
import com.prank.sounds.fart.bean.MyBean;
import com.prank.sounds.fart.databinding.FragHomeBinding;
import com.prank.sounds.fart.myadapter.AdapterHome;
import com.prank.sounds.fart.tools.MyItemDecoration;

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


public class FragHome extends Fragment {


    private FragHomeBinding binding;

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

    public FragHome() {
    }

    @SuppressWarnings("unused")
    public static FragHome newInstance() {
        FragHome fragment = new FragHome();
        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);

        MyItemDecoration itemHelper = new MyItemDecoration(10, 10, 10);
        binding.recyclerView.addItemDecoration(itemHelper);
        binding.recyclerView.setLayoutManager(new GridLayoutManager(requireContext(), 2));
        binding.recyclerView.setAdapter(new AdapterHome(requireContext(), MyApp.bean));
        initAudioData();


        return binding.getRoot();
    }

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

    private void initAudio() {

    }

}