package com.hh.holyolm;

import android.os.Bundle;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.hh.holyolm.databinding.ActivityMainBinding;
import com.hh.holyolm.util.Utils;

import java.io.File;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding binding;
    private File libsDir;
    private File taskDir;
    private File downDir;

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

        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        BottomNavigationView navView = findViewById(R.id.nav_view);
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_task, R.id.navigation_com_lib, R.id.navigation_opt_lib,R.id.navigation_setting)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_activity_main);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(binding.navView, navController);

        libsDir=Utils.initLibsDir(this);
        taskDir=Utils.initTaskDir(this);
        downDir=Utils.initDownDir(this);

    }

    public File getLibsDir() {
        return libsDir==null?Utils.initLibsDir(this):libsDir;
    }

    public File getTaskDir() {
        return taskDir==null?Utils.initTaskDir(this):taskDir;
    }

    public File getDownDir() {
        return downDir==null?Utils.initDownDir(this):downDir;
    }
}