package com.example.beijing_daxing.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;

import com.example.beijing_daxing.R;
import com.example.beijing_daxing.databinding.DialogInputBinding;

/**
 * @author wanghao
 * @date 2024/2/21  14:33
 */
public class InPutDialog extends Dialog {
    private InPutDialogCall inPutDialogCall;
    private DialogInputBinding binding;

    public void setInPutDialogCall(InPutDialogCall inPutDialogCall) {
        this.inPutDialogCall = inPutDialogCall;
    }

    public InPutDialog(@NonNull Context context) {
        super(context, R.style.dialog);
        binding = DataBindingUtil.inflate(LayoutInflater.from(context),
                R.layout.dialog_input, null, false);
        setContentView(binding.getRoot());
        binding.dialogFalse.setOnClickListener(v -> dismiss());
        binding.dialogTrue.setOnClickListener(v -> {
            inPutDialogCall.inPutDialogReculi( binding.inputDialogSelect.getSelectedItem().toString());
        });
    }


    public interface InPutDialogCall {
        void inPutDialogReculi(String name);
    }



    @Override
    public void show() {
        super.show(); binding.inputDialogText.setText(null);
    }
}
