package com.haircut.pranks.app.uiview;

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

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

import com.haircut.pranks.app.data.ChildData;
import com.haircut.pranks.app.data.ParentData;
import com.haircut.pranks.app.databinding.ActivityChildBinding;
import com.haircut.pranks.app.listener.ListenerSounds;
import com.haircut.pranks.app.manager.RecyclerSpace;
import com.haircut.pranks.app.manager.Tools;
import com.haircut.pranks.app.recyadapter.AdapterChild;

public class ActChild extends AppCompatActivity implements View.OnClickListener, ListenerSounds {

    private ActivityChildBinding activityListBinding;
    private ParentData data;
    private int colorIndex;

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

    private void onList() {
        RecyclerSpace itemHelper = new RecyclerSpace(10, 10, 0);
        activityListBinding.listRecycler.addItemDecoration(itemHelper);
        activityListBinding.listRecycler.setLayoutManager(new GridLayoutManager(this, 3));
        AdapterChild adapterChild = new AdapterChild(this, data.getChildDataList(),0,this);
        activityListBinding.listRecycler.setAdapter(adapterChild);
    }

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

    }

    @Override
    public void onClickSoundsListener(ChildData data) {
        Intent intent = new Intent(this, ActPlaySounds.class);
        intent.putExtra(Tools.KEY_PLAY_DATA, data);
         startActivity(intent);
    }
}