aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-28 21:43:49 -0500
committerGitHub <noreply@github.com>2018-12-28 21:43:49 -0500
commit8c4db7d79d4f9557d0eef2ef707663c5e8a7aac6 (patch)
tree8e6202efb768d954145038cb8642453c62650c5e /app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
parent7d85262ada198501d2d5844e1196c9b45f4a38f5 (diff)
parent66a6657b81e6274e1eac33c4c7379d3db2c463fb (diff)
downloadfrost-8c4db7d79d4f9557d0eef2ef707663c5e8a7aac6.tar.gz
frost-8c4db7d79d4f9557d0eef2ef707663c5e8a7aac6.tar.bz2
frost-8c4db7d79d4f9557d0eef2ef707663c5e8a7aac6.zip
Merge pull request #1265 from AllanWang/enhancement/coroutine-ui
Replace coroutines in view logic
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
index 2b9e8f9c..f7cb2214 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt
@@ -28,6 +28,7 @@ import com.pitchedapps.frost.contracts.FrostContentCore
import com.pitchedapps.frost.contracts.FrostContentParent
import com.pitchedapps.frost.fragments.RecyclerContentContract
import com.pitchedapps.frost.utils.Prefs
+import kotlinx.coroutines.launch
/**
* Created by Allan Wang on 2017-05-29.
@@ -69,11 +70,12 @@ class FrostRecyclerView @JvmOverloads constructor(
override fun reloadBase(animate: Boolean) {
if (Prefs.animate) fadeOut(onFinish = onReloadClear)
- parent.refreshObservable.onNext(true)
- recyclerContract.reload({ parent.progressObservable.onNext(it) }) {
- parent.progressObservable.onNext(100)
- parent.refreshObservable.onNext(false)
- if (Prefs.animate) post { circularReveal() }
+ scope.launch {
+ parent.refreshChannel.offer(true)
+ val loaded = recyclerContract.reload { parent.progressChannel.offer(it) }
+ parent.progressChannel.offer(100)
+ parent.refreshChannel.offer(false)
+ if (Prefs.animate) circularReveal()
}
}