package com.keypalette.theme.activity;

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

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;

import com.keypalette.theme.AllAdapter;
import com.keypalette.theme.KeyApp;
import com.keypalette.theme.dataabout.resource.Data;
import com.keypalette.theme.databinding.PageSkinsAllBinding;
import com.keypalette.theme.dataabout.resource.WrapperData;
import com.keypalette.theme.other.Helper;
import com.keypalette.theme.other.ItemDecoration;

import java.util.List;

public class PageSkinsAll extends AppCompatActivity {
    private PageSkinsAllBinding vb;
    public static final String KEY_NAME = "class_name";
    private String name;
    private List<Data> data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        vb = PageSkinsAllBinding.inflate(getLayoutInflater());
        Helper.INSTANCE.initFullScreen(this, true);
        setContentView(vb.getRoot());
        ;
        name = getIntent().getStringExtra(KEY_NAME);
        initData();
        initClick();

    }

    private void initData() {
        vb.className.setText(name);
        for (WrapperData WrapperData : KeyApp.list) {
            if (WrapperData.getParentName().equals(name)) {
                data = WrapperData.getKeyboardList();
            }
        }
        ItemDecoration itemDecoration = new ItemDecoration(3, 3, 0);
        AllAdapter adapterMain = new AllAdapter(this);
        adapterMain.setForYouList(data);
        vb.recycler.setLayoutManager(new GridLayoutManager(PageSkinsAll.this, 2));
        vb.recycler.setAdapter(adapterMain);
        vb.recycler.addItemDecoration(itemDecoration);

    }

    private void initClick() {
        vb.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}