package com.paint.trace.drawing.view;

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

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

import com.paint.trace.drawing.databinding.ActivityCategoryBinding;
import com.paint.trace.drawing.item.ClassAdapter;
import com.paint.trace.drawing.other.Utils;
import com.paint.trace.drawing.topon.AdManager;

import java.util.List;

public class CatogryActivity extends AppCompatActivity {

    private ActivityCategoryBinding preViewBinding;

    private String dirStr;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AdManager.loadAllAd();
        preViewBinding = ActivityCategoryBinding.inflate(getLayoutInflater());
        setContentView(preViewBinding.getRoot());
        Utils.setStatusBarTextColor(this, true);
        dirStr = getIntent().getStringExtra(MyApplication.Key_ViewDir);
        preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_") + 1));



        onInitList();
        onInitClick();
    }

    private void onInitList() {

        List<String> list = Utils.fileExistsInAssets(this, dirStr);

        ClassAdapter classAdapter = new ClassAdapter(this, list);
        preViewBinding.recyclerview.setAdapter(classAdapter);
        preViewBinding.recyclerview.setLayoutManager(new GridLayoutManager(this, 3));
    }

    private void onInitClick() {
        preViewBinding.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }




}