package com.app.keyboard.colorful.activity;

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

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

import com.app.keyboard.colorful.MyApp;
import com.app.keyboard.colorful.data.ChildBean;
import com.app.keyboard.colorful.databinding.ActivityViewAllBinding;
import com.app.keyboard.colorful.data.ClassBean;
import com.app.keyboard.colorful.ada.AdaOther;
import com.app.keyboard.colorful.helper.CommonUtils;
import com.app.keyboard.colorful.helper.ItemDec;

import java.util.List;

public class ActivityAll extends AppCompatActivity {
    private ActivityViewAllBinding vb;
    public static final String KEY_NAME ="class_name";
    private String name;
    private List<ChildBean> data;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        vb = ActivityViewAllBinding.inflate(getLayoutInflater());
        CommonUtils.INSTANCE.initFullScreen(this, true);
        setContentView(vb.getRoot());

        name = getIntent().getStringExtra(KEY_NAME);
        initData();
        initClick();
    }

    private void initData(){
        vb.className.setText(name);
        for (ClassBean classBean : MyApp.list) {
            if(classBean.getParentName().equals(name)){
                data = classBean.getKeyboardList();
            }
        }
        ItemDec itemDec = new ItemDec(3, 3, 0);
        AdaOther adapterMain = new AdaOther(this);
        adapterMain.setForYouList(data);
        vb.recycler.setLayoutManager(new GridLayoutManager(ActivityAll.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();
            }
        });
    }

}