package com.key.simplekeyboard.fragment;

import android.os.Bundle;

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

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.key.simplekeyboard.R;
import com.key.simplekeyboard.SimpleKeyboardSkins;
import com.key.simplekeyboard.adapter.ThumAdapter;
import com.key.simplekeyboard.data.MydataBase;
import com.key.simplekeyboard.data.Otherdata;
import com.key.simplekeyboard.tools.Mytools;
import com.key.simplekeyboard.tools.SpaceItem;

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

public class AllFragment extends Fragment {
    private List<Otherdata> alllist = new ArrayList<>();
    private List<Otherdata> lovelist = new ArrayList<>();
    private List<Otherdata> coollist = new ArrayList<>();
    private List<Otherdata> cutelist = new ArrayList<>();
    private List<Otherdata> neonlist = new ArrayList<>();
    private List<Otherdata> festivallist = new ArrayList<>();
    private List<Otherdata> gravitylist = new ArrayList<>();
    private List<Otherdata> aestheticlist = new ArrayList<>();
    private List<Otherdata> superlist = new ArrayList<>();
    private RecyclerView allrv;
    private ThumAdapter thumAdapter;
    private List<Otherdata> dataList = new ArrayList<>();
    private SpaceItem spaceItem = new SpaceItem(12, 12, 12);
    private String tabargs;
    private String[] listtext = {"ALL", "Love", "Cool", "Cute", "Neon", "Festival", "Gravity", "Aesthetic", "Super Theme"};

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_all, container, false);

        allrv = view.findViewById(R.id.all_rv);

        tabargs = getArguments().getString("tab");
        if (tabargs.equals("ALL")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getAlllist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Love")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getLovelist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Cool")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getCoollist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Cute")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getCutelist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Neon")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getNeonlist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Festival")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getFestivallist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Gravity")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getGravitylist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Aesthetic")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getAestheticlist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        } else if (tabargs.equals("Super Theme")) {
            thumAdapter = new ThumAdapter(requireContext(), SimpleKeyboardSkins.getSuperlist());
            allrv.setLayoutManager(new GridLayoutManager(requireContext(), 2));
            allrv.setAdapter(thumAdapter);
        }
        allrv.addItemDecoration(spaceItem);

        return view;
    }


    public static AllFragment newInstance(String pos) {

        Bundle args = new Bundle();

        AllFragment fragment = new AllFragment();
        args.putString("tab", pos);
        fragment.setArguments(args);
        return fragment;
    }
}