package com.app.paintingstool.myact;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.Fragment;

import com.app.paintingstool.R;
import com.app.paintingstool.databinding.ActivityPaintingBinding;
import com.app.paintingstool.myadapter.MyPagerAdapter;
import com.app.paintingstool.myfrg.PaintFragment;
import com.app.paintingstool.myuntils.Keys;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class PaintingActivity extends AppCompatActivity {
private ActivityPaintingBinding binding;
    private final List<String> nameLists=Keys.getAllDir();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        binding = ActivityPaintingBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        tabLayout();
        binding.back.setOnClickListener(v -> {
            finish();
        });
    }

    private void tabLayout() {
        MyPagerAdapter adapter = new MyPagerAdapter(this); // 创建您自己的适配器
        binding.viewpager.setAdapter(adapter);
        binding.viewpager.setOffscreenPageLimit(1);
        new TabLayoutMediator(binding.tablayout,binding.viewpager,(tab, position) -> {
            String dir=nameLists.get(position);
            tab.setText(dir.substring(dir.lastIndexOf("_") + 1));
        }).attach();
    }


}