package com.ar.drawing.art.activity;

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

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

import com.ar.drawing.art.adapter.AdaAllList;
import com.ar.drawing.art.databinding.UiAllListBinding;
import com.ar.drawing.art.utils.ArtApp;
import com.ar.drawing.art.utils.Common;
import com.ar.drawing.art.utils.ItemDec;

import java.util.List;

public class UIAllList extends AppCompatActivity {

    private UiAllListBinding preViewBinding;

    private String dirStr;


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

        preViewBinding = UiAllListBinding.inflate(getLayoutInflater());
        setContentView(preViewBinding.getRoot());
        Common.setStatusBarTextColor(this, true);
        dirStr = getIntent().getStringExtra(ArtApp.Key_ViewDir);
        preViewBinding.categoryName.setText(dirStr.substring(dirStr.lastIndexOf("_") + 1));



        onInitList();
        onInitClick();
    }

    private void onInitList() {

        List<String> list = Common.fileExistsInAssets(this, dirStr);
        ItemDec itemDec = new ItemDec(10, 10, 5);
        AdaAllList adaAllList = new AdaAllList(this, list);
        preViewBinding.recyclerview.setAdapter(adaAllList);
        preViewBinding.recyclerview.addItemDecoration(itemDec);
        preViewBinding.recyclerview.setLayoutManager(new GridLayoutManager(this, 2));
    }

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




}