package com.dskj.daikuan.ui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.dskj.daikuan.R;
import com.dskj.daikuan.adapter.comm.CommonAdapter;
import com.dskj.daikuan.adapter.comm.ViewHolder;
import com.dskj.daikuan.bean.BankBean;
import com.dskj.daikuan.ui.activity.MainActivity;
import com.dskj.daikuan.ui.activity.XiangQingActivity;
import com.dskj.daikuan.viewModel.home.SwitchVideoModel;

import java.util.List;

public class BankListDialog extends Dialog {

    private Context mContext;

    private RecyclerView switchDialogList;


    OnListItemClickListener onNextCallListener;

    private List<BankBean> data;

    public interface OnListItemClickListener {
        void onItemClick(BankBean position);
    }
    public void setOntoAlbumListener(OnListItemClickListener onNextCallListener) {
        this.onNextCallListener = onNextCallListener;
    }
    public BankListDialog(Context context,List<BankBean> data) {
        super(context, R.style.dialog_style);
        this.mContext = context;
        this.data = data;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bank_dialog);

        switchDialogList = findViewById(R.id.switch_dialog_list);

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        switchDialogList.setLayoutManager(linearLayoutManager);
        CommonAdapter commonAdapter = new CommonAdapter<>(getContext(), R.layout.switch_video_dialog_item, data) {
            @Override
            public void convert(ViewHolder holder, BankBean s, int index) {
                holder.setText(R.id.top_name, s.getName());
                holder.getView(R.id.top_name).setOnClickListener(view -> {
                    dismiss();
                    if (onNextCallListener != null) {
                        onNextCallListener.onItemClick(s);
                    }
                });
            }
        };
        switchDialogList.setAdapter(commonAdapter);

        Window window = getWindow();
        WindowManager.LayoutParams wlp = window.getAttributes();
        wlp.gravity = Gravity.BOTTOM;
        wlp.width = WindowManager.LayoutParams.MATCH_PARENT;
        wlp.height = WindowManager.LayoutParams.WRAP_CONTENT;


        window.setAttributes(wlp);
    }




}
