package com.prankster.fx.ui.activity;

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

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

import com.gyf.immersionbar.ImmersionBar;
import com.prankster.fx.R;
import com.prankster.fx.ui.adapter.AllAdapter;
import com.prankster.fx.databinding.ActivityAllBinding;
import com.prankster.fx.db.Category;
import com.prankster.fx.topon.AdManager;
import com.prankster.fx.utils.ConstValues;
import com.prankster.fx.utils.MyDecoration;

public class FXAllActivity extends AppCompatActivity implements View.OnClickListener {

    private ActivityAllBinding activityListBinding;
    private Category data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AdManager.loadAllAd();
        activityListBinding = ActivityAllBinding.inflate(getLayoutInflater());
        setContentView(activityListBinding.getRoot());
        ImmersionBar.with(this)
                .statusBarColor(R.color.white)
                .statusBarDarkFont(true)
                .statusBarView(activityListBinding.view)
                .init();
        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();
        }

    }
}