aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-01-05 00:34:11 -0500
committerAllan Wang <me@allanwang.ca>2019-01-05 00:34:11 -0500
commit4c32104d29de32cecf3c9647a8f628bd835e14cf (patch)
treeb9eb4105bf4942742a8b6af10673ae4e940cb78c /app/src/main/kotlin
parent5c89202f74f68ee6f273296014b5fff837520246 (diff)
downloadfrost-4c32104d29de32cecf3c9647a8f628bd835e14cf.tar.gz
frost-4c32104d29de32cecf3c9647a8f628bd835e14cf.tar.bz2
frost-4c32104d29de32cecf3c9647a8f628bd835e14cf.zip
Use conflated channels where possible, resolves #1314
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt11
2 files changed, 9 insertions, 4 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 230c1a55..044a1f37 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -34,7 +34,7 @@ import org.jsoup.Jsoup
class MainActivity : BaseMainActivity() {
override val fragmentChannel = BroadcastChannel<Int>(10)
- override val headerBadgeChannel = Channel<String>(Channel.RENDEZVOUS)
+ override val headerBadgeChannel = Channel<String>(Channel.CONFLATED)
var lastPosition = -1
override fun onNestedCreate(savedInstanceState: Bundle?) {
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 72d8803c..575e5a4d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostContentView.kt
@@ -43,6 +43,7 @@ import com.pitchedapps.frost.utils.Prefs
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.BroadcastChannel
+import kotlinx.coroutines.channels.ConflatedBroadcastChannel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.launch
@@ -82,9 +83,13 @@ abstract class FrostContentView<out T> @JvmOverloads constructor(
override val core: FrostContentCore
get() = coreView
- override val refreshChannel: BroadcastChannel<Boolean> = BroadcastChannel(100)
- override val progressChannel: BroadcastChannel<Int> = BroadcastChannel(100)
- override val titleChannel: BroadcastChannel<String> = BroadcastChannel(100)
+ /**
+ * While this can be conflated, there exist situations where we wish to watch refresh cycles.
+ * Here, we'd need to make sure we don't skip events
+ */
+ override val refreshChannel: BroadcastChannel<Boolean> = BroadcastChannel(10)
+ override val progressChannel: BroadcastChannel<Int> = ConflatedBroadcastChannel()
+ override val titleChannel: BroadcastChannel<String> = ConflatedBroadcastChannel()
override lateinit var scope: CoroutineScope