package com.prank.simulator.sounds.actfrag;

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

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

import com.prank.simulator.sounds.data.Category;
import com.prank.simulator.sounds.databinding.ActInfoBinding;
import com.prank.simulator.sounds.helper.ItemHelper;
import com.prank.simulator.sounds.helper.Static;
import com.prank.simulator.sounds.helper.Utils;
import com.prank.simulator.sounds.recycler.SecondAdapter;

public class SecondActivity extends AppCompatActivity implements View.OnClickListener {

    private ActInfoBinding activityListBinding;
    private Category data;
    private int colorIndex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Utils.setStatusBarTextColor(this,true);
        activityListBinding = ActInfoBinding.inflate(getLayoutInflater());
        setContentView(activityListBinding.getRoot());
        data = (Category) getIntent().getSerializableExtra(Static.KEY_LIST_DATA);
        colorIndex =  getIntent().getIntExtra(Static.KEY_LIST_COLOR_POS,0);
        activityListBinding.categoryName.setText(data.getName());
        onList();
        activityListBinding.back.setOnClickListener(this);
    }

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

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

    }
}