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

Unselect date after swiping to another month #21

Open
csbenz opened this issue Jan 27, 2017 · 2 comments
Open

Unselect date after swiping to another month #21

csbenz opened this issue Jan 27, 2017 · 2 comments

Comments

@csbenz
Copy link

csbenz commented Jan 27, 2017

When I swipe to another month, select a day and come back to the initial month, the day is still selected. Is this a normal behaviour? Because it isn't intuitive and there's no way of unselecting the day.
What I propose: when a day is clicked, all other days (there should be only one) are unselected.

@dgadelha
Copy link

dgadelha commented Jul 24, 2017

Experiencing this too. :(

Managed to workaround it with that:

private int lastMonth;

@Override
public void onDateSelected(Date date) {
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(date);

	if (calendar.get(Calendar.MONTH) != lastMonth) {
		Date epochStart = new Date(0L);

		for (int i = 0; i < 12; i++) {
			MonthView monthView = lightCalendarView.getMonthViewForPosition(i);
			if (monthView != null) monthView.setSelectedDate(epochStart);
		}

		lastMonth = calendar.get(Calendar.MONTH);
	}
}

@filippe-cl
Copy link

Same here.

Another workaround:

private Date mLastSelectedDate = Calendar.getInstance().getTime();

private void setCalendarView() {
        mCalendarView.setOnStateUpdatedListener(new LightCalendarView.OnStateUpdatedListener() {
            @Override
            public void onMonthSelected(@NotNull Date date, @NotNull MonthView monthView) {
                monthView.setSelectedDate(mLastSelectedDate);
            }

            @Override
            public void onDateSelected(@NotNull Date date) {
                mLastSelectedDate = date;
            }
        });
    }

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

3 participants