package com.casic.dcms.view.statistics;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.casic.dcms.R;
import com.casic.dcms.adapter.NormalRecyclerAdapter;
import com.casic.dcms.databinding.ActivityCaseAnalysisBinding;
import com.casic.dcms.model.DataAnalysisGridModel;
import com.casic.dcms.utils.LocaleConstant;
import com.casic.dcms.utils.ViewGroupKit;
import com.pengxh.androidx.lite.adapter.ViewHolder;
import com.pengxh.androidx.lite.base.AndroidxBaseActivity;
import com.pengxh.androidx.lite.kit.ContextKit;

import java.util.ArrayList;

/**
 * @author : Pengxh
 * @time : 2021/4/15 16:03
 * @email : 290677893@qq.com
 */
public class DataAnalysisActivity extends AndroidxBaseActivity<ActivityCaseAnalysisBinding> {

    private final Context context = DataAnalysisActivity.this;

    @Override
    protected void setupTopBarLayout() {
        ViewGroupKit.initImmersionBar(binding.rootView, this, true, R.color.white);

        binding.titleBarLayout.titleView.setText("统计分析");
        binding.titleBarLayout.leftBackView.setOnClickListener(v -> finish());
    }

    @Override
    protected void observeRequestState() {

    }

    @Override
    protected void initOnCreate(@Nullable Bundle savedInstanceState) {
        ArrayList<DataAnalysisGridModel> models = new ArrayList<>();
        for (int i = 0; i < 7; i++) {
            DataAnalysisGridModel model = new DataAnalysisGridModel();
            model.setItemIcon(LocaleConstant.ANALYSIS_ICONS.get(i));
            model.setItemTitle(LocaleConstant.ANALYSIS_ITEMS.get(i));
            models.add(model);
        }

        NormalRecyclerAdapter<DataAnalysisGridModel> adapter = new NormalRecyclerAdapter<DataAnalysisGridModel>(R.layout.item_home_rv_g, models) {

            @Override
            public void convertView(ViewHolder viewHolder, int position, DataAnalysisGridModel item) {
                viewHolder.setImageResource(R.id.imageView, item.getItemIcon()).setText(R.id.textView, item.getItemTitle());
            }
        };
        binding.analysisRecyclerView.setAdapter(adapter);
        adapter.setOnItemClickedListener(new NormalRecyclerAdapter.OnItemClickedListener<DataAnalysisGridModel>() {
            @Override
            public void onItemClicked(int position, DataAnalysisGridModel dataAnalysisGridModel) {
                Intent intent = new Intent();
                switch (position) {
                    case 0:
                        ContextKit.navigatePageTo(context, CityBaseDataActivity.class);
                        break;
                    case 1:
                        ContextKit.navigatePageTo(context, CaseResourceActivity.class);
                        break;
                    case 2:
                        ContextKit.navigatePageTo(context, HighEventActivity.class);
                        break;
                    case 3:
                        ContextKit.navigatePageTo(context, DeptHandleConditionActivity.class);
                        break;
                    case 4:
                        ContextKit.navigatePageTo(context, GridAnalysisActivity.class);
                        break;
                    case 5:
                        ContextKit.navigatePageTo(context, TrendAnalysisActivity.class);
                        break;
                    case 6:
                        ContextKit.navigatePageTo(context, PunishAnalysisActivity.class);
                        break;
                }
            }
        });
    }

    @Override
    protected void initEvent() {

    }
}