package com.keyboard.keyboardtheme.skin.act;

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

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

import com.keyboard.keyboardtheme.skin.MyApp;
import com.keyboard.keyboardtheme.skin.adapter.AdaList;
import com.keyboard.keyboardtheme.skin.databinding.ActViewAllBinding;
import com.keyboard.keyboardtheme.skin.datamanager.localdata.Child;
import com.keyboard.keyboardtheme.skin.datamanager.localdata.ParentData;
import com.keyboard.keyboardtheme.skin.utils.RecyclerDec;
import com.keyboard.keyboardtheme.skin.utils.Common;

import java.util.List;

public class ActViewAll extends AppCompatActivity {
    private ActViewAllBinding vb;
    public static final String KEY_NAME = "class_name";
    private String name;
    private List<Child> data;

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

    }

    private void initData() {
        vb.className.setText(name);
        for (ParentData ParentData : MyApp.list) {
            if (ParentData.getParentName().equals(name)) {
                data = ParentData.getKeyboardList();
            }
        }
        RecyclerDec recyclerDec = new RecyclerDec(3, 3, 0);
        AdaList adapterMain = new AdaList(this);
        adapterMain.setForYouList(data);
        vb.recycler.setLayoutManager(new GridLayoutManager(ActViewAll.this, 2));
        vb.recycler.setAdapter(adapterMain);
        vb.recycler.addItemDecoration(recyclerDec);

    }

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

}