package com.color.keyboard.black.activity;

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

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

import com.color.keyboard.black.ColorApp;
import com.color.keyboard.black.adapter.AdapterHomeChild;
import com.color.keyboard.black.bean.ChildData;
import com.color.keyboard.black.bean.ClassData;
import com.color.keyboard.black.databinding.LayoutSeeAllBinding;
import com.color.keyboard.black.manager.Common;
import com.color.keyboard.black.manager.Space;
import com.color.keyboard.black.max.MaxManager;
import com.color.keyboard.black.max.onAdAfterAction;

import java.util.List;

public class SeeActivity extends AppCompatActivity {
    private LayoutSeeAllBinding 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 = LayoutSeeAllBinding.inflate(getLayoutInflater());
        Common.INSTANCE.initFullScreen(this, true);
        setContentView(vb.getRoot());

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

    private void initData() {

        MaxManager.onLoadAd();
        MaxManager.startShowMaxAd(this, new onAdAfterAction() {
            @Override
            public void onAction() {

            }
        });

        vb.className.setText(name);
        for (ClassData classData : ColorApp.list) {
            if (classData.getParentName().equals(name)) {
                data = classData.getKeyboardList();
            }
        }
        Space space = new Space(3, 3, 0);
        AdapterHomeChild adapterMain = new AdapterHomeChild(this, data);
        vb.recycler.setLayoutManager(new GridLayoutManager(SeeActivity.this, 2));
        vb.recycler.setAdapter(adapterMain);
        vb.recycler.addItemDecoration(space);

    }

    private void initClick() {
        vb.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MaxManager.startShowMaxAd(SeeActivity.this, new onAdAfterAction() {
                    @Override
                    public void onAction() {
                        finish();
                    }
                });
            }
        });
    }

}