Skip to content

Commit

Permalink
Merge pull request #303 from Adventech/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
TinasheMzondiwa authored Mar 6, 2022
2 parents 734eef9 + 9e75913 commit a9bae76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/BuildAndroidConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object BuildAndroidConfig {
object Version {
private const val MAJOR = 4
private const val MINOR = 9
private const val PATCH = 0
private const val PATCH = 1

const val name = "$MAJOR.$MINOR.$PATCH"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ object ApiModule {
): OkHttpClient = OkHttpClient.Builder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.writeTimeout(2, TimeUnit.MINUTES)
.addInterceptor(
HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ internal class ReaderArtifactHelper @Inject constructor(
@ApplicationContext private val context: Context,
private val lessonsApi: SSLessonsApi,
private val ssPrefs: SSPrefs,
private val okHttpClient: OkHttpClient,
private val dispatcherProvider: DispatcherProvider,
private val connectivityHelper: ConnectivityHelper
) : CoroutineScope by CoroutineScope(dispatcherProvider.default) {
Expand Down Expand Up @@ -78,16 +79,19 @@ internal class ReaderArtifactHelper @Inject constructor(
val request = Request.Builder()
.url(URL)
.build()
OkHttpClient()
.newCall(request)
.execute()
.use { response ->
val body = response.body ?: return@use
destination.sink().buffer().use { sink ->
sink.writeAll(body.source())
callback()
}
try {
val response = okHttpClient.newCall(request).execute()
val body = response.body ?: run {
Timber.e("Failed to download reader")
return
}
destination.sink().buffer().use { sink ->
sink.writeAll(body.source())
callback()
}
} catch (error: Throwable) {
Timber.e(error)
}
}

companion object {
Expand Down

0 comments on commit a9bae76

Please sign in to comment.