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) {
|
if (now.year == mYear) {
|
||||||
val monthLabel = mView.findViewById(res.getIdentifier("month_${now.monthOfYear}_label", "id", activity.packageName)) as TextView
|
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))
|
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) {
|
fun setListener(listener: NavigationListener) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
||||||
var mColoredTextColor = 0
|
var mColoredTextColor = 0
|
||||||
var mDays = 31
|
var mDays = 31
|
||||||
var mFirstDay = 0
|
var mFirstDay = 0
|
||||||
|
var mTodaysId = 0
|
||||||
|
|
||||||
var mEvents: ArrayList<Int>? = null
|
var mEvents: ArrayList<Int>? = null
|
||||||
|
|
||||||
|
@ -40,6 +41,10 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
||||||
post { invalidate() }
|
post { invalidate() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setTodaysId(id: Int) {
|
||||||
|
mTodaysId = id
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val a = context.theme.obtainStyledAttributes(
|
val a = context.theme.obtainStyledAttributes(
|
||||||
attrs,
|
attrs,
|
||||||
|
@ -76,13 +81,18 @@ class SmallMonthView(context: Context, attrs: AttributeSet, defStyle: Int) : Vie
|
||||||
for (y in 1..6) {
|
for (y in 1..6) {
|
||||||
for (x in 1..7) {
|
for (x in 1..7) {
|
||||||
if (curId > 0 && curId <= mDays) {
|
if (curId > 0 && curId <= mDays) {
|
||||||
if (mEvents?.contains(curId) == true)
|
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, getPaint(curId))
|
||||||
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, mColoredPaint)
|
|
||||||
else
|
if (curId == mTodaysId) {
|
||||||
canvas.drawText(curId.toString(), x * mDayWidth, y * mDayWidth, mPaint)
|
canvas.drawCircle(x * mDayWidth - mDayWidth / 4, y * mDayWidth - mDayWidth / 4, mDayWidth * 0.41f, mColoredPaint)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
curId++
|
curId++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getPaint(curId: Int): Paint {
|
||||||
|
return if (mEvents?.contains(curId) == true) mColoredPaint else mPaint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue