package com.sound.prankparty.FirstFragment;

import android.os.Bundle;

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

import com.sound.prankparty.JSON.Category;
import com.sound.prankparty.JSON.SoundItem;
import com.sound.prankparty.R;
import com.sound.prankparty.Utils.ItemDecoration;

import java.util.List;

public class AirHornActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_airhonr);

        RecyclerView recyclerView = findViewById(R.id.air_horn_recyclerview);
        recyclerView.setLayoutManager(new GridLayoutManager(this, 2));

        // 接收传递的 List<Category> 对象
        Category categories = (Category) getIntent().getSerializableExtra("123");

        if (categories == null) {
            // 处理 categories 为 null 的情况
            return;
        }
        List<SoundItem> soundItemList = categories.getSoundItemList();

        recyclerView.setAdapter(new AirHornRecyclerViewAdapter(this, soundItemList));

        // 为 RecyclerView 添加自定义的间距装饰。
        ItemDecoration itemDecoration = new ItemDecoration(16, 19, 10);
        recyclerView.addItemDecoration(itemDecoration);

    }
}
