/*
 * Copyright (c) 2015. Ncomz. All Rights Reserved
 */

package com.ntels.onecable.view.dialog;

import com.ntels.onecable.R;
import com.ntels.onecable.common.util.Dlog;
import com.ntels.onecable.common.util.Util;

import android.app.Dialog;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.text.DecimalFormat;
import java.util.Calendar;

/**
 * <pre>
 * 1. ClassName :   DialogDate
 * 2. FileName  :   DialogDate.java
 * 3. Package   :   com.ntels.onecable.view.dialog
 * 4. Date      :   2016-12-02
 * 5. Author    :   aaron
 * 6. Comment   :   Initialize
 * </pre>
 */
public class DialogDate extends Dialog implements View.OnClickListener {

    private Util mUtil = new Util();
    private String mDate = "";
    private String mMinDate = "";
    private String mMaxDate = "";
    private String mTitle = "";
    private String mBtn1 = "";
    private String mBtn2 = "";
    private String mYear = "";
    private String mMon = "";
    private String mDay = "";
    private TextView mUpYearTextView;
    private TextView mUpMonTextView;
    private TextView mUpDayTextView;
    private TextView mDownYearTextView;
    private TextView mDownMonTextView;
    private TextView mDownDayTextView;
    private EditText mYearEditText;
    private EditText mMonEditText;
    private EditText mDayEditText;

    private int mMinYear = 2015;
    private int mMinMon = 1;
    private int mMinDay = 1;

    private int mMaxYear = 2035;
    private int mMaxMon = 12;
    private int mMaxDay = 31;

    private int mMonStart = 1;
    private int mMonEnd = 12;
    private int mDayStart = 1;
    private int mDayEnd = 31;

    private DecimalFormat decimalFormatYear = new DecimalFormat("0000");
    private DecimalFormat decimalFormat = new DecimalFormat("00");
    private Context mContext;

    private DatePickerListner mDatePickerListner;
    private LinearLayout mBtn1LinearLayout;
    private LinearLayout mBtn2LinearLayout;

    /**
     * 생성자.
     *
     * @param context 컨텍스트
     */
    public DialogDate(Context context) {

        super(context, R.style.NTLES_Dialog1);
        mContext = context;
    }

    /**
     * 생성자.
     *
     * @param context           컨텍스트
     * @param datePickerListner Callback listener
     */
    public DialogDate(Context context, DatePickerListner datePickerListner) {

        super(context, R.style.NTLES_Dialog1);
        mContext = context;
        mDatePickerListner = datePickerListner;
    }

    /**
     * 생성자.
     *
     * @param context           컨텍스트
     * @param title             Dialog title
     * @param date              Date string
     * @param datePickerListner Callback listener
     */
    public DialogDate(Context context, String title, String date, DatePickerListner datePickerListner) {

        super(context, R.style.NTLES_Dialog1);
        mContext = context;
        mTitle = title;
        mDate = date;
        mDatePickerListner = datePickerListner;
    }

    /**
     * 생성자.
     *
     * @param context           컨텍스트
     * @param title             Dialog title
     * @param btn1Title         Button 1 title
     * @param btn2Title         Button 2 title
     * @param date              Date string
     * @param datePickerListner Callback listener
     */
    public DialogDate(Context context, String title, String btn1Title, String btn2Title, String date, DatePickerListner datePickerListner) {

        super(context, R.style.NTLES_Dialog1);
        mContext = context;
        mTitle = title;
        mBtn1 = btn1Title;
        mBtn2 = btn2Title;
        mDate = date;
        mDatePickerListner = datePickerListner;
    }

    /**
     * Initialize.
     */
    public void init() {

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.dialog_date, null);
        this.setContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT));
        this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
                | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
        mBtn1LinearLayout = (LinearLayout) findViewById(R.id.llBtn1);
        TextView tvBtn1 = (TextView) findViewById(R.id.tvBtn1);
        mBtn2LinearLayout = (LinearLayout) findViewById(R.id.llBtn2);
        TextView tvBtn2 = (TextView) findViewById(R.id.tvBtn2);

        if ("".equals(mTitle)) {
            mTitle = mUtil.getString(mContext, R.string.layout_date_selected);
        }
        if ("".equals(mBtn1)) {
            mBtn1 = mUtil.getString(mContext, R.string.layout_selected);
        }
        if ("".equals(mBtn2)) {
            mBtn2 = mUtil.getString(mContext, R.string.layout_cancel);
        }
        tvTitle.setText(mTitle);
        tvBtn1.setText(mBtn1);
        tvBtn2.setText(mBtn2);

        if ("".equals(mMinDate)) {
            mMinYear = mUtil.null2int(mUtil.getRealTimeType("yyyy"));
            mMinMon = 1;
            mMinDay = 1;
        } else {
            mMinYear = mUtil.null2int(mUtil.formattedDate(mMinDate, "yyyy-MM-dd", "yyyy"));
            mMinMon = mUtil.null2int(mUtil.formattedDate(mMinDate, "yyyy-MM-dd", "MM"));
            mMinDay = mUtil.null2int(mUtil.formattedDate(mMinDate, "yyyy-MM-dd", "dd"));
        }

        if ("".equals(mMaxDate)) {
            mMaxYear = mMinYear + 20;
            mMaxMon = 12;
            mMaxDay = 31;
        } else {
            mMaxYear = mUtil.null2int(mUtil.formattedDate(mMaxDate, "yyyy-MM-dd", "yyyy"));
            mMaxMon = mUtil.null2int(mUtil.formattedDate(mMaxDate, "yyyy-MM-dd", "MM"));
            mMaxDay = mUtil.null2int(mUtil.formattedDate(mMaxDate, "yyyy-MM-dd", "dd"));
        }

        Dlog.v("mUtil.getDiffDate1(mMinDate, mMaxDate) = " + mUtil.getDiffDate1(mMinDate, mMaxDate));
        Dlog.v("mUtil.getDiffDate1(mMaxDate, mMinDate) = " + mUtil.getDiffDate1(mMaxDate, mMinDate));
        Dlog.v("mUtil.getDiffDate1(mMaxDate, mMinDate) = " + mUtil.getDiffDate1(mMaxDate, mMinDate));

        if ("".equals(mDate)) {
            if (mUtil.getDiffDate1(mMinDate, mUtil.getRealTimeType("yyyy-MM-dd")) <= 0) {
                if (mUtil.getDiffDate1(mMaxDate, mUtil.getRealTimeType("yyyy-MM-dd")) <= 0) {
                    mDate = mMaxDate;
                } else {
                    mDate = mUtil.getRealTimeType("yyyy-MM-dd");
                }
            } else {
                mDate = mMinDate;
            }
        }

        mYear = mUtil.formattedDate(mDate, "yyyy-MM-dd", "yyyy");
        mMon = mUtil.formattedDate(mDate, "yyyy-MM-dd", "MM");
        mDay = mUtil.formattedDate(mDate, "yyyy-MM-dd", "dd");

        displayListView();
    }

    /**
     * {@link #mTitle} setter.
     *
     * @param title Dialog title
     */
    public void setTitle(String title) {

        mTitle = title;
    }

    /**
     * {@link #mBtn1} setter.
     *
     * @param btn1Title Button 1 title
     */
    public void setBtn1Val(String btn1Title) {

        mBtn1 = btn1Title;
    }

    /**
     * {@link #mBtn2} setter.
     *
     * @param btn2Title Button 2 title
     */
    public void setBtn2Val(String btn2Title) {

        mBtn2 = btn2Title;
    }

    /**
     * {@link #mDate} setter.
     *
     * @param date Date string
     */
    public void setDateVal(String date) {

        mDate = date;
    }

    /**
     * {@link #mMinDate} setter.
     *
     * @param minDate 일자 최소값
     */
    public void setMinDateVal(String minDate) {

        mMinDate = minDate;
    }

    /**
     * {@link #mMaxDate} setter.
     *
     * @param maxDate 일자 최대값
     */
    public void setMaxDateVal(String maxDate) {

        mMaxDate = maxDate;
    }

    /**
     * {@link #mDatePickerListner} setter.
     *
     * @param datePickerListner Callback listener
     */
    public void setDtpVal(DatePickerListner datePickerListner) {

        mDatePickerListner = datePickerListner;
    }

    /**
     * UI display.
     */
    private void displayListView() {

        Button btnUpYear = (Button) findViewById(R.id.btnUpYear);
        Button btnUpMon = (Button) findViewById(R.id.btnUpMon);
        Button btnUpDay = (Button) findViewById(R.id.btnUpDay);
        Button btnDownYear = (Button) findViewById(R.id.btnDownYear);
        Button btnDownMon = (Button) findViewById(R.id.btnDownMon);
        Button btnDownDay = (Button) findViewById(R.id.btnDownDay);

        mUpYearTextView = (TextView) findViewById(R.id.tvUpYear);
        mUpMonTextView = (TextView) findViewById(R.id.tvUpMon);
        mUpDayTextView = (TextView) findViewById(R.id.tvUpDay);
        mYearEditText = (EditText) findViewById(R.id.edtYear);
        mMonEditText = (EditText) findViewById(R.id.edtMon);
        mDayEditText = (EditText) findViewById(R.id.edtDay);
        mDownYearTextView = (TextView) findViewById(R.id.tvDownYear);
        mDownMonTextView = (TextView) findViewById(R.id.tvDownMon);
        mDownDayTextView = (TextView) findViewById(R.id.tvDownDay);

        btnUpYear.setOnClickListener(this);
        mUpYearTextView.setOnClickListener(this);
        mDownYearTextView.setOnClickListener(this);
        btnDownYear.setOnClickListener(this);

        btnUpMon.setOnClickListener(this);
        mUpMonTextView.setOnClickListener(this);
        mDownMonTextView.setOnClickListener(this);
        btnDownMon.setOnClickListener(this);

        btnUpDay.setOnClickListener(this);
        mUpDayTextView.setOnClickListener(this);
        mDownDayTextView.setOnClickListener(this);
        btnDownDay.setOnClickListener(this);

        setKeyDisp();
        mYearEditText.setText(mYear);
        mMonEditText.setText(mMon);
        mDayEditText.setText(mDay);
        btnUpDay.performClick();
        btnDownDay.performClick();

        mBtn1LinearLayout.setOnClickListener(this);
        mBtn2LinearLayout.setOnClickListener(this);
    }

    private void setKeyDisp() {

        mYearEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); // 키보드 확인 버튼 클릭시
        mYearEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {

                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    mYearEditText.clearFocus();
                    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
                return false;
            }
        });
        mYearEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            public void onFocusChange(View view, boolean hasFocus) {

                if (!hasFocus) {
                    if (mYearEditText.getText().toString().length() < 4) {
                        mYearEditText.setText(mMinYear + "");
                    }
                }
            }
        });

        mYearEditText.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence charSequence, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable editable) {

                if (mUtil.null2int(editable.toString()) > mMaxYear) {
                    mYearEditText.setText(mMaxYear + "");
                    mUpYearTextView.setText(decimalFormatYear.format(mMaxYear - 1));
                    mDownYearTextView.setText(decimalFormatYear.format(mMinYear));
                    updateDays();
                } else if (mUtil.null2string(editable.toString()).equals("")) {
                    mYearEditText.setText(mMinYear + "");
                    mUpYearTextView.setText(decimalFormatYear.format(mMaxYear));
                    mDownYearTextView.setText(decimalFormatYear.format(mMinYear + 1));
                    updateDays();
                } else if (editable.toString().length() >= 4) {
                    int iCurentYear = mUtil.null2int(editable.toString());
                    if (iCurentYear <= mMaxYear && iCurentYear >= mMinYear) {
                        if (iCurentYear == mMinYear) {
                            mUpYearTextView.setText(decimalFormatYear.format(mMaxYear));
                        } else {
                            mUpYearTextView.setText(decimalFormatYear.format(iCurentYear - 1));
                        }
                        if (iCurentYear < mMaxYear) {
                            mDownYearTextView.setText(decimalFormatYear.format(iCurentYear + 1));
                        } else {
                            mDownYearTextView.setText(decimalFormatYear.format(mMinYear));
                        }
                    } else {
                        iCurentYear = mMinYear;
                        mYearEditText.setText(mMinYear + "");
                        mUpYearTextView.setText(decimalFormatYear.format(mMaxYear));
                        mDownYearTextView.setText(decimalFormatYear.format(iCurentYear + 1));
                    }
                    updateDays();
                    mYearEditText.selectAll();
                }
            }
        });
        mMonEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); // 키보드 확인 버튼 클릭시
        mMonEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {

                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    mMonEditText.clearFocus();
                    InputMethodManager imm = (InputMethodManager) view.getContext()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
                }
                return false;
            }
        });
        mMonEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            public void onFocusChange(View view, boolean hasFocus) {

                if (!hasFocus) {
                    if (mMonEditText.getText().toString().length() == 1) {
                        mMonEditText.setText("0" + mMonEditText.getText());
                    }
                }
            }
        });
        mMonEditText.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence charSequence, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable editable) {

                if (mUtil.null2int(editable.toString()) > 12) {
                    mMonEditText.setText("12");
                } else if (mUtil.null2string(editable.toString()).equals("")) {
                    mMonEditText.setText("12");
                } else if (editable.toString().length() > 1) {
                    if (mUtil.null2int(editable.toString()) == 0) {
                        mMonEditText.setText("01");
                    } else {
                        int iCurentMon = mUtil.null2int(editable.toString());
                        if (iCurentMon <= mMonEnd) {
                            if (iCurentMon == mMonStart) {
                                mUpMonTextView.setText(decimalFormat.format(mMonEnd));
                            } else {
                                mUpMonTextView.setText(decimalFormat.format(iCurentMon - 1));
                            }
                            if (iCurentMon < mMonEnd) {
                                mDownMonTextView.setText(decimalFormat.format(iCurentMon + 1));
                            } else {
                                mDownMonTextView.setText(decimalFormat.format(mMonStart));
                            }
                        } else {
                            iCurentMon = mMonStart;
                            mUpMonTextView.setText(decimalFormat.format(mMonEnd));
                            mDownMonTextView.setText(decimalFormat.format(iCurentMon + 1));
                        }
                        updateDays();
                        mMonEditText.selectAll();
                    }
                } else {
                    if (mUtil.null2int(editable.toString()) > 1) {
                        mMonEditText.setText("0" + editable.toString());
                    } else if (mUtil.null2int(editable.toString()) > 0) {
                        int iCurentMon = mUtil.null2int(editable.toString());
                        if (iCurentMon <= mMonEnd) {
                            if (iCurentMon == mMonStart) {
                                mUpMonTextView.setText(decimalFormat.format(mMonEnd));
                            } else {
                                mUpMonTextView.setText(decimalFormat.format(iCurentMon - 1));
                            }
                            if (iCurentMon < mMonEnd) {
                                mDownMonTextView.setText(decimalFormat.format(iCurentMon + 1));
                            } else {
                                mDownMonTextView.setText(decimalFormat.format(mMonStart));
                            }
                        } else {
                            iCurentMon = mMonStart;
                            mUpMonTextView.setText(decimalFormat.format(mMonEnd));
                            mDownMonTextView.setText(decimalFormat.format(iCurentMon + 1));
                        }
                        updateDays();
                    }
                }
            }
        });

        mDayEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); // 키보드 확인 버튼 클릭시
        mDayEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    mDayEditText.clearFocus();
                    InputMethodManager imm = (InputMethodManager) v.getContext()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                }
                return false;
            }
        });
        mDayEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            public void onFocusChange(View v, boolean hasFocus) {

                if (!hasFocus) {
                    if (mDayEditText.getText().toString().length() == 1) {
                        mDayEditText.setText("0" + mDayEditText.getText());
                    }
                }
            }
        });
        mDayEditText.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {

                if (mUtil.null2int(s.toString()) > mDayEnd) {
                    mDayEditText.setText(mDayEnd + "");
                } else if (mUtil.null2string(s.toString()).equals("")) {
                    mDayEditText.setText("01");
                } else if (s.toString().length() > 1) {
                    if (mUtil.null2int(s.toString()) == 0) {
                        mDayEditText.setText("01");
                    } else {
                        int iCurentDay = mUtil.null2int(s.toString());
                        if (iCurentDay <= mDayEnd) {
                            if (iCurentDay == mDayStart) {
                                mUpDayTextView.setText(decimalFormat.format(mDayEnd));
                            } else {
                                mUpDayTextView.setText(decimalFormat.format(iCurentDay - 1));
                            }
                            if (iCurentDay < mDayEnd) {
                                mDownDayTextView.setText(decimalFormat.format(iCurentDay + 1));
                            } else {
                                mDownDayTextView.setText(decimalFormat.format(mDayStart));
                            }
                        } else {
                            iCurentDay = mDayStart;
                            mUpDayTextView.setText(decimalFormat.format(mDayEnd));
                            mDownDayTextView.setText(decimalFormat.format(iCurentDay + 1));
                        }
                        mDayEditText.selectAll();
                    }
                } else {
                    if (mUtil.null2int(s.toString()) > 1) {
                        mDayEditText.setText("0" + s.toString());
                    } else if (mUtil.null2int(s.toString()) > 0) {
                        int iCurentDay = mUtil.null2int(s.toString());
                        if (iCurentDay <= mDayEnd) {
                            if (iCurentDay == mDayStart) {
                                mUpDayTextView.setText(decimalFormat.format(mDayEnd));
                            } else {
                                mUpDayTextView.setText(decimalFormat.format(iCurentDay - 1));
                            }
                            if (iCurentDay < mDayEnd) {
                                mDownDayTextView.setText(decimalFormat.format(iCurentDay + 1));
                            } else {
                                mDownDayTextView.setText(decimalFormat.format(mDayStart));
                            }
                        } else {
                            iCurentDay = mDayStart;
                            mUpDayTextView.setText(decimalFormat.format(mDayEnd));
                            mDownDayTextView.setText(decimalFormat.format(iCurentDay + 1));
                        }
                    }
                }
            }
        });
    }

    @Override
    public void onClick(View view) {

        int iCurentYear = mUtil.null2int(mYearEditText.getText());
        int iCurentMon = mUtil.null2int(mMonEditText.getText());
        int iCurentDay = mUtil.null2int(mDayEditText.getText());
        switch (view.getId()) {
            case R.id.llBtn1:
                mDate = decimalFormatYear.format(iCurentYear) + "-" + decimalFormat.format(iCurentMon) + "-" + decimalFormat.format
                        (iCurentDay);
                mDatePickerListner.onDoneButton(DialogDate.this, mDate);
                break;
            case R.id.llBtn2:
                mDatePickerListner.onCancelButton(DialogDate.this);
                break;
            case R.id.btnUpYear:
            case R.id.tvUpYear:
                if (iCurentYear > mMinYear) {
                    iCurentYear--;
                    mYearEditText.setText(decimalFormatYear.format(iCurentYear));
                } else {
                    iCurentYear = mMaxYear;
                    mYearEditText.setText(decimalFormatYear.format(iCurentYear));
                }

                break;
            case R.id.tvDownYear:
            case R.id.btnDownYear:
                if (iCurentYear < mMaxYear) {
                    iCurentYear++;
                    mYearEditText.setText(decimalFormatYear.format(iCurentYear));
                } else {
                    iCurentYear = mMinYear;
                    mYearEditText.setText(decimalFormatYear.format(iCurentYear));
                }
                break;
            case R.id.btnUpMon:
            case R.id.tvUpMon:
                if (iCurentMon > mMonStart) {
                    iCurentMon--;
                    mMonEditText.setText(decimalFormat.format(iCurentMon));
                } else {
                    iCurentMon = mMonEnd;
                    mMonEditText.setText(decimalFormat.format(iCurentMon));
                }
                break;
            case R.id.tvDownMon:
            case R.id.btnDownMon:
                if (iCurentMon < mMonEnd) {
                    iCurentMon++;
                    mMonEditText.setText(decimalFormat.format(iCurentMon));
                } else {
                    iCurentMon = mMonStart;
                    mMonEditText.setText(decimalFormat.format(iCurentMon));
                }
                break;
            case R.id.btnUpDay:
            case R.id.tvUpDay:
                if (iCurentDay > mDayStart) {
                    iCurentDay--;
                    mDayEditText.setText(decimalFormat.format(iCurentDay));
                } else {
                    iCurentDay = mDayEnd;
                    mDayEditText.setText(decimalFormat.format(iCurentDay));
                }
                break;
            case R.id.tvDownDay:
            case R.id.btnDownDay:
                if (iCurentDay < mDayEnd) {
                    iCurentDay++;
                    mDayEditText.setText(decimalFormat.format(iCurentDay));
                } else {
                    iCurentDay = mDayStart;
                    mDayEditText.setText(decimalFormat.format(iCurentDay));
                }
                break;
            default:
                break;
        }
    }

    /**
     * 일자 업데이트.
     */
    private void updateDays() {

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, mUtil.null2int(mYearEditText.getText()));
        calendar.set(Calendar.MONTH, mUtil.null2int(mMonEditText.getText()) - 1);

        int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

        mDayEnd = maxDays;
        int curDay = Math.min(maxDays, mUtil.null2int(mDayEditText.getText().toString()));
        mDayEditText.setText(curDay + "");
    }

    /**
     * DatePicker listener interface.
     */
    public interface DatePickerListner {

        /**
         * DatePicker done button click listener.
         *
         * @param dialog Dialog object
         * @param date   Selected date
         */
        void onDoneButton(Dialog dialog, String date);

        /**
         * DatePicker cancel button click listener.
         *
         * @param dialog Dialog object
         */
        void onCancelButton(Dialog dialog);
    }
}
