package com.example.administrator.zhapp.weight;

import android.content.Context;
import androidx.appcompat.app.AlertDialog;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.zhapp.R;

/**
 * Created by gzw on 2016/8/17.
 */

public class PdDialog {

    private Context mContext;
    private AlertDialog dialog;
    private TextView tv_title;
    private TextView tv_message;
    private Button btn_fg;
    private Button btn_xj;
    private Button btn_qx;
    private Window mWindow;

    public PdDialog(Context context) {
        mContext = context;

        dialog = new AlertDialog.Builder(context).create();
        dialog.setCancelable(true);
        dialog.show();
        mWindow = dialog.getWindow();
        mWindow.setContentView(R.layout.pd_dialog);
        tv_title = (TextView) mWindow.findViewById(R.id.tv_title);
        tv_message = (TextView) mWindow.findViewById(R.id.tv_message);
        btn_fg = (Button) mWindow.findViewById(R.id.btn_fg);
        btn_qx = (Button) mWindow.findViewById(R.id.btn_qx);
        btn_xj = (Button) mWindow.findViewById(R.id.btn_xj);
    }

    /**
     * 覆盖点击事件
     *
     * @param listener
     */
    public void setFgOnClick(View.OnClickListener listener) {
        btn_fg.setOnClickListener(listener);
    }

    /**
     * 相加点击事件
     *
     * @param listener
     */
    public void setXjOnClick(View.OnClickListener listener) {
        btn_xj.setOnClickListener(listener);
    }

    /**
     * 取消点击事件
     *
     * @param listener
     */
    public void setQxOnClick(View.OnClickListener listener) {
        btn_qx.setOnClickListener(listener);
    }

    /**
     * 设置Title
     *
     * @param title
     */
    public void setTitle(String title) {
        tv_title.setText(title);
    }

    /**
     * 设置message
     *
     * @param message
     */
    public void setMessage(String message) {
        tv_message.setText(message);
    }

    public void close() {
        dialog.dismiss();
    }
}
