// Path: app/src/main/java/top/soyask/calendarii/utils/DayUtils.java
// public class DayUtils {
//     /**
//      * @param month 传入实际的月份
//      * @param year
//      * @return
//      */
//     public static int getMonthDayCount(int month, int year) {
//         month = month - 1;
//         switch (month) {
//             case Calendar.JANUARY:
//             case Calendar.MARCH:
//             case Calendar.MAY:
//             case Calendar.JULY:
//             case Calendar.AUGUST:
//             case Calendar.OCTOBER:
//             case Calendar.DECEMBER:
//                 return 31;
//             case Calendar.APRIL:
//             case Calendar.JUNE:
//             case Calendar.SEPTEMBER:
//             case Calendar.NOVEMBER:
//                 return 30;
//             case Calendar.FEBRUARY:
//                 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ? 29 : 28;
//             default:
//                 throw new IllegalArgumentException("Didn't find this month(未找到该月份):" + month);
//         }
// 
//     }
// 
//     public static int getPrevMonthDayCount(int month, int year) {
//         if (month > 1) {
//             month--;
//         } else {
//             year--;
//         }
//         return getMonthDayCount(month, year);
//     }
// 
// 
//     public static int getDayForWeek(Calendar calendar) {
//         int date = calendar.get(Calendar.DAY_OF_MONTH);
//         if (date < 1 || date > 31) {
//             return 1;
//         }
//         return calendar.get(Calendar.DAY_OF_WEEK) - 1;
//     }
// 
//     public static int getWeekForMonth(Calendar calendar) {
//         int date = calendar.get(Calendar.DAY_OF_MONTH);
//         if (date < 1 || date > 31) {
//             return 1;
//         }
//         return calendar.get(Calendar.WEEK_OF_MONTH);
//     }
// }


import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.NumberPicker;
import java.lang.reflect.Method;
import top.soyask.calendarii.R;
import top.soyask.calendarii.utils.DayUtils;
    }

    public void setDateSelectCallback(DateSelectCallback dateSelectCallback) {
        this.mDateSelectCallback = dateSelectCallback;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_confirm:
                mDateSelectCallback.onSelectConfirm(mNpYear.getValue(), mNpMonth.getValue(), mNpDay.getValue());
                dismiss();
                break;
            case R.id.btn_cancel:
                mDateSelectCallback.onSelectCancel();
                mDateSelectCallback.onValueChange(mYear, mMonth, mDay);
                dismiss();
                break;
        }
    }

    @Override
    public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
        int year = mNpYear.getValue();
        int month = mNpMonth.getValue();
        mDateSelectCallback.onValueChange(year, month, mNpDay.getValue());
        updateDayCount(year, month);
    }

    private void updateDayCount(int year, int month) {
// Path: app/src/main/java/top/soyask/calendarii/utils/DayUtils.java
// public class DayUtils {
//     /**
//      * @param month 传入实际的月份
//      * @param year
//      * @return
//      */
//     public static int getMonthDayCount(int month, int year) {
//         month = month - 1;
//         switch (month) {
//             case Calendar.JANUARY:
//             case Calendar.MARCH:
//             case Calendar.MAY:
//             case Calendar.JULY:
//             case Calendar.AUGUST:
//             case Calendar.OCTOBER:
//             case Calendar.DECEMBER:
//                 return 31;
//             case Calendar.APRIL:
//             case Calendar.JUNE:
//             case Calendar.SEPTEMBER:
//             case Calendar.NOVEMBER:
//                 return 30;
//             case Calendar.FEBRUARY:
//                 return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) ? 29 : 28;
//             default:
//                 throw new IllegalArgumentException("Didn't find this month(未找到该月份):" + month);
//         }
// 
//     }
// 
//     public static int getPrevMonthDayCount(int month, int year) {
//         if (month > 1) {
//             month--;
//         } else {
//             year--;
//         }
//         return getMonthDayCount(month, year);
//     }
// 
// 
//     public static int getDayForWeek(Calendar calendar) {
//         int date = calendar.get(Calendar.DAY_OF_MONTH);
//         if (date < 1 || date > 31) {
//             return 1;
//         }
//         return calendar.get(Calendar.DAY_OF_WEEK) - 1;
//     }
// 
//     public static int getWeekForMonth(Calendar calendar) {
//         int date = calendar.get(Calendar.DAY_OF_MONTH);
//         if (date < 1 || date > 31) {
//             return 1;
//         }
//         return calendar.get(Calendar.WEEK_OF_MONTH);
//     }
// }


// Path: app/src/main/java/top/soyask/calendarii/ui/fragment/dialog/DateSelectDialog.java
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.NumberPicker;
import java.lang.reflect.Method;
import top.soyask.calendarii.R;
import top.soyask.calendarii.utils.DayUtils;

    }

    public void setDateSelectCallback(DateSelectCallback dateSelectCallback) {
        this.mDateSelectCallback = dateSelectCallback;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_confirm:
                mDateSelectCallback.onSelectConfirm(mNpYear.getValue(), mNpMonth.getValue(), mNpDay.getValue());
                dismiss();
                break;
            case R.id.btn_cancel:
                mDateSelectCallback.onSelectCancel();
                mDateSelectCallback.onValueChange(mYear, mMonth, mDay);
                dismiss();
                break;
        }
    }

    @Override
    public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
        int year = mNpYear.getValue();
        int month = mNpMonth.getValue();
        mDateSelectCallback.onValueChange(year, month, mNpDay.getValue());
        updateDayCount(year, month);
    }

    private void updateDayCount(int year, int month) {
        int dayCount = DayUtils.getMonthDayCount(month, year);