package com.app.sounds.prank.party.act;

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.app.sounds.prank.party.PartyApp;
import com.app.sounds.prank.party.bean.Info;
import com.app.sounds.prank.party.bean.MyBean;
import com.app.sounds.prank.party.common.ItemSpace;
import com.app.sounds.prank.party.databinding.HomeFragmentBinding;
import com.app.sounds.prank.party.list.AdaMain;

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


public class MainFragment extends Fragment {


    private HomeFragmentBinding binding;

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

    public MainFragment() {
    }

    @SuppressWarnings("unused")
    public static MainFragment newInstance() {
        MainFragment fragment = new MainFragment();
        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 = HomeFragmentBinding.inflate(inflater);

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


        return binding.getRoot();
    }

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

    private void initAudio() {

    }

}