properly update the weekly screen if some color changes

This commit is contained in:
tibbi 2017-01-22 16:48:25 +01:00
parent 03a11ff99b
commit c1a2051f8c
2 changed files with 19 additions and 8 deletions

View File

@ -41,6 +41,8 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
private var mSnackbar: Snackbar? = null
private var mEventListFragment: EventListFragment? = null
private var mStoredTextColor = 0
private var mStoredBackgroundColor = 0
private var mStoredPrimaryColor = 0
private var mStoredIsSundayFirst = false
companion object {
@ -52,16 +54,18 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
setContentView(R.layout.activity_main)
calendar_fab.setOnClickListener { addNewEvent() }
updateViewPager()
mStoredTextColor = config.textColor
mStoredIsSundayFirst = config.isSundayFirst
checkWhatsNewDialog()
}
override fun onResume() {
super.onResume()
if (mStoredTextColor != config.textColor)
if (mStoredTextColor != config.textColor || mStoredBackgroundColor != config.backgroundColor || mStoredPrimaryColor != config.primaryColor)
updateViewPager()
mStoredTextColor = config.textColor
mStoredPrimaryColor = config.primaryColor
mStoredBackgroundColor = config.backgroundColor
if (mStoredIsSundayFirst != config.isSundayFirst && config.storedView == WEEKLY_VIEW)
fillWeeklyViewPager()
@ -74,6 +78,8 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
checkDeleteEvents()
mStoredTextColor = config.textColor
mStoredIsSundayFirst = config.isSundayFirst
mStoredBackgroundColor = config.backgroundColor
mStoredPrimaryColor = config.primaryColor
}
override fun onDestroy() {
@ -195,10 +201,12 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
week_view_hours_holder.removeAllViews()
for (i in 1..23) {
val view = layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView
val value = i.toString()
view.text = if (value.length == 2) value else "0$value"
week_view_hours_holder.addView(view)
(layoutInflater.inflate(R.layout.weekly_view_hour_textview, null, false) as TextView).apply {
text = if (value.length == 2) value else "0$value"
setTextColor(mStoredTextColor)
week_view_hours_holder.addView(this)
}
}
week_view_view_pager.apply {

View File

@ -94,10 +94,13 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private fun setupDayLabels() {
var curDay = Formatter.getDateTimeFromTS(mWeekTimestamp)
val textColor = context.config.textColor
for (i in 0..6) {
val view = mView.findViewById(mRes.getIdentifier("week_day_label_$i", "id", context.packageName)) as TextView
val dayLetter = getDayLetter(curDay.dayOfWeek)
view.text = "$dayLetter\n${curDay.dayOfMonth}"
(mView.findViewById(mRes.getIdentifier("week_day_label_$i", "id", context.packageName)) as TextView).apply {
text = "$dayLetter\n${curDay.dayOfMonth}"
setTextColor(textColor)
}
curDay = curDay.plusDays(1)
}
}