package kz.arta.synergy.workflow.mobile.android.common.components;

/**
 * Created by neox on 15.04.14.
 * Диалог выбора времени
 */

import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;

import kz.arta.synergy.workflow.mobile.android.common.utils.DateUtils;

public class DatePickerFragment extends DialogFragment {

    /**
     * Год
     */
    public static final String YEAR = "yyyy";
    /**
     * Месяц
     */
    public static final String MONTH = "MM";
    /**
     * День
     */
    public static final String DAY = "dd";
    /**
     * CallBack
     */
    private OnDateSetListener onDate;
    /**
     * Год
     */
    private int year;

    /**
     * Месяц
     */
    private int month;

    /**
     * День
     */
    private int day;

    public void setCallBack(OnDateSetListener onDate) {
        this.onDate = onDate;
    }

    @Override
    public void setArguments(Bundle args) {
        super.setArguments(args);
        year = args.getInt(DateUtils.YEAR);
        month = args.getInt(DateUtils.MONTH);
        day = args.getInt(DateUtils.DAY);
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return new DatePickerDialog(getActivity(), onDate, year, month, day);
    }
}