Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

withSelectedDate scrolls to maxDate #49

Closed
spacecowboy opened this issue May 24, 2013 · 2 comments
Closed

withSelectedDate scrolls to maxDate #49

spacecowboy opened this issue May 24, 2013 · 2 comments

Comments

@spacecowboy
Copy link

When I load the view (in my dialog fragment), the calendar automatically scrolls to the end of the allowed range. I don't want to restrict the date in this case so I selected a 10 year limit. The view scrolls to 2023 upon loading.

However, if you comment out the line "withSelectedDate", the calendar loads fine and does not scroll to maxDate.

Device: Galaxy Nexus, Android 4.2.2

Code:

final Calendar future = Calendar.getInstance();
        future.add(Calendar.YEAR, 10);
        final Calendar selected = Calendar.getInstance();
        // Default to tomorrow
        selected.add(Calendar.DAY_OF_YEAR, 1);
        // New item hides delete button and disables OK initially
        if (getArguments().getLong(SELECTED_DATE, -1) > 0) {
            // TODO default date
            selected.setTimeInMillis(getArguments().getLong(SELECTED_DATE, -1));
        }

        calendarView.init(Calendar.getInstance().getTime(), future.getTime())
        .withSelectedDate(selected.getTime());
@spacecowboy
Copy link
Author

The fix seems to be to use "selectDate" instead. "withSelectedDate" should perhaps be removed?

        final Calendar future = Calendar.getInstance();
        future.add(Calendar.YEAR, 10);
        final Calendar selected = Calendar.getInstance();
        // Default to tomorrow
        selected.add(Calendar.DAY_OF_YEAR, 1);
        if (getArguments().getLong(SELECTED_DATE, -1) > 0) {
            // TODO default date
            selected.setTimeInMillis(getArguments().getLong(SELECTED_DATE, -1));
        }

        calendarView.init(Calendar.getInstance().getTime(), future.getTime());
        calendarView.selectDate(selected.getTime());
        //.withSelectedDate(selected.getTime());

edenman pushed a commit that referenced this issue May 24, 2013
@edenman
Copy link
Collaborator

edenman commented May 24, 2013

Sorry, the proposed fix isn't correct: you should definitely be using .withSelectedDate. The real fix is in 94631ab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants