package com.prank.sound.app.pageview;

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

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

import com.prank.sound.app.adapter.InfoAdapter;
import com.prank.sound.app.databinding.LayoutInfoBinding;
import com.prank.sound.app.mydata.Category;
import com.prank.sound.app.myutils.ItemHelper;
import com.prank.sound.app.myutils.MyValues;
import com.prank.sound.app.myutils.Utils;
import com.prank.sound.app.topon.AdManager;
import com.prank.sound.app.topon.onActionListener;

public class InfoActivity extends AppCompatActivity implements View.OnClickListener {

    private LayoutInfoBinding activityListBinding;
    private Category data;
    private int colorIndex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Utils.setStatusBarTextColor(this,true);
        AdManager.loadAllAd();
        activityListBinding = LayoutInfoBinding.inflate(getLayoutInflater());
        setContentView(activityListBinding.getRoot());
        data = (Category) getIntent().getSerializableExtra(MyValues.KEY_LIST_DATA);
        colorIndex =  getIntent().getIntExtra(MyValues.KEY_LIST_COLOR_POS,0);
        activityListBinding.categoryName.setText(data.getName());
        onList();
        activityListBinding.back.setOnClickListener(this);
        AdManager.showTopOn(this, new onActionListener() {
            @Override
            public void onAction() {

            }
        });
    }

    private void onList() {
        ItemHelper itemHelper = new ItemHelper(10, 10, 5);
        activityListBinding.listRecycler.addItemDecoration(itemHelper);
        activityListBinding.listRecycler.setLayoutManager(new GridLayoutManager(this, 3));
        InfoAdapter infoAdapter = new InfoAdapter(this, data.getChildDataList(),colorIndex);
        activityListBinding.listRecycler.setAdapter(infoAdapter);
    }

    @Override
    public void onClick(View v) {
        if(v.equals(activityListBinding.back)){
            finish();
        }

    }
}