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