Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ac88088 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Return correct year in DayPickerPagerAdapter.getYearForPosition()" into mnc-dev

parents 6044798e bd51b4d0
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -186,11 +186,12 @@ class DayPickerPagerAdapter extends PagerAdapter {
    }
    }


    private int getMonthForPosition(int position) {
    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) {
    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) {
    private int getPositionForDay(@Nullable Calendar day) {
@@ -198,8 +199,8 @@ class DayPickerPagerAdapter extends PagerAdapter {
            return -1;
            return -1;
        }
        }


        final int yearOffset = (day.get(Calendar.YEAR) - mMinDate.get(Calendar.YEAR));
        final int yearOffset = day.get(Calendar.YEAR) - mMinDate.get(Calendar.YEAR);
        final int monthOffset = (day.get(Calendar.MONTH) - mMinDate.get(Calendar.MONTH));
        final int monthOffset = day.get(Calendar.MONTH) - mMinDate.get(Calendar.MONTH);
        final int position = yearOffset * MONTHS_IN_YEAR + monthOffset;
        final int position = yearOffset * MONTHS_IN_YEAR + monthOffset;
        return position;
        return position;
    }
    }
+2 −2
Original line number Original line Diff line number Diff line
@@ -176,8 +176,6 @@ class DayPickerView extends ViewGroup {
                }
                }
            }
            }
        });
        });

        updateButtonVisibility(mViewPager.getCurrentItem());
    }
    }


    private void updateButtonVisibility(int position) {
    private void updateButtonVisibility(int position) {
@@ -346,6 +344,8 @@ class DayPickerView extends ViewGroup {
        // Changing the min/max date changes the selection position since we
        // Changing the min/max date changes the selection position since we
        // don't really have stable IDs. Jumps immediately to the new position.
        // don't really have stable IDs. Jumps immediately to the new position.
        setDate(mSelectedDay.getTimeInMillis(), false, false);
        setDate(mSelectedDay.getTimeInMillis(), false, false);

        updateButtonVisibility(mViewPager.getCurrentItem());
    }
    }


    /**
    /**