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

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lc.myapplication.security.mysoundstwo.R;
import com.lc.myapplication.security.mysoundstwo.ScaryPrank;
import com.lc.myapplication.security.mysoundstwo.activity.SettingActivity;
import com.lc.myapplication.security.mysoundstwo.adapter.SoundsListAdapter;
import com.lc.myapplication.security.mysoundstwo.value.MySpace;

public class SoundsFragment extends Fragment {
    private TextView sounds_title;
    private RecyclerView recyclerView_sounds;
    private ImageView main_image_set;
    @SuppressLint("MissingInflatedId")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view =  inflater.inflate(R.layout.fragment_sounds, container, false);
        recyclerView_sounds = view.findViewById(R.id.fra_recycle_sounds);
        sounds_title = view.findViewById(R.id.sounds_title);
        sounds_title.setTypeface(Typeface.createFromAsset(getActivity().getAssets(),"myfront1.ttf"));
        main_image_set = view.findViewById(R.id.main_image_set);
        main_image_set.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(), SettingActivity.class);
                startActivity(intent);
            }
        });
        setRecycleSounds();
        return view;
    }
    private void setRecycleSounds() {
        MySpace mySpace = new MySpace(1,20,1);
        GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2);
        recyclerView_sounds.setLayoutManager(gridLayoutManager);
        recyclerView_sounds.addItemDecoration(mySpace);
        SoundsListAdapter soundsAdapter = new SoundsListAdapter(getActivity(), ScaryPrank.getList());
        recyclerView_sounds.setAdapter(soundsAdapter);
    }
}