package com.lc.myapplication.security.mysoundstwo.activity;

import android.os.Bundle;
import android.os.Parcelable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TableLayout;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
import com.lc.myapplication.security.mysoundstwo.R;
import com.lc.myapplication.security.mysoundstwo.adapter.FragmentAdapter;

public class MainActivity extends AppCompatActivity {

    private ViewPager2 main_viewpapre;
    private RelativeLayout main_relayout;
    private TabLayout main_tablelayout;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gotofindview();
        setbackground();
        setViewPaper();
    }

    private void setbackground() {
        Window window = getWindow();
        window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        main_relayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    }

    private void setViewPaper() {
        main_viewpapre.setAdapter(new FragmentAdapter(this));
        TabLayoutMediator tabLayoutMediator = new TabLayoutMediator(main_tablelayout, main_viewpapre, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                switch (position) {
                    case 0:
                        tab.setIcon(R.drawable.sounds_src);
                        break;
                    case 1:
                        tab.setIcon(R.drawable.add_src);
                        break;
                    case 2:
                        tab.setIcon(R.drawable.win_src);
                        break;
                    case 3:
                        tab.setIcon(R.drawable.like_src);
                        break;
                }
            }
        });
        tabLayoutMediator.attach();
    }

    private void gotofindview() {
        main_relayout = findViewById(R.id.main_relayout);
        main_viewpapre = findViewById(R.id.main_viewpaper);
        main_tablelayout = findViewById(R.id.main_tablelayout);
    }
}