aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-01-12 23:07:02 -0800
committerAllan Wang <me@allanwang.ca>2021-01-12 23:07:02 -0800
commit5aec10ce0fe191d78399869074c7e118256848ea (patch)
treeaff3d79f003ef1200a36b810a336d6947e69114d /app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
parentce9e44a742638eaaad5833f39d394535ddfd67a2 (diff)
downloadfrost-5aec10ce0fe191d78399869074c7e118256848ea.tar.gz
frost-5aec10ce0fe191d78399869074c7e118256848ea.tar.bz2
frost-5aec10ce0fe191d78399869074c7e118256848ea.zip
Fix swipe disable logic and disable for messenger
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt22
1 files changed, 16 insertions, 6 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
index e25b603e..177b8862 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
@@ -22,7 +22,6 @@ import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ProgressBar
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import ca.allanwang.kau.utils.ContextHelper
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.circularReveal
@@ -104,14 +103,26 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
protected abstract val layoutRes: Int
- override var swipeEnabled = true
+ @Volatile
+ override var swipeDisabledByAction = false
set(value) {
- if (field == value)
- return
field = value
- refresh.post { refresh.isEnabled = value }
+ updateSwipeEnabler()
}
+ @Volatile
+ override var swipeAllowedByPage: Boolean = true
+ set(value) {
+ field = value
+ updateSwipeEnabler()
+ }
+
+ private fun updateSwipeEnabler() {
+ val swipeEnabled = swipeAllowedByPage && !swipeDisabledByAction
+ if (refresh.isEnabled == swipeEnabled) return
+ refresh.post { refresh.isEnabled = swipeEnabled }
+ }
+
/**
* Sets up everything
* Called by [bind]
@@ -136,7 +147,6 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
refreshChannel.subscribeDuringJob(scope, ContextHelper.coroutineContext) { r ->
refresh.isRefreshing = r
- refresh.isEnabled = true
}
progressChannel.subscribeDuringJob(scope, ContextHelper.coroutineContext) { p ->