Skip to content

Commit 884e20f

Browse files
authored
Merge pull request Bigkoo#755 from MankinChung/fix
修复 农历‘日’越界的bug
2 parents cad6d79 + 7b9e6c8 commit 884e20f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pickerview/src/main/java/com/bigkoo/pickerview/view/WheelTime.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public void onItemSelected(int index) {
161161
wv_month.setCurrentItem(wv_month.getCurrentItem());
162162
}
163163

164+
int currentIndex = wv_day.getCurrentItem();
164165
int maxItem = 29;
165166
if (ChinaDate.leapMonth(year_num) != 0 && wv_month.getCurrentItem() > ChinaDate.leapMonth(year_num) - 1) {
166167
if (wv_month.getCurrentItem() == ChinaDate.leapMonth(year_num) + 1) {
@@ -175,7 +176,7 @@ public void onItemSelected(int index) {
175176
maxItem = ChinaDate.monthDays(year_num, wv_month.getCurrentItem() + 1);
176177
}
177178

178-
if (wv_day.getCurrentItem() > maxItem - 1) {
179+
if (currentIndex > maxItem - 1) {
179180
wv_day.setCurrentItem(maxItem - 1);
180181
}
181182

@@ -191,6 +192,7 @@ public void onItemSelected(int index) {
191192
public void onItemSelected(int index) {
192193
int month_num = index;
193194
int year_num = wv_year.getCurrentItem() + startYear;
195+
int currentIndex = wv_day.getCurrentItem();
194196
int maxItem = 29;
195197
if (ChinaDate.leapMonth(year_num) != 0 && month_num > ChinaDate.leapMonth(year_num) - 1) {
196198
if (wv_month.getCurrentItem() == ChinaDate.leapMonth(year_num) + 1) {
@@ -205,7 +207,7 @@ public void onItemSelected(int index) {
205207
maxItem = ChinaDate.monthDays(year_num, month_num + 1);
206208
}
207209

208-
if (wv_day.getCurrentItem() > maxItem - 1) {
210+
if (currentIndex > maxItem - 1) {
209211
wv_day.setCurrentItem(maxItem - 1);
210212
}
211213

0 commit comments

Comments
 (0)