mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
invalidate options menu only when necessary, not at every swipe
This commit is contained in:
@ -65,6 +65,7 @@ class MainActivity : SimpleActivity(), NavigationListener, RefreshRecyclerViewLi
|
|||||||
private var mLatestSearchQuery = ""
|
private var mLatestSearchQuery = ""
|
||||||
private var mCalDAVSyncHandler = Handler()
|
private var mCalDAVSyncHandler = Handler()
|
||||||
private var mSearchMenuItem: MenuItem? = null
|
private var mSearchMenuItem: MenuItem? = null
|
||||||
|
private var mIsGoToTodayVisible = true
|
||||||
|
|
||||||
private var mDefaultWeeklyPage = 0
|
private var mDefaultWeeklyPage = 0
|
||||||
private var mDefaultMonthlyPage = 0
|
private var mDefaultMonthlyPage = 0
|
||||||
@ -168,13 +169,16 @@ class MainActivity : SimpleActivity(), NavigationListener, RefreshRecyclerViewLi
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_main, menu)
|
menuInflater.inflate(R.menu.menu_main, menu)
|
||||||
|
mIsGoToTodayVisible = shouldGoToTodayBeVisible()
|
||||||
menu.apply {
|
menu.apply {
|
||||||
findItem(R.id.filter).isVisible = mShouldFilterBeVisible
|
findItem(R.id.filter).isVisible = mShouldFilterBeVisible
|
||||||
findItem(R.id.go_to_today).isVisible = shouldGoToTodayBeVisible()
|
findItem(R.id.go_to_today).isVisible = mIsGoToTodayVisible
|
||||||
findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
|
findItem(R.id.refresh_caldav_calendars).isVisible = config.caldavSync
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mSearchMenuItem == null) {
|
||||||
setupSearch(menu)
|
setupSearch(menu)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,7 +634,10 @@ class MainActivity : SimpleActivity(), NavigationListener, RefreshRecyclerViewLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (mIsGoToTodayVisible != shouldGoToTodayBeVisible()) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
if (config.storedView == YEARLY_VIEW) {
|
if (config.storedView == YEARLY_VIEW) {
|
||||||
val dateTime = Formatter.getDateTimeFromCode(codes[position])
|
val dateTime = Formatter.getDateTimeFromCode(codes[position])
|
||||||
supportActionBar?.title = "${getString(R.string.app_launcher_name)} - ${Formatter.getYear(dateTime)}"
|
supportActionBar?.title = "${getString(R.string.app_launcher_name)} - ${Formatter.getYear(dateTime)}"
|
||||||
@ -690,7 +697,10 @@ class MainActivity : SimpleActivity(), NavigationListener, RefreshRecyclerViewLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (mIsGoToTodayVisible != shouldGoToTodayBeVisible()) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
setupWeeklyActionbarTitle(weekTSs[position])
|
setupWeeklyActionbarTitle(weekTSs[position])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -753,7 +763,10 @@ class MainActivity : SimpleActivity(), NavigationListener, RefreshRecyclerViewLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
|
if (mIsGoToTodayVisible != shouldGoToTodayBeVisible()) {
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
|
||||||
if (position < years.size) {
|
if (position < years.size) {
|
||||||
supportActionBar?.title = "${getString(R.string.app_launcher_name)} - ${years[position]}"
|
supportActionBar?.title = "${getString(R.string.app_launcher_name)} - ${years[position]}"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user