package com.tenlionsoft.baselib.core.widget.views;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.tenlionsoft.baselib.R;

import razerdp.basepopup.BasePopupWindow;


/**
 * 作者: adam
 * 日期: 2021/9/30 - 2:58 下午
 * 邮箱: itgaojian@163.com
 * 描述:
 */
public class EditOrDelPopup extends BasePopupWindow {
    private OnItemClick mOnItemClick;

    public EditOrDelPopup(Context context) {
        super(context);
        View view = createPopupById(R.layout.popup_edit_del_layout);
        TextView tvEdit = view.findViewById(R.id.tv_edit);
        TextView tvDel = view.findViewById(R.id.tv_del);
        setContentView(view);
        setPopupGravity(Gravity.BOTTOM | Gravity.CENTER);
        setViewClickListener(v -> {
            int id = v.getId();
            if (id == R.id.tv_del) {
                mOnItemClick.onDel();
            } else {
                mOnItemClick.onEdit();
            }
        }, tvEdit, tvDel);
    }


    public void addOnItemClick(OnItemClick listener) {
        this.mOnItemClick = listener;
    }

    public interface OnItemClick {
        void onEdit();

        void onDel();
    }
}
