package com.artisanic.helper.artui;

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.artisanic.helper.artadapter.MainAdapter;
import com.artisanic.helper.test.databinding.FragmentMainBinding;

public class MainFragment extends Fragment {
    private FragmentMainBinding fragmentHomeBinding;

    public MainFragment() {}

    public static MainFragment newInstance() {
        MainFragment fragment = new MainFragment();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        fragmentHomeBinding = FragmentMainBinding.inflate(getLayoutInflater());
        onInitRecycler();
        return fragmentHomeBinding.getRoot();
    }

    private void onInitRecycler() {
        MainAdapter homeAdapter = new MainAdapter(requireContext());
        fragmentHomeBinding.recyclerview.setAdapter(homeAdapter);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(requireContext(), 2);
        fragmentHomeBinding.recyclerview.setLayoutManager(gridLayoutManager);
    }
}