package com.prank.master.ui;

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

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

import com.prank.master.adapter.AllAdapter;
import com.prank.master.databinding.ActivityAllBinding;
import com.prank.master.db.Category;
import com.prank.master.utils.CommonUtils;
import com.prank.master.utils.ConstValues;
import com.prank.master.utils.MyDecoration;

public class AllActivity extends AppCompatActivity implements View.OnClickListener {

    private ActivityAllBinding activityListBinding;
    private Category data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        CommonUtils.setStatusBarTextColor(this,true);
        activityListBinding = ActivityAllBinding.inflate(getLayoutInflater());
        setContentView(activityListBinding.getRoot());
        data = (Category) getIntent().getSerializableExtra(ConstValues.KEY_LIST_DATA);
        activityListBinding.categoryName.setText(data.getName());
        onList();
        activityListBinding.back.setOnClickListener(this);
    }

    private void onList() {
        MyDecoration myDecoration = new MyDecoration(10, 10, 5);
        activityListBinding.listRecycler.addItemDecoration(myDecoration);
        activityListBinding.listRecycler.setLayoutManager(new GridLayoutManager(this, 3));
        AllAdapter allAdapter = new AllAdapter(this, data.getBeanList());
        activityListBinding.listRecycler.setAdapter(allAdapter);
    }

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

    }
}