mark current day in the yearly view with a circle
This commit is contained in:
parent
761c45c414
commit
f490ddf1ee
|
@ -68,8 +68,10 @@ class YearFragment : Fragment(), YearlyCalendar {
|
|||
if (now.year == mYear) {
|
||||
val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) as TextView
|
||||
monthLabel.setTextColor(Utils.adjustAlpha(res.getColor(R.color.colorPrimary), Constants.HIGH_ALPHA))
|
||||
}
|
||||
|
||||
val monthView = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}", "id", activity.packageName)) as SmallMonthView
|
||||
monthView.setTodaysId(now.dayOfMonth)
|
||||
}
|
||||
}
|
||||
|
||||
fun setListener(listener: NavigationListener) {
|
||||
|
|
|
@ -20,6 +20,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
var mColoredTextColor = 0
|
||||
var mDays = 31
|
||||
var mFirstDay = 0
|
||||
var mTodaysId = 0
|
||||
|
||||
var mEvents: ArrayList<Int>? = null
|
||||
|
||||
|
@ -40,6 +41,10 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
post { invalidate() }
|
||||
}
|
||||
|
||||
fun setTodaysId(id: Int) {
|
||||
mTodaysId = id
|
||||
}
|
||||
|
||||
init {
|
||||
val a = context.theme.obtainStyledAttributes(
|
||||
attrs,
|
||||
|
@ -76,13 +81,18 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
|||
for (y in 1..6) {
|
||||
for (x in 1..7) {
|
||||
if (curId > 0 && curId <= mDays) {
|
||||
if (mEvents?.contains(curId) == true)
|
||||
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, mColoredPaint)
|
||||
else
|
||||
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, mPaint)
|
||||
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, getPaint(curId))
|
||||
|
||||
if (curId == mTodaysId) {
|
||||
canvas.drawCircle(x * mDayWidth - mDayWidth / 4, y * mDayWidth - mDayWidth / 4, mDayWidth * 0.41f, mColoredPaint)
|
||||
}
|
||||
}
|
||||
curId++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPaint(curId: Int): Paint {
|
||||
return if (mEvents?.contains(curId) == true) mColoredPaint else mPaint
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue