use the actual event type colors at weekly view
This commit is contained in:
parent
58e1a4e88d
commit
5babf8acd2
|
@ -6,6 +6,7 @@ import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v4.app.ActivityCompat
|
import android.support.v4.app.ActivityCompat
|
||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
|
import android.util.SparseIntArray
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
@ -51,6 +52,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var mWeekScrollY = 0
|
var mWeekScrollY = 0
|
||||||
|
var eventTypeColors = SparseIntArray(3)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -66,6 +68,10 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor)
|
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor)
|
||||||
updateViewPager()
|
updateViewPager()
|
||||||
|
|
||||||
|
DBHelper.newInstance(applicationContext).getEventTypes {
|
||||||
|
eventTypeColors.clear()
|
||||||
|
it.map { eventTypeColors.put(it.id, it.color) }
|
||||||
|
}
|
||||||
mStoredTextColor = config.textColor
|
mStoredTextColor = config.textColor
|
||||||
mStoredPrimaryColor = config.primaryColor
|
mStoredPrimaryColor = config.primaryColor
|
||||||
mStoredBackgroundColor = config.backgroundColor
|
mStoredBackgroundColor = config.backgroundColor
|
||||||
|
|
|
@ -234,7 +234,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
||||||
val duration = endDateTime.minuteOfDay - startMinutes
|
val duration = endDateTime.minuteOfDay - startMinutes
|
||||||
|
|
||||||
(inflater.inflate(R.layout.week_event_marker, null, false) as TextView).apply {
|
(inflater.inflate(R.layout.week_event_marker, null, false) as TextView).apply {
|
||||||
background = ColorDrawable(primaryColor)
|
background = ColorDrawable(MainActivity.eventTypeColors.get(event.eventType, primaryColor))
|
||||||
text = event.title
|
text = event.title
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
layout.addView(this)
|
layout.addView(this)
|
||||||
|
@ -295,7 +295,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
|
||||||
|
|
||||||
private fun addAllDayEvent(event: Event) {
|
private fun addAllDayEvent(event: Event) {
|
||||||
(inflater.inflate(R.layout.week_all_day_event_marker, null, false) as TextView).apply {
|
(inflater.inflate(R.layout.week_all_day_event_marker, null, false) as TextView).apply {
|
||||||
background = ColorDrawable(primaryColor)
|
background = ColorDrawable(MainActivity.eventTypeColors.get(event.eventType, primaryColor))
|
||||||
text = event.title
|
text = event.title
|
||||||
|
|
||||||
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
val startDateTime = Formatter.getDateTimeFromTS(event.startTS)
|
||||||
|
|
Loading…
Reference in New Issue