fix #154, properly update the actionbar title at yearly view
This commit is contained in:
parent
f63e7a5924
commit
00efe5b33a
|
@ -335,6 +335,10 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
|
||||
override fun onPageSelected(position: Int) {
|
||||
invalidateOptionsMenu()
|
||||
if (config.storedView == YEARLY_VIEW) {
|
||||
val dateTime = Formatter.getDateTimeFromCode(codes[position])
|
||||
title = "${getString(R.string.app_launcher_name)} - ${Formatter.getYear(dateTime)}"
|
||||
}
|
||||
}
|
||||
})
|
||||
currentItem = mDefaultMonthlyPage
|
||||
|
@ -391,7 +395,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
|
||||
override fun onPageSelected(position: Int) {
|
||||
invalidateOptionsMenu()
|
||||
setupActionbarTitle(weekTSs[position])
|
||||
setupWeeklyActionbarTitle(weekTSs[position])
|
||||
}
|
||||
})
|
||||
currentItem = mDefaultWeeklyPage
|
||||
|
@ -419,7 +423,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||
return weekTSs
|
||||
}
|
||||
|
||||
private fun setupActionbarTitle(timestamp: Int) {
|
||||
private fun setupWeeklyActionbarTitle(timestamp: Int) {
|
||||
val startDateTime = Formatter.getDateTimeFromTS(timestamp)
|
||||
val endDateTime = Formatter.getDateTimeFromTS(timestamp + WEEK_SECONDS)
|
||||
val startMonthName = Formatter.getMonthName(this, startDateTime.monthOfYear)
|
||||
|
|
|
@ -67,6 +67,8 @@ object Formatter {
|
|||
// use manually translated month names, as DateFormat and Joda have issues with a lot of languages
|
||||
fun getMonthName(context: Context, id: Int) = context.resources.getStringArray(R.array.months)[id - 1]
|
||||
|
||||
fun getYear(dateTime: DateTime) = dateTime.toString(YEAR_PATTERN)
|
||||
|
||||
fun getHourPattern(context: Context) = if (context.config.use24hourFormat) PATTERN_HOURS_24 else PATTERN_HOURS_12
|
||||
|
||||
fun getTimePattern(context: Context) = if (context.config.use24hourFormat) PATTERN_TIME_24 else PATTERN_TIME_12
|
||||
|
|
Loading…
Reference in New Issue