disable swipe refresh layout at the weekly view

This commit is contained in:
tibbi 2018-10-24 20:01:14 +02:00
parent 6a783df2ac
commit f0b300f423
1 changed files with 10 additions and 1 deletions

View File

@ -133,7 +133,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
search_placeholder_2.setTextColor(config.textColor)
calendar_fab.setColors(config.textColor, getAdjustedPrimaryColor(), config.backgroundColor)
search_holder.background = ColorDrawable(config.backgroundColor)
swipe_refresh_layout.isEnabled = config.caldavSync && config.pullToRefresh
checkSwipeRefreshAvailability()
}
override fun onPause() {
@ -189,6 +189,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
override fun onBackPressed() {
swipe_refresh_layout.isRefreshing = false
checkSwipeRefreshAvailability()
if (currentFragments.size > 1) {
removeTopFragment()
} else {
@ -537,6 +538,7 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun updateView(view: Int) {
calendar_fab.beVisibleIf(view != YEARLY_VIEW)
config.storedView = view
checkSwipeRefreshAvailability()
updateViewPager()
if (goToTodayButton?.isVisible == true) {
shouldGoToTodayBeVisible = false
@ -750,6 +752,13 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
}
}
private fun checkSwipeRefreshAvailability() {
swipe_refresh_layout.isEnabled = config.caldavSync && config.pullToRefresh && config.storedView != WEEKLY_VIEW
if (!swipe_refresh_layout.isEnabled) {
swipe_refresh_layout.isRefreshing = false
}
}
// only used at active search
override fun refreshItems() {
searchQueryChanged(mLatestSearchQuery)