package com.zztrapp.zztrapp.ui.currency;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.zztrapp.zztrapp.bean.CurrencyBean;
import com.zztrapp.zztrapp.databinding.FragmentCurrencyBinding;
import com.zztrapp.zztrapp.ui.currency.activity.FaLvFaGuiActivity;
import com.zztrapp.zztrapp.ui.currency.activity.SpecialTasksActivity;
import com.zztrapp.zztrapp.ui.currency.activity.VideoconferencingActivity;
import com.zztrapp.zztrapp.ui.currency.adapter.CurrencyAdapter;

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

/**
 * Describe 通用
 * Created by Bby on 2022/6/22
 * Email bby0856@163.com
 */
public class CurrencyFragment extends Fragment {

    private FragmentCurrencyBinding binding;
    private CurrencyAdapter adapter;

    public CurrencyFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = FragmentCurrencyBinding.inflate(inflater, container, false);
        init();
        return binding.getRoot();
    }

    private void init() {
        List<CurrencyBean> list = new ArrayList<>();
        list.add(new CurrencyBean("专项任务", "", 1));
        list.add(new CurrencyBean("视频会议", "面对面视频会议", 2));
        list.add(new CurrencyBean("法律法规", "", 3));
        binding.rv.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
        adapter = new CurrencyAdapter(getContext());
        binding.rv.setAdapter(adapter);
        adapter.setData(list);
        adapter.setOnItemClickListener(new CurrencyAdapter.OnItemClickListener() {
            @Override
            public void onEnterClick(int type) {
                switch (type) {
                    case 1:
                        startActivity(new Intent(getContext(), SpecialTasksActivity.class));
                        break;
                    case 2:
                        startActivity(new Intent(getContext(), VideoconferencingActivity.class));
                        break;
                    case 3:
                        startActivity(new Intent(getContext(), FaLvFaGuiActivity.class));
                        break;
                }
            }
        });
    }
}