package com.themes.keyboard.black.activity;

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

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

import com.themes.keyboard.black.MyApp;
import com.themes.keyboard.black.databinding.ActivityViewAllBinding;
import com.themes.keyboard.black.localdata.ChildData;
import com.themes.keyboard.black.localdata.ClassData;
import com.themes.keyboard.black.recycler.AdapterOther;
import com.themes.keyboard.black.utils.Common;
import com.themes.keyboard.black.utils.ItemDec;

import java.util.List;

public class ViewAllActivity extends AppCompatActivity {
    private ActivityViewAllBinding vb;
    public static final String KEY_NAME ="class_name";
    private String name;
    private List<ChildData> data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        vb = ActivityViewAllBinding.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 (ClassData classData : MyApp.list) {
            if(classData.getParentName().equals(name)){
                data = classData.getKeyboardList();
            }
        }
        ItemDec itemDec = new ItemDec(3, 3, 0);
        AdapterOther adapterMain = new AdapterOther(this);
        adapterMain.setForYouList(data);
        vb.recycler.setLayoutManager(new GridLayoutManager(ViewAllActivity.this,2));
        vb.recycler.setAdapter(adapterMain);
        vb.recycler.addItemDecoration(itemDec);

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

}