From f0b300f4231556451e2723192592dc5f6de9e9ac Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 24 Oct 2018 20:01:14 +0200 Subject: [PATCH] disable swipe refresh layout at the weekly view --- .../calendar/activities/MainActivity.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 bbe731ec6..f6d7bf510 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -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)