package com.trace.ar.drawing.activity;

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

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

import com.trace.ar.drawing.ARApp;
import com.trace.ar.drawing.adapter.ViewAllAdapter;
import com.trace.ar.drawing.databinding.ActivityViewAllBinding;
import com.trace.ar.drawing.helper.Utils;

import java.util.List;

public class ViewAllActivity extends AppCompatActivity {

    private ActivityViewAllBinding preViewBinding;

    private String dirStr;


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



        onInitList();
        onInitClick();
    }

    private void onInitList() {

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

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

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




}