fade out the event label if the day doesnt belong in the current month

This commit is contained in:
tibbi
2017-10-07 22:49:56 +02:00
parent 095062f7d5
commit 965e48a31d

View File

@@ -24,7 +24,6 @@ import com.simplemobiletools.calendar.helpers.*
import com.simplemobiletools.calendar.interfaces.MonthlyCalendar import com.simplemobiletools.calendar.interfaces.MonthlyCalendar
import com.simplemobiletools.calendar.interfaces.NavigationListener import com.simplemobiletools.calendar.interfaces.NavigationListener
import com.simplemobiletools.calendar.models.DayMonthly import com.simplemobiletools.calendar.models.DayMonthly
import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import kotlinx.android.synthetic.main.first_row.* import kotlinx.android.synthetic.main.first_row.*
import kotlinx.android.synthetic.main.fragment_month.view.* import kotlinx.android.synthetic.main.fragment_month.view.*
@@ -180,9 +179,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
removeAllViews() removeAllViews()
addDayNumber(day, this) addDayNumber(day, this)
day.dayEvents.forEach { addDayEvents(day, this)
addDayEvent(it, this)
}
} }
} }
} }
@@ -222,20 +219,28 @@ class MonthFragment : Fragment(), MonthlyCalendar {
} }
} }
private fun addDayEvent(event: Event, linearLayout: LinearLayout) { private fun addDayEvents(day: DayMonthly, linearLayout: LinearLayout) {
val backgroundDrawable = mRes.getDrawable(R.drawable.day_monthly_event_background) day.dayEvents.forEach {
backgroundDrawable.mutate().setColorFilter(event.color, PorterDuff.Mode.SRC_IN) val backgroundDrawable = mRes.getDrawable(R.drawable.day_monthly_event_background)
backgroundDrawable.mutate().setColorFilter(it.color, PorterDuff.Mode.SRC_IN)
val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) val eventLayoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
eventLayoutParams.setMargins(dividerMargin, dividerMargin, dividerMargin, dividerMargin) eventLayoutParams.setMargins(dividerMargin, dividerMargin, dividerMargin, dividerMargin)
(View.inflate(context, R.layout.day_monthly_item_view, null) as TextView).apply { var textColor = it.color.getContrastColor().adjustAlpha(MEDIUM_ALPHA)
setTextColor(event.color.getContrastColor().adjustAlpha(MEDIUM_ALPHA)) if (!day.isThisMonth) {
text = event.title backgroundDrawable.alpha = 64
gravity = Gravity.START textColor = textColor.adjustAlpha(0.25f)
background = backgroundDrawable }
layoutParams = eventLayoutParams
linearLayout.addView(this) (View.inflate(context, R.layout.day_monthly_item_view, null) as TextView).apply {
setTextColor(textColor)
text = it.title
gravity = Gravity.START
background = backgroundDrawable
layoutParams = eventLayoutParams
linearLayout.addView(this)
}
} }
} }
} }