From 00b0d8a31d62820c2b018fd3b16dba96877f98ab Mon Sep 17 00:00:00 2001 From: Dmitriy Krivoruchko Date: Thu, 3 Jun 2021 14:49:42 +0300 Subject: [PATCH] Dependency updates --- app/build.gradle | 14 +++++++------- build.gradle | 2 +- data/build.gradle | 10 +++++----- .../screenstream/data/state/AppStateMachineImpl.kt | 12 +++++++++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 663cbda2..497a89e2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId = "info.dvkr.screenstream" minSdkVersion(21) targetSdkVersion(30) - versionCode = 30603 - versionName = "3.6.3" + versionCode = 30604 + versionName = "3.6.4" resConfigs("en", "ru", "pt-rBR", "zh-rTW", "fr-rFR", "fa", "it", "pl", "hi", "de", "sk", "es", "ar", "ja", "gl", "ca") vectorDrawables.useSupportLibrary = true @@ -81,12 +81,12 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0") - implementation("androidx.core:core-ktx:1.5.0-rc02") + implementation("androidx.core:core-ktx:1.5.0") implementation("androidx.activity:activity-ktx:1.2.3") - implementation("androidx.fragment:fragment-ktx:1.3.3") - implementation("androidx.appcompat:appcompat:1.3.0-rc01") + implementation("androidx.fragment:fragment-ktx:1.3.4") + implementation("androidx.appcompat:appcompat:1.3.0") implementation("androidx.constraintlayout:constraintlayout:2.0.4") - implementation("androidx.recyclerview:recyclerview:1.2.0") + implementation("androidx.recyclerview:recyclerview:1.2.1") implementation("com.google.android.material:material:1.3.0") implementation("androidx.navigation:navigation-fragment-ktx:2.3.5") @@ -102,7 +102,7 @@ dependencies { implementation(fileTree("libs/bottomsheets-release.aar")) // implementation("com.afollestad.material-dialogs:bottomsheets:3.3.0") - implementation("io.insert-koin:koin-android:3.0.1") + implementation("io.insert-koin:koin-android:3.0.2") implementation("com.github.iamironz:binaryprefs:1.0.1") implementation("com.elvishew:xlog:1.9.0") diff --git a/build.gradle b/build.gradle index 1a6fcf62..2ac8b6be 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { dependencies { classpath("com.android.tools.build:gradle:4.2.1") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10") classpath("com.google.gms:google-services:4.3.8") classpath("com.google.firebase:firebase-crashlytics-gradle:2.6.1") } diff --git a/data/build.gradle b/data/build.gradle index de4e551e..e2a738b9 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion(21) targetSdkVersion(30) - versionCode = 30603 - versionName = "3.6.3" + versionCode = 30604 + versionName = "3.6.4" } compileOptions { @@ -28,11 +28,11 @@ android { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0") - implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.0") + implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.10") - implementation("androidx.core:core:1.5.0-rc02") + implementation("androidx.core:core:1.5.0") - implementation("io.ktor:ktor-server-cio:1.5.4") + implementation("io.ktor:ktor-server-cio:1.6.0") implementation("com.github.iamironz:binaryprefs:1.0.1") implementation("com.elvishew:xlog:1.9.0") diff --git a/data/src/main/kotlin/info/dvkr/screenstream/data/state/AppStateMachineImpl.kt b/data/src/main/kotlin/info/dvkr/screenstream/data/state/AppStateMachineImpl.kt index 9eb3b73f..995c4753 100644 --- a/data/src/main/kotlin/info/dvkr/screenstream/data/state/AppStateMachineImpl.kt +++ b/data/src/main/kotlin/info/dvkr/screenstream/data/state/AppStateMachineImpl.kt @@ -19,6 +19,7 @@ import info.dvkr.screenstream.data.state.helper.MediaProjectionHelper import info.dvkr.screenstream.data.state.helper.NetworkHelper import kotlinx.coroutines.* import kotlinx.coroutines.flow.* +import java.util.concurrent.LinkedBlockingDeque class AppStateMachineImpl( context: Context, @@ -91,8 +92,10 @@ class AppStateMachineImpl( XLog.d(getLog("sendEvent", "Event: $event")) try { + _eventDeque.addLast(event) _eventSharedFlow.tryEmit(event) || throw IllegalStateException("_eventSharedFlow IsFull") } catch (th: Throwable) { + XLog.e(getLog("sendEvent", _eventDeque.toString())) XLog.e(getLog("sendEvent"), th) coroutineScope.launch(NonCancellable) { onEffect( @@ -106,6 +109,7 @@ class AppStateMachineImpl( private var streamState = StreamState() private var previousStreamState = StreamState() private val _eventSharedFlow = MutableSharedFlow(extraBufferCapacity = 32) + private val _eventDeque = LinkedBlockingDeque() init { XLog.d(getLog("init")) @@ -118,7 +122,7 @@ class AppStateMachineImpl( streamState = when (event) { is InternalEvent.DiscoverAddress -> discoverAddress(streamState) is InternalEvent.StartServer -> startServer(streamState) - is InternalEvent.ComponentError -> componentError(streamState, event.appError) + is InternalEvent.ComponentError -> componentError(streamState, event.appError, false) is InternalEvent.StartStopFromWebPage -> startStopFromWebPage(streamState) is InternalEvent.RestartServer -> restartServer(streamState, event.reason) is InternalEvent.ScreenOff -> screenOff(streamState) @@ -135,12 +139,13 @@ class AppStateMachineImpl( if (streamState.isPublicStatePublishRequired(previousStreamState)) onEffect(streamState.toPublicState()) + _eventDeque.pollFirst() XLog.i(this@AppStateMachineImpl.getLog("eventSharedFlow.onEach", "New state:${streamState.state}")) } } .catch { cause -> XLog.e(this@AppStateMachineImpl.getLog("eventSharedFlow.catch"), cause) - streamState = componentError(streamState, FatalError.CoroutineException) + streamState = componentError(streamState, FatalError.CoroutineException, true) onEffect(streamState.toPublicState()) } .collect() @@ -349,8 +354,9 @@ class AppStateMachineImpl( ) } - private fun componentError(streamState: StreamState, appError: AppError): StreamState { + private fun componentError(streamState: StreamState, appError: AppError, report: Boolean): StreamState { XLog.d(getLog("componentError")) + if (report) XLog.e(getLog("componentError"), appError) return stopProjection(streamState).copy(state = StreamState.State.ERROR, appError = appError) }