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

[add] added properties for fixing the circle of today #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,6 +43,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
calendarView.setMonthFrom(calFrom.getTime());
calendarView.setMonthTo(calTo.getTime());
calendarView.setMonthCurrent(calNow.getTime());
// 当日の強調表示固定
calendarView.setFixToday(true);

calendarView.setOnMonthSelected(new Function2<Date, MonthView, Unit>() {
@Override
public Unit invoke(Date date, final MonthView monthView) {
Expand Down
Expand Up @@ -36,6 +36,9 @@ class CalendarSettings(private val context: Context) : ObservableSettings() {
var timeZone: TimeZone = TimeZone.getDefault()
var locale: Locale = Locale.getDefault()

// 当日を常に強調表示
var fixToday: Boolean = false

// settings for DayLayout and WeekDayLayout: first day of the week
var firstDayOfWeek: WeekDay = WeekDay.SUNDAY
val dayOfWeekOffset: Int
Expand Down
Expand Up @@ -18,6 +18,7 @@ package jp.co.recruit_mp.android.lightcalendarview

import android.content.Context
import android.support.v4.view.ViewCompat
import android.text.format.DateUtils
import java.util.*

/**
Expand Down Expand Up @@ -135,8 +136,11 @@ class DayLayout(context: Context, settings: CalendarSettings, var month: Date) :

private fun setSelectedDay(view: DayView?) {
selectedDayView?.apply {
isSelected = false
updateState()
if (!settings.fixToday || !DateUtils.isToday(selectedDayView?.date!!.time)) {
// 今日の場合は常に丸を表示させる
isSelected = false
updateState()
}
}
selectedDayView = view?.apply {
isSelected = true
Expand Down
Expand Up @@ -239,6 +239,13 @@ class LightCalendarView(context: Context, attrs: AttributeSet? = null, defStyleA
}.notifySettingsChanged()
}

var fixToday: Boolean
get() = settings.fixToday
set(value) {
settings.apply {
fixToday = value
}.notifySettingsChanged()
}
/**
* Sets the locale to use in LightCalendarView.
* Set null to use Locale.getDefault()
Expand Down