diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-27 02:15:10 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2018-12-27 02:15:10 -0500 |
commit | e6dcbd7b32dc49b11184b6beca598819c3f071fd (patch) | |
tree | a02691a1eaf1b1506930c7e50c5f43f6f0fc953a /app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt | |
parent | 7d85262ada198501d2d5844e1196c9b45f4a38f5 (diff) | |
download | frost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.tar.gz frost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.tar.bz2 frost-e6dcbd7b32dc49b11184b6beca598819c3f071fd.zip |
Begin replacing observables with channels
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.kt | 14 |
1 files changed, 9 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..fb20c3ba 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostRecyclerView.kt @@ -23,11 +23,14 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.utils.circularReveal import ca.allanwang.kau.utils.fadeOut +import com.pitchedapps.frost.R.string.reload import com.pitchedapps.frost.contracts.FrostContentContainer 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.CoroutineScope +import kotlinx.coroutines.launch /** * Created by Allan Wang on 2017-05-29. @@ -69,11 +72,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.send(true) + val loaded = recyclerContract.reload { parent.progressChannel.offer(it) } + parent.progressChannel.send(100) + parent.refreshChannel.send(false) + if (Prefs.animate) circularReveal() } } |