am 1ac88088: Merge "Return correct year in DayPickerPagerAdapter.getYearForPosition()" into mnc-dev
* commit '1ac88088adf54be60c12ec80c3533ee586eee02f': Return correct year in DayPickerPagerAdapter.getYearForPosition()
This commit is contained in:
@@ -186,11 +186,12 @@ class DayPickerPagerAdapter extends PagerAdapter {
|
||||
}
|
||||
|
||||
private int getMonthForPosition(int position) {
|
||||
return position % MONTHS_IN_YEAR + mMinDate.get(Calendar.MONTH);
|
||||
return (position + mMinDate.get(Calendar.MONTH)) % MONTHS_IN_YEAR;
|
||||
}
|
||||
|
||||
private int getYearForPosition(int position) {
|
||||
return position / MONTHS_IN_YEAR + mMinDate.get(Calendar.YEAR);
|
||||
final int yearOffset = (position + mMinDate.get(Calendar.MONTH)) / MONTHS_IN_YEAR;
|
||||
return yearOffset + mMinDate.get(Calendar.YEAR);
|
||||
}
|
||||
|
||||
private int getPositionForDay(@Nullable Calendar day) {
|
||||
@@ -198,8 +199,8 @@ class DayPickerPagerAdapter extends PagerAdapter {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final int yearOffset = (day.get(Calendar.YEAR) - mMinDate.get(Calendar.YEAR));
|
||||
final int monthOffset = (day.get(Calendar.MONTH) - mMinDate.get(Calendar.MONTH));
|
||||
final int yearOffset = day.get(Calendar.YEAR) - mMinDate.get(Calendar.YEAR);
|
||||
final int monthOffset = day.get(Calendar.MONTH) - mMinDate.get(Calendar.MONTH);
|
||||
final int position = yearOffset * MONTHS_IN_YEAR + monthOffset;
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -176,8 +176,6 @@ class DayPickerView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
updateButtonVisibility(mViewPager.getCurrentItem());
|
||||
}
|
||||
|
||||
private void updateButtonVisibility(int position) {
|
||||
@@ -346,6 +344,8 @@ class DayPickerView extends ViewGroup {
|
||||
// Changing the min/max date changes the selection position since we
|
||||
// don't really have stable IDs. Jumps immediately to the new position.
|
||||
setDate(mSelectedDay.getTimeInMillis(), false, false);
|
||||
|
||||
updateButtonVisibility(mViewPager.getCurrentItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user