package com.example.wallpapermagazine.fragment;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;

import com.example.wallpapermagazine.R;
import com.example.wallpapermagazine.WallPaperSelect;
import com.example.wallpapermagazine.adapter.adapter.MycataAdapter;
import com.example.wallpapermagazine.json.Info;
import com.example.wallpapermagazine.json.Info_data;
import com.example.wallpapermagazine.CataItemActivity;
import com.google.android.material.navigation.NavigationView;

import java.util.ArrayList;
import java.util.List;

public class FragmentCate extends Fragment {
    private ListView listView;
    private DrawerLayout drawerLayout;
    private ImageView imageView;
    private NavigationView navigationView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.layout_cate, container, false);
        listView = view.findViewById(R.id.list_catagray);
        imageView = view.findViewById(R.id.cate_more);


        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                drawerLayout = requireActivity().findViewById(R.id.dlt_main);
                drawerLayout.openDrawer(GravityCompat.START);
            }
        });
        MycataAdapter adapter = new MycataAdapter(getActivity(), WallPaperSelect.getCataName());
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getActivity(), CataItemActivity.class);
                intent.putExtra("position", position);
                startActivity(intent);
            }
        });
        return view;
    }



}
