From a3e5f824c8c0c575058c55af98c2d909798246b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sat, 16 Nov 2019 18:46:01 +0100 Subject: [PATCH] [UI] Fix messages & homework refresh layout sensitivity. --- .../edziennik/ui/modules/homework/HomeworkFragment.kt | 8 ++++++-- .../edziennik/ui/modules/messages/MessagesFragment.kt | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt index 5afdd9a6..f9ea01ff 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt @@ -12,8 +12,8 @@ import com.mikepenz.iconics.typeface.library.community.material.CommunityMateria import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.MainActivity import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.databinding.FragmentHomeworkBinding import pl.szczodrzynski.edziennik.data.db.modules.metadata.Metadata +import pl.szczodrzynski.edziennik.databinding.FragmentHomeworkBinding import pl.szczodrzynski.edziennik.ui.dialogs.event.EventManualDialog import pl.szczodrzynski.edziennik.ui.modules.messages.MessagesFragment import pl.szczodrzynski.edziennik.utils.Themes @@ -84,7 +84,11 @@ class HomeworkFragment : Fragment() { b.viewPager.currentItem = pageSelection b.viewPager.clearOnPageChangeListeners() b.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrollStateChanged(state: Int) {} + override fun onPageScrollStateChanged(state: Int) { + if (b.refreshLayout != null) { + b.refreshLayout.isEnabled = state == ViewPager.SCROLL_STATE_IDLE + } + } override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { pageSelection = position diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/messages/MessagesFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/messages/MessagesFragment.kt index 094adc40..03fd355d 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/messages/MessagesFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/messages/MessagesFragment.kt @@ -77,7 +77,11 @@ class MessagesFragment : Fragment() { b.viewPager.currentItem = pageSelection b.viewPager.clearOnPageChangeListeners() b.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener { - override fun onPageScrollStateChanged(state: Int) {} + override fun onPageScrollStateChanged(state: Int) { + if (b.refreshLayout != null) { + b.refreshLayout.isEnabled = state == ViewPager.SCROLL_STATE_IDLE + } + } override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {} override fun onPageSelected(position: Int) { pageSelection = position