@@ -15,7 +15,6 @@ import java.util.concurrent.Executors
1515import javax.inject.Inject
1616import kotlinx.coroutines.CoroutineScope
1717import kotlinx.coroutines.Dispatchers
18- import kotlinx.coroutines.SupervisorJob
1918import kotlinx.coroutines.launch
2019import kotlinx.coroutines.withContext
2120import okhttp3.ResponseBody
@@ -25,6 +24,8 @@ import org.ole.planet.myplanet.R
2524import org.ole.planet.myplanet.callback.SecurityDataCallback
2625import org.ole.planet.myplanet.callback.SuccessListener
2726import org.ole.planet.myplanet.di.ApiInterfaceEntryPoint
27+ import org.ole.planet.myplanet.di.ApplicationScope
28+ import org.ole.planet.myplanet.di.ApplicationScopeEntryPoint
2829import org.ole.planet.myplanet.di.AutoSyncEntryPoint
2930import org.ole.planet.myplanet.model.MyPlanet
3031import org.ole.planet.myplanet.model.RealmCommunity
@@ -52,19 +53,25 @@ import retrofit2.Response
5253
5354class Service @Inject constructor(
5455 private val context : Context ,
55- private val retrofitInterface : ApiInterface
56+ private val retrofitInterface : ApiInterface ,
57+ @ApplicationScope private val serviceScope : CoroutineScope ,
5658) {
5759 constructor (context: Context ) : this (
5860 context,
5961 EntryPointAccessors .fromApplication(
6062 context.applicationContext,
6163 ApiInterfaceEntryPoint ::class .java
62- ).apiInterface()
64+ ).apiInterface(),
65+ EntryPointAccessors .fromApplication(
66+ context.applicationContext,
67+ ApplicationScopeEntryPoint ::class .java
68+ ).applicationScope(),
6369 )
70+
6471 private val preferences: SharedPreferences = context.getSharedPreferences(PREFS_NAME , Context .MODE_PRIVATE )
65- private val serviceScope = CoroutineScope (SupervisorJob () + Dispatchers .IO )
6672 private val serverAvailabilityCache = ConcurrentHashMap <String , Pair <Boolean , Long >>()
67- private val configurationManager = ConfigurationManager (context, preferences, retrofitInterface)
73+ private val configurationManager =
74+ ConfigurationManager (context, preferences, retrofitInterface)
6875 private fun getUploadToShelfService (): UploadToShelfService {
6976 val entryPoint = EntryPointAccessors .fromApplication(
7077 context.applicationContext,
0 commit comments