Skip to content

Commit

Permalink
Timeout in network petitions for avoiding "forever" requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Javinator9889 committed Jul 3, 2020
1 parent d78d41b commit 2fcfff1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -40,7 +40,7 @@ android {
applicationId "com.javinator9889.handwashingreminder"
minSdkVersion 17
targetSdkVersion 29
versionCode 136
versionCode 137
versionName "1.2.0-${gitCommitHash}"
multiDexEnabled true
resConfigs "en", "es"
Expand Down
Expand Up @@ -196,9 +196,6 @@ class DiseasesFragment : BaseFragmentView(), LayoutVisibilityChange,
)
)
handwashingViewModel.increment(CalendarUtils.today.time)
Timber.d("${CalendarUtils.lastWeek.time}")
Timber.d("${CalendarUtils.lastMonth.time}")
handwashingViewModel.create(Handwashing(CalendarUtils.lastWeek.time, 12))
leaves.visibility = View.VISIBLE
if (!leaves.isAnimating)
leaves.playAnimation()
Expand All @@ -215,7 +212,6 @@ class DiseasesFragment : BaseFragmentView(), LayoutVisibilityChange,
)
)
handwashingViewModel.decrement(CalendarUtils.today.time)
handwashingViewModel.create(Handwashing(CalendarUtils.lastMonth.time, 123))
}
}
}
Expand Down
Expand Up @@ -18,16 +18,20 @@
*/
package com.javinator9889.handwashingreminder.network

import okhttp3.CacheControl
import okhttp3.Headers
import okhttp3.OkHttpClient
import okhttp3.Request
import com.javinator9889.handwashingreminder.application.HandwashingApplication
import okhttp3.*
import okio.BufferedSource
import java.io.IOException
import java.io.Reader
import java.util.concurrent.TimeUnit

class HttpDownloader : OkHttpDownloader {
private val client = OkHttpClient()
private val client: OkHttpClient = OkHttpClient.Builder()
.cache(Cache(HandwashingApplication.instance.cacheDir, 2024 * 10))
.callTimeout(5, TimeUnit.SECONDS)
.readTimeout(1, TimeUnit.MINUTES)
.followRedirects(true)
.build()

override fun downloadFile(url: String): BufferedSource {
val request = with(Request.Builder()) {
Expand Down

0 comments on commit 2fcfff1

Please sign in to comment.