From 98f29fad553b930c3d40e5125a240825be1d2896 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 22 Mar 2017 19:37:04 +0100 Subject: [PATCH] fix the "Go to today" button at monthly view opened from yearly view --- .../calendar/activities/MainActivity.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index 1f2f0fd3c..1859cf1fe 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -155,7 +155,11 @@ class MainActivity : SimpleActivity(), NavigationListener { } else if (config.storedView == MONTHLY_VIEW) { main_view_pager.currentItem = mDefaultMonthlyPage } else if (config.storedView == YEARLY_VIEW) { - main_view_pager.currentItem = mDefaultYearlyPage + if (mIsMonthSelected) { + openMonthlyToday() + } else { + main_view_pager.currentItem = mDefaultYearlyPage + } } } @@ -193,13 +197,17 @@ class MainActivity : SimpleActivity(), NavigationListener { } else if (config.storedView == WEEKLY_VIEW) { fillWeeklyViewPager() } else { - val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN) - fillMonthlyViewPager(targetDay) + openMonthlyToday() } mWeekScrollY = 0 } + private fun openMonthlyToday() { + val targetDay = DateTime().toString(Formatter.DAYCODE_PATTERN) + fillMonthlyViewPager(targetDay) + } + private fun refreshViewPager() { if (config.storedView == YEARLY_VIEW) { (main_view_pager.adapter as MyYearPagerAdapter).refreshEvents(main_view_pager.currentItem)