mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-05 03:57:24 +00:00
v3.1.3 - Fixed the satellite data update bug #108
This commit is contained in:
7 files changed
+42
-35
No files matched your search
+3
-2
@@ -15,8 +15,8 @@ android {
|
||||
applicationId "com.rtbishop.look4sat"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 312
|
||||
versionName '3.1.2'
|
||||
versionCode 313
|
||||
versionName '3.1.3'
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -76,6 +76,7 @@ dependencies {
|
||||
implementation "com.google.android.material:material:$material_version"
|
||||
implementation "com.google.dagger:hilt-android:$hilt_version"
|
||||
kapt "com.google.dagger:hilt-compiler:$hilt_version"
|
||||
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
|
||||
implementation "org.osmdroid:osmdroid-android:$osmdroid_version"
|
||||
|
||||
// implementation "androidx.compose.ui:ui:$compose_version"
|
||||
|
||||
@@ -20,13 +20,20 @@ package com.rtbishop.look4sat.framework.data
|
||||
import com.rtbishop.look4sat.domain.data.IRemoteDataSource
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import java.io.InputStream
|
||||
import java.net.URL
|
||||
|
||||
class RemoteDataSource(private val ioDispatcher: CoroutineDispatcher) : IRemoteDataSource {
|
||||
class RemoteDataSource(
|
||||
private val httpClient: OkHttpClient, private val ioDispatcher: CoroutineDispatcher
|
||||
) : IRemoteDataSource {
|
||||
|
||||
@Suppress("BlockingMethodInNonBlockingContext")
|
||||
override suspend fun getDataStream(url: String): InputStream? = withContext(ioDispatcher) {
|
||||
URL(url).openStream()
|
||||
try {
|
||||
val request = Request.Builder().url(url).build()
|
||||
httpClient.newCall(request).execute().body?.byteStream()
|
||||
} catch (exception: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ import dagger.hilt.components.SingletonComponent
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import okhttp3.OkHttpClient
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@@ -58,7 +59,7 @@ object BaseModule {
|
||||
val fileSource = FileDataSource(context.contentResolver, Dispatchers.IO)
|
||||
val entries = LocalEntrySource(db.entriesDao())
|
||||
val radios = LocalRadioSource(db.radiosDao())
|
||||
val remoteSource = RemoteDataSource(Dispatchers.IO)
|
||||
val remoteSource = RemoteDataSource(OkHttpClient.Builder().build(), Dispatchers.IO)
|
||||
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
return DataRepository(parser, fileSource, entries, radios, remoteSource, scope, settings)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user