From 954c7408746c13dde762cda539b7d660ef1e5095 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:21:13 +0330 Subject: [PATCH 01/10] Adding :core:network:light-streamer for #56 --- app/build.gradle | 4 +- build.gradle | 8 +-- core/network/light-streamer/.gitignore | 1 + core/network/light-streamer/build.gradle | 44 +++++++++++++++ .../network/light-streamer/consumer-rules.pro | 0 .../network/light-streamer/proguard-rules.pro | 21 ++++++++ .../src/main/AndroidManifest.xml | 4 ++ .../DefaultLightStreamerConnection.kt | 54 ++----------------- .../connection/LightStreamerConnection.kt | 48 +++++++++++++++++ .../listeners/EmptyClientListener.kt | 12 +++++ .../light_streamer/models/SubscriptionMode.kt | 6 +++ .../service/LightStreamerService.kt | 12 +++++ settings.gradle | 1 + 13 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 core/network/light-streamer/.gitignore create mode 100644 core/network/light-streamer/build.gradle create mode 100644 core/network/light-streamer/consumer-rules.pro create mode 100644 core/network/light-streamer/proguard-rules.pro create mode 100644 core/network/light-streamer/src/main/AndroidManifest.xml rename app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt => core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt (72%) create mode 100644 core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt create mode 100644 core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt create mode 100644 core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt create mode 100644 core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt diff --git a/app/build.gradle b/app/build.gradle index 396501f..e0bd11a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,9 +69,6 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.1.4' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0' - implementation "com.lightstreamer:ls-android-client:4.2.6" - implementation "com.lightstreamer:ls-log-adapter-java:1.0.2" - implementation "androidx.navigation:navigation-compose:2.5.3" @@ -90,6 +87,7 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2' + implementation project(":core:network:light-streamer") // testImplementation "io.mockk:mockk:1.12.4" // androidTestImplementation "io.mockk:mockk-android:1.12.4" } diff --git a/build.gradle b/build.gradle index 27711ee..6de47ed 100644 --- a/build.gradle +++ b/build.gradle @@ -15,8 +15,8 @@ plugins { } subprojects { - apply from: "../buildscripts/ktlint.gradle" - apply from: "../buildscripts/detekt.gradle" - apply from: "../buildscripts/git-hooks.gradle" - apply from: "../buildscripts/versionsplugin.gradle" + apply from: "$rootDir/buildscripts/ktlint.gradle" + apply from: "$rootDir/buildscripts/detekt.gradle" + apply from: "$rootDir/buildscripts/git-hooks.gradle" + apply from: "$rootDir/buildscripts/versionsplugin.gradle" } \ No newline at end of file diff --git a/core/network/light-streamer/.gitignore b/core/network/light-streamer/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/core/network/light-streamer/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/network/light-streamer/build.gradle b/core/network/light-streamer/build.gradle new file mode 100644 index 0000000..6aa4c76 --- /dev/null +++ b/core/network/light-streamer/build.gradle @@ -0,0 +1,44 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'garousi.dev.light_streamer' + compileSdk 33 + + defaultConfig { + minSdk 23 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + + api "com.lightstreamer:ls-android-client:4.2.6" + api "com.lightstreamer:ls-log-adapter-java:1.0.2" + +} \ No newline at end of file diff --git a/core/network/light-streamer/consumer-rules.pro b/core/network/light-streamer/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/core/network/light-streamer/proguard-rules.pro b/core/network/light-streamer/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/core/network/light-streamer/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/core/network/light-streamer/src/main/AndroidManifest.xml b/core/network/light-streamer/src/main/AndroidManifest.xml new file mode 100644 index 0000000..44008a4 --- /dev/null +++ b/core/network/light-streamer/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt similarity index 72% rename from app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt rename to core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt index 26738ae..782a0a8 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt @@ -1,58 +1,14 @@ -@file:Suppress("LongParameterList", "TooManyFunctions") - -package dev.garousi.stockwatcher.feature.watchlist.data +package garousi.dev.light_streamer.connection import android.util.Log import com.lightstreamer.client.ClientListener import com.lightstreamer.client.LightstreamerClient import com.lightstreamer.client.Subscription import com.lightstreamer.client.SubscriptionListener -import javax.inject.Inject - -interface LightStreamerConnection { - val lsClient: LightstreamerClient? - var subscriptionListener: SubscriptionListener? - var subscription: Subscription? - fun connect(serverAddress: String, adapterSet: String) - fun disconnect() - fun subscribe( - subscriptionMode: SubscriptionMode, - dataAdapter: String? = null, - requestedSnapshot: String? = null, - requestedMaxFrequency: String? = null, - itemNames: Array, - fieldNames: Array, - ): Subscription? - - fun subscribe( - subscriptionMode: SubscriptionMode, - dataAdapter: String? = null, - requestedSnapshot: String? = null, - requestedMaxFrequency: String? = null, - itemName: String, - fieldNames: Array, - ): Subscription? - - fun unsubscribe() - fun subscribeToClient() - fun setSubscription( - subscriptionMode: SubscriptionMode, - itemNames: Array, - fieldNames: Array, - ) - - fun setSubscription( - subscriptionMode: SubscriptionMode, - itemName: String, - fieldNames: Array, - ) - - fun setRequestedSnapshot(requestedSnapshot: String?) - fun setRequestedMaxFrequency(requestedMaxFrequency: String?) -} - -class LightStreamerConnectionImpl @Inject constructor() : LightStreamerConnection { +import garousi.dev.light_streamer.listeners.EmptyClientListener +import garousi.dev.light_streamer.models.SubscriptionMode +class DefaultLightStreamerConnection : LightStreamerConnection { override var lsClient: LightstreamerClient? = null override var subscription: Subscription? = null override var subscriptionListener: SubscriptionListener? = null @@ -161,4 +117,4 @@ class LightStreamerConnectionImpl @Inject constructor() : LightStreamerConnectio ) { subscription = Subscription(subscriptionMode.name, itemName, fieldNames) } -} +} \ No newline at end of file diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt new file mode 100644 index 0000000..3323ebb --- /dev/null +++ b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt @@ -0,0 +1,48 @@ +package garousi.dev.light_streamer.connection + +import com.lightstreamer.client.LightstreamerClient +import com.lightstreamer.client.Subscription +import com.lightstreamer.client.SubscriptionListener +import garousi.dev.light_streamer.models.SubscriptionMode + +interface LightStreamerConnection { + val lsClient: LightstreamerClient? + var subscriptionListener: SubscriptionListener? + var subscription: Subscription? + fun connect(serverAddress: String, adapterSet: String) + fun disconnect() + fun subscribe( + subscriptionMode: SubscriptionMode, + dataAdapter: String? = null, + requestedSnapshot: String? = null, + requestedMaxFrequency: String? = null, + itemNames: Array, + fieldNames: Array, + ): Subscription? + + fun subscribe( + subscriptionMode: SubscriptionMode, + dataAdapter: String? = null, + requestedSnapshot: String? = null, + requestedMaxFrequency: String? = null, + itemName: String, + fieldNames: Array, + ): Subscription? + + fun unsubscribe() + fun subscribeToClient() + fun setSubscription( + subscriptionMode: SubscriptionMode, + itemNames: Array, + fieldNames: Array, + ) + + fun setSubscription( + subscriptionMode: SubscriptionMode, + itemName: String, + fieldNames: Array, + ) + + fun setRequestedSnapshot(requestedSnapshot: String?) + fun setRequestedMaxFrequency(requestedMaxFrequency: String?) +} \ No newline at end of file diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt new file mode 100644 index 0000000..20aa2cc --- /dev/null +++ b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt @@ -0,0 +1,12 @@ +package garousi.dev.light_streamer.listeners + +import com.lightstreamer.client.ClientListener +import com.lightstreamer.client.LightstreamerClient + +object EmptyClientListener : ClientListener { + override fun onListenStart(client: LightstreamerClient) = Unit + override fun onListenEnd(client: LightstreamerClient) = Unit + override fun onServerError(errorCode: Int, errorMessage: String) = Unit + override fun onStatusChange(status: String) = Unit + override fun onPropertyChange(property: String) = Unit +} diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt new file mode 100644 index 0000000..6f87774 --- /dev/null +++ b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt @@ -0,0 +1,6 @@ +package garousi.dev.light_streamer.models + +enum class SubscriptionMode { + Merge, + Command, +} diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt new file mode 100644 index 0000000..0db96cf --- /dev/null +++ b/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt @@ -0,0 +1,12 @@ +package garousi.dev.light_streamer.service + +import com.lightstreamer.client.ItemUpdate +import kotlinx.coroutines.flow.StateFlow + +interface LightStreamerService { + val stream: StateFlow + fun subscribe(vararg params: Any): LightStreamerService + fun unsubscribe() + fun observeSubscriptionUpdates() + fun setFieldsToDto(itemUpdate: ItemUpdate) +} diff --git a/settings.gradle b/settings.gradle index 3b78b01..d12910d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,3 +14,4 @@ dependencyResolutionManagement { } rootProject.name = "Stock Watcher" include ':app' +include ':core:network:light-streamer' From 349303ed554d378088d16a087d2ed6d3431cfd75 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:33:45 +0330 Subject: [PATCH 02/10] Resolving detekt issues #56 --- .../watchlist/data/EmptyClientListener.kt | 12 ---- .../watchlist/data/LightStreamerService.kt | 12 ---- .../feature/watchlist/data/StockListDto.kt | 2 +- .../data/StockListLightStreamerService.kt | 21 +++--- .../watchlist/data/SubscriptionMode.kt | 7 -- .../watchlist/di/LightStreamerModule.kt | 6 +- .../watchlist/di/WatchlistListModule.kt | 31 ++------ .../presentation/WatchlistViewModel.kt | 71 ++++++++----------- .../DefaultLightStreamerConnection.kt | 8 +-- .../connection/LightStreamerConnection.kt | 6 +- .../listeners/EmptyClientListener.kt | 2 +- .../models/SubscriptionMode.kt | 2 +- .../service/LightStreamerService.kt | 2 +- 13 files changed, 65 insertions(+), 117 deletions(-) delete mode 100644 app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/EmptyClientListener.kt delete mode 100644 app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerService.kt delete mode 100644 app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt rename core/network/light-streamer/src/main/java/garousi/dev/{light_streamer => lightstreamer}/connection/DefaultLightStreamerConnection.kt (95%) rename core/network/light-streamer/src/main/java/garousi/dev/{light_streamer => lightstreamer}/connection/LightStreamerConnection.kt (93%) rename core/network/light-streamer/src/main/java/garousi/dev/{light_streamer => lightstreamer}/listeners/EmptyClientListener.kt (91%) rename core/network/light-streamer/src/main/java/garousi/dev/{light_streamer => lightstreamer}/models/SubscriptionMode.kt (57%) rename core/network/light-streamer/src/main/java/garousi/dev/{light_streamer => lightstreamer}/service/LightStreamerService.kt (88%) diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/EmptyClientListener.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/EmptyClientListener.kt deleted file mode 100644 index 4ba1330..0000000 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/EmptyClientListener.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.garousi.stockwatcher.feature.watchlist.data - -import com.lightstreamer.client.ClientListener -import com.lightstreamer.client.LightstreamerClient - -object EmptyClientListener : ClientListener { - override fun onListenStart(client: LightstreamerClient) = Unit - override fun onListenEnd(client: LightstreamerClient) = Unit - override fun onServerError(errorCode: Int, errorMessage: String) = Unit - override fun onStatusChange(status: String) = Unit - override fun onPropertyChange(property: String) = Unit -} diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerService.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerService.kt deleted file mode 100644 index aa3d9ba..0000000 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/LightStreamerService.kt +++ /dev/null @@ -1,12 +0,0 @@ -package dev.garousi.stockwatcher.feature.watchlist.data - -import com.lightstreamer.client.ItemUpdate -import kotlinx.coroutines.flow.StateFlow - -interface LightStreamerService { - val flow: StateFlow - fun subscribe(vararg params: Any): LightStreamerService - fun unsubscribe() - fun observeSubscriptionUpdates() - fun setFieldsToDto(itemUpdate: ItemUpdate) -} diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListDto.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListDto.kt index a1dd754..53de717 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListDto.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListDto.kt @@ -16,5 +16,5 @@ data class StockListDto( val min: Double? = null, val max: Double? = null, val ref: Double? = null, - val open: Double? = null, + val open: Double? = null ) diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListLightStreamerService.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListLightStreamerService.kt index e1b702b..8bbe299 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListLightStreamerService.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/StockListLightStreamerService.kt @@ -4,9 +4,11 @@ import android.util.Log import com.lightstreamer.client.ItemUpdate import com.lightstreamer.client.Subscription import com.lightstreamer.client.SubscriptionListener +import garousi.dev.lightstreamer.connection.LightStreamerConnection +import garousi.dev.lightstreamer.models.SubscriptionMode +import garousi.dev.lightstreamer.service.LightStreamerService import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow @@ -16,15 +18,18 @@ import javax.inject.Inject class StockListLightStreamerService @Inject constructor( private val connection: LightStreamerConnection, + private val externalScope: CoroutineScope ) : LightStreamerService { - private val scope = CoroutineScope(SupervisorJob()) private var dto = StockListDto() - private val _flow: MutableStateFlow = MutableStateFlow(StockListDto()) - override val flow = _flow.asStateFlow() + private val _stockListStream: MutableStateFlow = MutableStateFlow(StockListDto()) + override val stream = _stockListStream.asStateFlow() init { - connection.connect(serverAddress = serverAddress, adapterSet = adapterSet) + connection.connect( + serverAddress = serverAddress, + adapterSet = adapterSet + ) } companion object { @@ -152,13 +157,13 @@ class StockListLightStreamerService @Inject constructor( ref = ref, open = open, ) - scope.launch(Dispatchers.IO) { - _flow.emit(dto) + externalScope.launch(Dispatchers.IO) { + _stockListStream.emit(dto) } } override fun unsubscribe() { connection.unsubscribe() - scope.cancel() + externalScope.cancel() } } diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt deleted file mode 100644 index ce6e560..0000000 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/data/SubscriptionMode.kt +++ /dev/null @@ -1,7 +0,0 @@ -@file:Suppress("UnusedPrivateMember") -package dev.garousi.stockwatcher.feature.watchlist.data - -enum class SubscriptionMode { - Merge, - Command, -} diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/LightStreamerModule.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/LightStreamerModule.kt index 47af65d..b44e9b6 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/LightStreamerModule.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/LightStreamerModule.kt @@ -6,8 +6,8 @@ import dagger.Binds import dagger.Module import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import dev.garousi.stockwatcher.feature.watchlist.data.LightStreamerConnection -import dev.garousi.stockwatcher.feature.watchlist.data.LightStreamerConnectionImpl +import garousi.dev.lightstreamer.connection.DefaultLightStreamerConnection +import garousi.dev.lightstreamer.connection.LightStreamerConnection import javax.inject.Singleton @Module @@ -15,5 +15,5 @@ import javax.inject.Singleton abstract class LightStreamerModule { @Binds @Singleton - abstract fun bindsLightStreamerService(impl: LightStreamerConnectionImpl): LightStreamerConnection + abstract fun bindsLightStreamerService(impl: DefaultLightStreamerConnection): LightStreamerConnection } diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/WatchlistListModule.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/WatchlistListModule.kt index 5a044b0..5c7831e 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/WatchlistListModule.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/di/WatchlistListModule.kt @@ -1,37 +1,20 @@ package dev.garousi.stockwatcher.feature.watchlist.di +import dagger.Binds import dagger.Module -import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent -import dev.garousi.stockwatcher.feature.watchlist.data.LightStreamerConnection -import dev.garousi.stockwatcher.feature.watchlist.data.LightStreamerService import dev.garousi.stockwatcher.feature.watchlist.data.StockListDto import dev.garousi.stockwatcher.feature.watchlist.data.StockListLightStreamerService +import garousi.dev.lightstreamer.service.LightStreamerService import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) -object WatchlistListModule { -// @Provides -// fun provideGetStockListUseCase( -// repository: StockRepository -// ): GetStockListUseCase { -// return GetStockListUseCase(repository) -// } -// -// @Provides -// fun provideStockListUseCases( -// getStockListUseCase: GetStockListUseCase -// ): StockListUseCases { -// return StockListUseCases(getStockList = getStockListUseCase) -// } - - @Provides +interface WatchlistListModule { + @Binds @Singleton - fun provideStockListLightStreamerService( - connection: LightStreamerConnection, - ): LightStreamerService { - return StockListLightStreamerService(connection = connection) - } + fun bindsStockListLightStreamerService( + impl: StockListLightStreamerService + ): LightStreamerService } diff --git a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistViewModel.kt b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistViewModel.kt index 16adeca..4ab0955 100644 --- a/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistViewModel.kt +++ b/app/src/main/java/dev/garousi/stockwatcher/feature/watchlist/presentation/WatchlistViewModel.kt @@ -1,19 +1,17 @@ @file:Suppress("CyclomaticComplexMethod") + package dev.garousi.stockwatcher.feature.watchlist.presentation -import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel -import dev.garousi.stockwatcher.feature.watchlist.data.LightStreamerService import dev.garousi.stockwatcher.feature.watchlist.data.StockListDto +import garousi.dev.lightstreamer.service.LightStreamerService import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.flow.stateIn +import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel @@ -30,41 +28,34 @@ class WatchlistViewModel @Inject constructor( } private fun subscribeToDemoAdapterSet() { - stockListLightStreamerService - .subscribe() - .flow - .map { stock -> - _uiState.update { it.copy(isLoading = false) } - stock.itemPos?.let { updatedItemIndex -> - _uiState.update { - it.copy( - stocks = it.stocks.toMutableList().apply { - this[updatedItemIndex - 1] = this[updatedItemIndex - 1].copy( - name = stock.name ?: it.stocks[updatedItemIndex].name, - last = stock.last ?: it.stocks[updatedItemIndex].last, - time = stock.time ?: it.stocks[updatedItemIndex].time, - change = stock.change ?: it.stocks[updatedItemIndex].change, - bidSize = stock.bidSize ?: it.stocks[updatedItemIndex].bidSize, - bid = stock.bid ?: it.stocks[updatedItemIndex].bid, - ask = stock.ask ?: it.stocks[updatedItemIndex].ask, - askSize = stock.askSize ?: it.stocks[updatedItemIndex].askSize, - min = stock.min ?: it.stocks[updatedItemIndex].min, - max = stock.max ?: it.stocks[updatedItemIndex].max, - ref = stock.ref ?: it.stocks[updatedItemIndex].ref, - open = stock.open ?: it.stocks[updatedItemIndex].open, - ) - }, - ) + viewModelScope.launch { + stockListLightStreamerService + .subscribe() + .stream + .collectLatest { stock -> + stock.itemPos?.let { updatedItemIndex -> + _uiState.update { + it.copy( + stocks = it.stocks.toMutableList().apply { + this[updatedItemIndex - 1] = this[updatedItemIndex - 1].copy( + name = stock.name ?: it.stocks[updatedItemIndex].name, + last = stock.last ?: it.stocks[updatedItemIndex].last, + time = stock.time ?: it.stocks[updatedItemIndex].time, + change = stock.change ?: it.stocks[updatedItemIndex].change, + bidSize = stock.bidSize ?: it.stocks[updatedItemIndex].bidSize, + bid = stock.bid ?: it.stocks[updatedItemIndex].bid, + ask = stock.ask ?: it.stocks[updatedItemIndex].ask, + askSize = stock.askSize ?: it.stocks[updatedItemIndex].askSize, + min = stock.min ?: it.stocks[updatedItemIndex].min, + max = stock.max ?: it.stocks[updatedItemIndex].max, + ref = stock.ref ?: it.stocks[updatedItemIndex].ref, + open = stock.open ?: it.stocks[updatedItemIndex].open, + ) + } + ) + } } } - } - .catch { cause: Throwable -> - Log.i("LOGGER", "" + cause.localizedMessage.orEmpty()) - } - .stateIn( - scope = viewModelScope, - initialValue = StockListDto(), - started = SharingStarted.Eagerly, - ) + } } } diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt similarity index 95% rename from core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt rename to core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt index 782a0a8..fb2edde 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/DefaultLightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt @@ -1,12 +1,12 @@ -package garousi.dev.light_streamer.connection +package garousi.dev.lightstreamer.connection import android.util.Log import com.lightstreamer.client.ClientListener import com.lightstreamer.client.LightstreamerClient import com.lightstreamer.client.Subscription import com.lightstreamer.client.SubscriptionListener -import garousi.dev.light_streamer.listeners.EmptyClientListener -import garousi.dev.light_streamer.models.SubscriptionMode +import garousi.dev.lightstreamer.listeners.EmptyClientListener +import garousi.dev.lightstreamer.models.SubscriptionMode class DefaultLightStreamerConnection : LightStreamerConnection { override var lsClient: LightstreamerClient? = null @@ -117,4 +117,4 @@ class DefaultLightStreamerConnection : LightStreamerConnection { ) { subscription = Subscription(subscriptionMode.name, itemName, fieldNames) } -} \ No newline at end of file +} diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt similarity index 93% rename from core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt rename to core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt index 3323ebb..4bf4c74 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/connection/LightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt @@ -1,9 +1,9 @@ -package garousi.dev.light_streamer.connection +package garousi.dev.lightstreamer.connection import com.lightstreamer.client.LightstreamerClient import com.lightstreamer.client.Subscription import com.lightstreamer.client.SubscriptionListener -import garousi.dev.light_streamer.models.SubscriptionMode +import garousi.dev.lightstreamer.models.SubscriptionMode interface LightStreamerConnection { val lsClient: LightstreamerClient? @@ -45,4 +45,4 @@ interface LightStreamerConnection { fun setRequestedSnapshot(requestedSnapshot: String?) fun setRequestedMaxFrequency(requestedMaxFrequency: String?) -} \ No newline at end of file +} diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/listeners/EmptyClientListener.kt similarity index 91% rename from core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt rename to core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/listeners/EmptyClientListener.kt index 20aa2cc..5286463 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/listeners/EmptyClientListener.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/listeners/EmptyClientListener.kt @@ -1,4 +1,4 @@ -package garousi.dev.light_streamer.listeners +package garousi.dev.lightstreamer.listeners import com.lightstreamer.client.ClientListener import com.lightstreamer.client.LightstreamerClient diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/models/SubscriptionMode.kt similarity index 57% rename from core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt rename to core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/models/SubscriptionMode.kt index 6f87774..1f2e9da 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/models/SubscriptionMode.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/models/SubscriptionMode.kt @@ -1,4 +1,4 @@ -package garousi.dev.light_streamer.models +package garousi.dev.lightstreamer.models enum class SubscriptionMode { Merge, diff --git a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/service/LightStreamerService.kt similarity index 88% rename from core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt rename to core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/service/LightStreamerService.kt index 0db96cf..12743c7 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/light_streamer/service/LightStreamerService.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/service/LightStreamerService.kt @@ -1,4 +1,4 @@ -package garousi.dev.light_streamer.service +package garousi.dev.lightstreamer.service import com.lightstreamer.client.ItemUpdate import kotlinx.coroutines.flow.StateFlow From fc3954e600f855881b06a4069dc559277f958416 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:36:03 +0330 Subject: [PATCH 03/10] Resolving LongParameterList issue in LightStreamerConnection.kt #56 --- .../dev/lightstreamer/connection/LightStreamerConnection.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt index 4bf4c74..4932f53 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/LightStreamerConnection.kt @@ -11,6 +11,7 @@ interface LightStreamerConnection { var subscription: Subscription? fun connect(serverAddress: String, adapterSet: String) fun disconnect() + @Suppress("LongParameterList") fun subscribe( subscriptionMode: SubscriptionMode, dataAdapter: String? = null, @@ -20,6 +21,7 @@ interface LightStreamerConnection { fieldNames: Array, ): Subscription? + @Suppress("LongParameterList") fun subscribe( subscriptionMode: SubscriptionMode, dataAdapter: String? = null, From 8884eb852e39d6a557d5c327d5b5ba32d1188a0a Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:39:09 +0330 Subject: [PATCH 04/10] Resolving TooManyFunctions issue in DefaultLightStreamerConnection.kt #56 --- .../lightstreamer/connection/DefaultLightStreamerConnection.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt index fb2edde..29b4381 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt @@ -1,3 +1,4 @@ +@file:Suppress("TooManyFunctions") // TODO: Do we need to separate this files methods in multiple file? package garousi.dev.lightstreamer.connection import android.util.Log From 316cf410880f22668a421ec1d1df28d96cc4a765 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:40:53 +0330 Subject: [PATCH 05/10] Disable ForbiddenComment in detekt #56 --- config/detekt/detekt.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/detekt/detekt.yml b/config/detekt/detekt.yml index 3bfc618..65c72e7 100644 --- a/config/detekt/detekt.yml +++ b/config/detekt/detekt.yml @@ -529,7 +529,7 @@ style: active: false includeLineWrapping: false ForbiddenComment: - active: true + active: false values: - 'FIXME:' - 'STOPSHIP:' From f1c0f9690c63dc4213e5f5d8dcb16dd3f1e91dda Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:49:46 +0330 Subject: [PATCH 06/10] Added :core:common for #58 --- app/build.gradle | 1 + core/common/.gitignore | 1 + core/common/build.gradle | 41 ++++++++++++++++++++++++ core/common/src/main/AndroidManifest.xml | 4 +++ settings.gradle | 1 + 5 files changed, 48 insertions(+) create mode 100644 core/common/.gitignore create mode 100644 core/common/build.gradle create mode 100644 core/common/src/main/AndroidManifest.xml diff --git a/app/build.gradle b/app/build.gradle index e0bd11a..f2dde6d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -88,6 +88,7 @@ dependencies { implementation project(":core:network:light-streamer") + implementation project(":core:common") // testImplementation "io.mockk:mockk:1.12.4" // androidTestImplementation "io.mockk:mockk-android:1.12.4" } diff --git a/core/common/.gitignore b/core/common/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/core/common/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/common/build.gradle b/core/common/build.gradle new file mode 100644 index 0000000..ccb571f --- /dev/null +++ b/core/common/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' +} + +android { + namespace 'garousi.dev.common' + compileSdk 33 + + defaultConfig { + minSdk 23 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'com.google.android.material:material:1.8.0' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' +} \ No newline at end of file diff --git a/core/common/src/main/AndroidManifest.xml b/core/common/src/main/AndroidManifest.xml new file mode 100644 index 0000000..44008a4 --- /dev/null +++ b/core/common/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index d12910d..9a5afb0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,3 +15,4 @@ dependencyResolutionManagement { rootProject.name = "Stock Watcher" include ':app' include ':core:network:light-streamer' +include ':core:common' From 8ff2f84ce87ee282bc6aa09b4fe25c86c824db37 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:57:32 +0330 Subject: [PATCH 07/10] Provide Coroutine Scope and Dispatchers Modules for #56 --- .../common/di/CoroutinesDispatchersModule.kt | 29 +++++++++++++++++++ .../dev/common/di/CoroutinesQualifiers.kt | 23 +++++++++++++++ .../dev/common/di/CoroutinesScopesModule.kt | 23 +++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 core/common/src/main/java/garousi/dev/common/di/CoroutinesDispatchersModule.kt create mode 100644 core/common/src/main/java/garousi/dev/common/di/CoroutinesQualifiers.kt create mode 100644 core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt diff --git a/core/common/src/main/java/garousi/dev/common/di/CoroutinesDispatchersModule.kt b/core/common/src/main/java/garousi/dev/common/di/CoroutinesDispatchersModule.kt new file mode 100644 index 0000000..e304ed4 --- /dev/null +++ b/core/common/src/main/java/garousi/dev/common/di/CoroutinesDispatchersModule.kt @@ -0,0 +1,29 @@ +package garousi.dev.common.di + +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers + +@Module +@InstallIn(SingletonComponent::class) +object CoroutinesDispatchersModule { + + @DefaultDispatcher + @Provides + fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default + + @IoDispatcher + @Provides + fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO + + @MainDispatcher + @Provides + fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main + + @MainImmediateDispatcher + @Provides + fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate +} diff --git a/core/common/src/main/java/garousi/dev/common/di/CoroutinesQualifiers.kt b/core/common/src/main/java/garousi/dev/common/di/CoroutinesQualifiers.kt new file mode 100644 index 0000000..4e80cae --- /dev/null +++ b/core/common/src/main/java/garousi/dev/common/di/CoroutinesQualifiers.kt @@ -0,0 +1,23 @@ +package garousi.dev.common.di + +import javax.inject.Qualifier + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class DefaultDispatcher + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class IoDispatcher + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class MainDispatcher + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class MainImmediateDispatcher + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class ApplicationScope diff --git a/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt b/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt new file mode 100644 index 0000000..c40c1c6 --- /dev/null +++ b/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt @@ -0,0 +1,23 @@ +package garousi.dev.common.di + +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob + +@Module +@InstallIn(SingletonComponent::class) +object CoroutinesScopesModule { + @Singleton // Provide always the same instance + @Provides + fun providesCoroutineScope( + @DefaultDispatcher defaultDispatcher: CoroutineDispatcher + ): CoroutineScope { + // Run this code when providing an instance of CoroutineScope + return CoroutineScope(SupervisorJob() + defaultDispatcher) + } +} \ No newline at end of file From 755e9eb727c983c2da62fb7e8220d54f866c2834 Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:58:46 +0330 Subject: [PATCH 08/10] Adding hilt dependencies in :core:common and :core:network:light-streamer for #56 --- core/common/build.gradle | 5 +++++ core/network/light-streamer/build.gradle | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/core/common/build.gradle b/core/common/build.gradle index ccb571f..4dafe0a 100644 --- a/core/common/build.gradle +++ b/core/common/build.gradle @@ -1,6 +1,8 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' + id 'kotlin-kapt' + id 'com.google.dagger.hilt.android' } android { @@ -38,4 +40,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + implementation "com.google.dagger:hilt-android:2.44.2" + kapt "com.google.dagger:hilt-compiler:2.44.2" } \ No newline at end of file diff --git a/core/network/light-streamer/build.gradle b/core/network/light-streamer/build.gradle index 6aa4c76..2760992 100644 --- a/core/network/light-streamer/build.gradle +++ b/core/network/light-streamer/build.gradle @@ -1,6 +1,8 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' + id 'kotlin-kapt' + id 'com.google.dagger.hilt.android' } android { @@ -38,7 +40,13 @@ dependencies { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + implementation project(":core:common") api "com.lightstreamer:ls-android-client:4.2.6" api "com.lightstreamer:ls-log-adapter-java:1.0.2" + implementation "com.google.dagger:hilt-android:2.44.2" + kapt "com.google.dagger:hilt-compiler:2.44.2" + + androidTestImplementation 'com.google.dagger:hilt-android-testing:2.44.2' + kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.44.2' } \ No newline at end of file From 31624ac3926facaf8d19198dc0b3323866a4bd3b Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 11:59:14 +0330 Subject: [PATCH 09/10] Annotating DefaultLightStreamerConnection.kt with @Inject for #56 --- .../lightstreamer/connection/DefaultLightStreamerConnection.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt index 29b4381..818dfbb 100644 --- a/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt +++ b/core/network/light-streamer/src/main/java/garousi/dev/lightstreamer/connection/DefaultLightStreamerConnection.kt @@ -8,8 +8,9 @@ import com.lightstreamer.client.Subscription import com.lightstreamer.client.SubscriptionListener import garousi.dev.lightstreamer.listeners.EmptyClientListener import garousi.dev.lightstreamer.models.SubscriptionMode +import javax.inject.Inject -class DefaultLightStreamerConnection : LightStreamerConnection { +class DefaultLightStreamerConnection @Inject constructor() : LightStreamerConnection { override var lsClient: LightstreamerClient? = null override var subscription: Subscription? = null override var subscriptionListener: SubscriptionListener? = null From 010165fb35aea0b64157637a78ea576e01da083c Mon Sep 17 00:00:00 2001 From: Vahid Garousi Date: Fri, 17 Mar 2023 12:00:33 +0330 Subject: [PATCH 10/10] Fix detekt issue for NewLineAtEndOfFile in CoroutinesScopesModule.kt #56 --- .../main/java/garousi/dev/common/di/CoroutinesScopesModule.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt b/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt index c40c1c6..a6898d4 100644 --- a/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt +++ b/core/common/src/main/java/garousi/dev/common/di/CoroutinesScopesModule.kt @@ -20,4 +20,4 @@ object CoroutinesScopesModule { // Run this code when providing an instance of CoroutineScope return CoroutineScope(SupervisorJob() + defaultDispatcher) } -} \ No newline at end of file +}