aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-07-01 11:57:38 -0700
committerAllan Wang <me@allanwang.ca>2019-07-01 11:57:38 -0700
commit42caa8a566c9416fc9f956e346b6001b5d7b549a (patch)
tree28f06e42bececc352bada06a19d10ccbc23eb0ce /app
parente6bc006975a682c84d8a71b28ad084ce3629f65c (diff)
downloadfrost-42caa8a566c9416fc9f956e346b6001b5d7b549a.tar.gz
frost-42caa8a566c9416fc9f956e346b6001b5d7b549a.tar.bz2
frost-42caa8a566c9416fc9f956e346b6001b5d7b549a.zip
Support setting own child scroll callback
Diffstat (limited to 'app')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt8
2 files changed, 7 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
index 42a0f6bb..0fb24f7e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/LoginActivity.kt
@@ -41,7 +41,6 @@ import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.profilePictureUrl
import com.pitchedapps.frost.glide.FrostGlide
import com.pitchedapps.frost.glide.GlideApp
-import com.pitchedapps.frost.glide.transform
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Showcase
import com.pitchedapps.frost.utils.frostEvent
@@ -87,9 +86,6 @@ class LoginActivity : BaseActivity() {
toolbar(toolbar)
}
profileLoader = GlideApp.with(profile)
- swipeRefresh.setOnChildScrollUpCallback { parent, child ->
- web.canScrollVertically(-1)
- }
launch {
for (refreshing in refreshChannel.uniqueOnly(this)) {
if (refreshing) swipeRefresh.isEnabled = true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt
index 0ab11fc6..451f3948 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/SwipeRefreshLayout.kt
@@ -24,11 +24,13 @@ class SwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: Attr
private var downY: Float = -1f
private val touchSlop = ViewConfiguration.get(context).scaledTouchSlop
+ private var nestedCanChildScrollUp: OnChildScrollUpCallback? = null
+
/**
* Copy of [canChildScrollUp], with additional support if necessary
*/
private val canChildScrollUp = OnChildScrollUpCallback { parent, child ->
- when (child) {
+ nestedCanChildScrollUp?.canChildScrollUp(parent, child) ?: when (child) {
is WebView -> child.canScrollVertically(-1).apply {
L.d { "Webview can scroll up $this" }
}
@@ -42,6 +44,10 @@ class SwipeRefreshLayout @JvmOverloads constructor(context: Context, attrs: Attr
setOnChildScrollUpCallback(canChildScrollUp)
}
+ override fun setOnChildScrollUpCallback(callback: OnChildScrollUpCallback?) {
+ this.nestedCanChildScrollUp = callback
+ }
+
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
if (ev.action != MotionEvent.ACTION_DOWN && preventRefresh) {
return false